89 lines
2.1 KiB
YAML
89 lines
2.1 KiB
YAML
services:
|
|
# MongoDB Service
|
|
mongodb:
|
|
image: mongo:6.0
|
|
container_name: infinity-mongodb
|
|
restart: always
|
|
environment:
|
|
MONGO_INITDB_ROOT_USERNAME: ${MONGO_INITDB_ROOT_USERNAME}
|
|
MONGO_INITDB_ROOT_PASSWORD: ${MONGO_INITDB_ROOT_PASSWORD}
|
|
MONGO_INITDB_DATABASE: ${MONGO_INITDB_DATABASE}
|
|
volumes:
|
|
- mongodb_data:/data/db
|
|
ports:
|
|
- "27017:27017"
|
|
networks:
|
|
- infinity-network
|
|
healthcheck:
|
|
test: ["CMD", "mongosh", "--eval", "db.adminCommand('ping')"]
|
|
interval: 10s
|
|
timeout: 5s
|
|
retries: 5
|
|
|
|
# Web Application (Next.js)
|
|
webapp:
|
|
build:
|
|
context: .
|
|
dockerfile: webapp/Dockerfile
|
|
container_name: infinity-webapp
|
|
restart: always
|
|
depends_on:
|
|
mongodb:
|
|
condition: service_healthy
|
|
environment:
|
|
- NODE_ENV=${NODE_ENV}
|
|
- DB_URI=${DB_URI}
|
|
- NEXT_PUBLIC_API_URL=${NEXT_PUBLIC_API_URL}
|
|
env_file: .env
|
|
ports:
|
|
- "3003:3000" # Map to a fixed port instead of dynamic
|
|
networks:
|
|
- infinity-network
|
|
healthcheck:
|
|
test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:3000/api/health"]
|
|
interval: 20s
|
|
timeout: 10s
|
|
retries: 3
|
|
|
|
# Worker Service
|
|
worker:
|
|
build:
|
|
context: .
|
|
dockerfile: worker/Dockerfile
|
|
container_name: infinity-worker
|
|
restart: always
|
|
depends_on:
|
|
mongodb:
|
|
condition: service_healthy
|
|
environment:
|
|
- DB_URI=${DB_URI}
|
|
env_file: .env
|
|
networks:
|
|
- infinity-network
|
|
|
|
# Helper Service (runs once to create admin account)
|
|
create-admin:
|
|
build:
|
|
context: .
|
|
dockerfile: helpers/Dockerfile
|
|
container_name: infinity-create-admin
|
|
depends_on:
|
|
mongodb:
|
|
condition: service_healthy
|
|
environment:
|
|
- DB_URI=${DB_URI}
|
|
- ADMIN_USERNAME=${ADMIN_USERNAME}
|
|
- ADMIN_PASSWORD=${ADMIN_PASSWORD}
|
|
env_file: .env
|
|
networks:
|
|
- infinity-network
|
|
# This ensures the container exits after creating the admin account
|
|
command: sh -c "python create_account.py"
|
|
|
|
networks:
|
|
infinity-network:
|
|
driver: bridge
|
|
|
|
volumes:
|
|
mongodb_data:
|
|
driver: local |