docker-compose.yaml
services:
###########
### API ###
###########
spr-api:
container_name: spr-api
tty: true
restart: on-failure
build:
context: ./api
environment:
- API_PORT=${API_PORT:-3004}
- MONGO_PORT=${MONGO_PORT:-27017}
- MONGO_USERNAME=${MONGO_USERNAME}
- MONGO_PASSWORD=${MONGO_PASSWORD}
- MONGO_DATABASE=${MONGO_DATABASE}
- MONGO_SERVICE=${MONGO_SERVICE}
- CONTAINERIZED=true
- ENVIRONMENT=${ENVIRONMENT}
- FRONTEND_PORT=${FRONTEND_PORT}
- FRONTEND_URL=${FRONTEND_URL}
- BACKEND_URL=${BACKEND_URL}
- SSO_CLIENT_ID=${SSO_CLIENT_ID}
- SSO_CLIENT_SECRET=${SSO_CLIENT_SECRET}
- SSO_AUTH_SERVER_URL=${SSO_AUTH_SERVER_URL}
- GC_NOTIFY_API_KEY=${GC_NOTIFY_API_KEY}
- GC_NOTIFY_ADMIN_EMAIL=${GC_NOTIFY_ADMIN_EMAIL}
- TESTING=${TESTING}
networks:
- purchase-net
ports:
- ${API_PORT:-3004}:${API_PORT:-3004}
healthcheck:
test: curl localhost:${API_PORT:-3004}/api/health | grep 'API running'
interval: 20s
timeout: 30s
retries: 5
start_period: 20s
depends_on:
mongo:
condition: service_healthy
###########
### APP ###
###########
spr-app:
container_name: spr-app
tty: true
restart: on-failure
build:
context: ./app
target: prod
networks:
- purchase-net
ports:
- 8080:8080
healthcheck:
test: curl --fail http://localhost:8080 || exit 1
interval: 20s
retries: 5
start_period: 20s
timeout: 30s
depends_on:
spr-api:
condition: service_healthy
#############
### MONGO ###
#############
mongo:
image: mongo:5.0.15
container_name: mongodb
tty: true
restart: always
environment:
- MONGO_INITDB_ROOT_USERNAME=${MONGO_USERNAME}
- MONGO_INITDB_ROOT_PASSWORD=${MONGO_PASSWORD}
- MONGO_DATABASE_NAME=${MONGO_DATABASE:-purchase-db}
volumes:
- ./mongoSeed/init:/docker-entrypoint-initdb.d
- ./mongo/init/data:/tmp/data
- ./mongo/data:/data/db
ports:
- ${MONGO_PORT:-27017}:27017
networks:
- purchase-net
healthcheck:
test: echo 'db.runCommand({serverStatus:1}).ok' | mongo admin -u ${MONGO_USERNAME} -p ${MONGO_PASSWORD} --quiet | grep 1
interval: 20s
timeout: 30s
retries: 5
start_period: 120s
###########
### NET ###
###########
networks:
purchase-net:
driver: "bridge"