Skip to content

Commit fd9f419

Browse files
committed
Add clean and seed scripts
1 parent 05bc11e commit fd9f419

File tree

3 files changed

+66
-1
lines changed

3 files changed

+66
-1
lines changed

README.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,20 @@ $ ./start.sh
4848
$ ./stop.sh
4949
```
5050

51+
#### Clean docker env
52+
Incase if you encounter any issue in the servers you can run the clean script to clean all docker containers and db.
53+
```bash
54+
$ ./clean.sh
55+
```
56+
> NOTE: In some cases that some containers are not cleaned/removed you need to restart, stopped or kill your docker process in your system or manually remove those images/containers.
57+
58+
59+
#### Database seeeding
60+
Incase if you add and seed the database you run this script only if mysql db server (or after the exeucution of ./start.sh) is up and running
61+
```bash
62+
$ ./seed.sh
63+
```
64+
5165
<br>
5266

5367

@@ -120,7 +134,7 @@ $ npx prisma generate
120134
```bash
121135
# Docker commands
122136
$ docker ps -a
123-
$ docker system prune -a
137+
$ docker container prune
124138
$ docker ps -a
125139
$ docker rm <id>
126140

clean.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/bin/bash
2+
3+
echo "===========[ Clean environment...] ============ ${pwd}"
4+
5+
./stop.sh
6+
7+
echo "===========[ Clean docker containers...] ============ ${pwd}"
8+
docker container ls -f 'status=exited' -f 'status=dead' -f 'status=created'
9+
10+
docker stop $(docker ps --filter "status=exited" -q)
11+
docker container rm $(docker container ls -q -f 'status=exited' -f 'exited=0')
12+
docker rm -v $(docker ps --filter status=exited -q)
13+
14+
15+
# Navigate back to backend directory and run Prisma migrations
16+
cd backend
17+
18+
echo "===========[ Clean all existing backend dbdata...] ============ ${pwd}"
19+
rm -rf dbdata node_modules
20+
21+
22+
echo "===========[ Clean environment done! ] ============"
23+
24+
echo "You can now run a clean start by running ./start.sh"
25+
26+

seed.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/bash
2+
3+
echo "===========[ Run backend seeding...] ============ ${pwd}"
4+
5+
# Navigate back to backend directory and run Prisma migrations
6+
cd backend
7+
8+
echo "===========[ Clean all existing backend dbdata...] ============ ${pwd}"
9+
rm -rf dbdata
10+
11+
12+
echo "===========[ Run prisma migrate ...] ============ ${pwd}"
13+
# npx prisma db seed
14+
npx prisma migrate dev
15+
16+
17+
echo "===========[ Run prisma seeding db...] ============ ${pwd}"
18+
npx prisma db seed
19+
20+
21+
echo "===========[ Seeding Done! ] ============"
22+
23+
echo "To test backend API service endpoint: "
24+
echo "http: //localhost:8888/"
25+

0 commit comments

Comments
 (0)