diff --git a/docker-compose-dev-backend.yml b/docker-compose-dev-backend.yml new file mode 100644 index 0000000..6429516 --- /dev/null +++ b/docker-compose-dev-backend.yml @@ -0,0 +1,52 @@ +services: + notatest-psql: + image: postgres:16-alpine + container_name: notatest-psql + restart: unless-stopped + healthcheck: + test: ["CMD-SHELL", "pg_isready -d $${POSTGRES_DB} -U $${POSTGRES_USER}"] + start_period: 20s + interval: 30s + retries: 5 + timeout: 5s + volumes: + - notatest-data:/var/lib/postgresql/data + networks: + - notatest + environment: + POSTGRES_USER: ${PG_USER:-notatest} + POSTGRES_PASSWORD: ${PG_PASS:?db password required} + POSTGRES_DB: ${PG_DB:-notatest} + + notatest-server: + container_name: notatest-server + build: + context: ${PWD}/server + dockerfile: ${PWD}/server/Dockerfile + image: notatest-server:latest + networks: + - notatest + ports: + - 8080:8080 # ! + depends_on: + notatest-psql: + condition: service_healthy + environment: + JWT_SECRET: ${JWT_SECRET:?jwt secret required} + DB_URL: postgres://${PG_USER:-notatest}:${PG_PASS:?db password required}@notatest-psql/${PG_DB:-notatest}?sslmode=disable + CSRF_SECRET: ${CSRF_SECRET:?csrf secret required} + ADMIN_USERNAME: ${ADMIN_USERNAME:?init admin username required} + ADMIN_PASSWORD: ${ADMIN_PASSWORD:?init admin password required} + LOG_LEVEL: debug + APP_ENV: development + DOMAIN: localhost + FRONTEND_URL: http://localhost:3000 + +networks: + notatest: + external: false + name: notatest + +volumes: + notatest-data: + name: notatest-data diff --git a/scripts/purge.sh b/scripts/purge.sh index ad9325a..d822417 100755 --- a/scripts/purge.sh +++ b/scripts/purge.sh @@ -3,4 +3,4 @@ # Delete all Docker artifacts (e.g. DB) from previous test runs docker stop notatest-server notatest-psql && docker rm -f notatest-server notatest-psql -docker volume rm -f notatest_notatest-data +docker volume rm -f notatest-data diff --git a/scripts/run_dev.sh b/scripts/run_backend_dev.sh similarity index 63% rename from scripts/run_dev.sh rename to scripts/run_backend_dev.sh index d09206b..4a64074 100755 --- a/scripts/run_dev.sh +++ b/scripts/run_backend_dev.sh @@ -1,8 +1,10 @@ #!/usr/bin/env bash +DEV_COMPOSE_FILE="docker-compose-dev-backend.yml" + [ "$( docker container inspect -f '{{.State.Status}}' notatest-psql )" = "running" ] || docker compose up notatest-psql -d # Shutdown, rebuild, & restart docker compose stop notatest-server && docker compose rm -f notatest-server -docker compose build -docker compose up notatest-server +docker compose -f $DEV_COMPOSE_FILE build +docker compose -f $DEV_COMPOSE_FILE up notatest-server