-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathMakefile
50 lines (40 loc) · 1.6 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# =====
all: install build db server
rebuild: build server
# =====
install:
@echo "Setting up the project..."
yarn
build:
@echo "Building the docker images..."
docker compose -f docker-compose.yml build
db:
@echo "Setting up the database and running migrations..."
docker compose -f docker-compose.db.yml up -d postgres
# This step runs a server-info container because it contains the @cc-server/data package
docker compose run -e DATABASE_URL server-info yarn workspace @cc-server/data prisma migrate deploy
server:
@echo "Running the game..."
docker compose -f docker-compose.yml up -d
down:
@echo "Stopping the game..."
docker compose -f docker-compose.yml down
@echo "Stopping the database..."
docker compose -f docker-compose.db.yml down
# =====
# This step is used to create a new migration.
# It creates a new nodejs-builder container, runs the migration command inside,
# then copies the migration files to the local machine.
add-migration:
@echo "Creating new migration"
read -p "Enter the migration name: " MIGRATION_NAME; \
docker compose -f docker-compose.db.yml up -d postgres; \
docker compose run -e DATABASE_URL nodejs-builder yarn workspace @cc-server/data prisma migrate dev --name $$MIGRATION_NAME; \
CONTAINER_ID=$$(docker ps -aqf "ancestor=nodejs-builder" --latest); \
docker cp $$CONTAINER_ID:/code/modules/@cc-server/data/prisma/migrations ./modules/@cc-server/data/prisma/; \
docker stop $$CONTAINER_ID; \
docker rm $$CONTAINER_ID; \
yarn workspace @cc-server/data prisma generate
prisma-generate:
@echo "Generating prisma client"
yarn workspace @cc-server/data run prisma-generate