-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build: use makefile for local setup, run migrations from container
- Loading branch information
1 parent
87a7b7e
commit 6ef770b
Showing
6 changed files
with
79 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,45 @@ | ||
# ===== | ||
|
||
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..." | ||
yarn dockerup-db | ||
|
||
@read -p "Enter the DATABASE_URL for seeding: " DATABASE_URL; \ | ||
DATABASE_URL=$$DATABASE_URL yarn workspace @creature-chess/data prisma-migrate deploy | ||
docker compose -f docker-compose.db.yml up -d postgres | ||
docker compose run -e DATABASE_URL nodejs-builder yarn workspace @creature-chess/data prisma migrate deploy | ||
|
||
server: | ||
@echo "Running the game..." | ||
yarn dockerup | ||
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 @creature-chess/data prisma migrate dev --name $$MIGRATION_NAME; \ | ||
CONTAINER_ID=$$(docker ps -aqf "ancestor=nodejs-builder" --latest); \ | ||
docker cp $$CONTAINER_ID:/code/modules/@creature-chess/data/prisma/migrations ./modules/@creature-chess/data/prisma/; \ | ||
docker stop $$CONTAINER_ID; \ | ||
docker rm $$CONTAINER_ID; \ | ||
yarn workspace @creature-chess/data prisma generate |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters