89 lines
2.0 KiB
YAML
89 lines
2.0 KiB
YAML
version: '3.8'
|
|
|
|
services:
|
|
# MongoDB Database
|
|
mongodb:
|
|
image: mongo:7.0
|
|
container_name: scoffer-mongodb
|
|
restart: unless-stopped
|
|
ports:
|
|
- "${MONGODB_PORT:-27017}:27017"
|
|
volumes:
|
|
- mongodb_data:/data/db
|
|
- ./backend/seedData.js:/docker-entrypoint-initdb.d/01-seedData.js:ro
|
|
networks:
|
|
- recipe-network
|
|
healthcheck:
|
|
test: ["CMD", "mongosh", "--eval", "db.adminCommand('ping')", "--quiet"]
|
|
interval: 30s
|
|
timeout: 10s
|
|
retries: 5
|
|
start_period: 40s
|
|
|
|
# Backend API Service
|
|
backend:
|
|
build:
|
|
context: ./backend
|
|
dockerfile: Dockerfile
|
|
container_name: scoffer-backend
|
|
restart: unless-stopped
|
|
environment:
|
|
- PORT=5000
|
|
- MONGODB_HOST=mongodb
|
|
- MONGODB_PORT=27017
|
|
- MONGODB_DATABASE=scoffer
|
|
- JWT_SECRET=${JWT_SECRET}
|
|
- ALLOW_REGISTRATION=${ALLOW_REGISTRATION:-true}
|
|
ports:
|
|
- "${BACKEND_PORT:-5000}:5000"
|
|
depends_on:
|
|
mongodb:
|
|
condition: service_healthy
|
|
networks:
|
|
- recipe-network
|
|
volumes:
|
|
- ./backend:/app
|
|
- /app/node_modules
|
|
|
|
# Frontend React App
|
|
frontend:
|
|
build:
|
|
context: ./frontend
|
|
dockerfile: Dockerfile
|
|
args:
|
|
- REACT_APP_API_URL=${REACT_APP_API_URL:-http://backend:5000/api}
|
|
container_name: scoffer-frontend
|
|
restart: unless-stopped
|
|
environment:
|
|
- REACT_APP_API_URL=${REACT_APP_API_URL:-http://backend:5000/api}
|
|
ports:
|
|
- "${FRONTEND_PORT:-3000}:80"
|
|
depends_on:
|
|
- backend
|
|
networks:
|
|
- recipe-network
|
|
|
|
# Optional: MongoDB Express for database management
|
|
mongo-express:
|
|
image: mongo-express:1.0.0
|
|
container_name: scoffer-mongo-express
|
|
restart: unless-stopped
|
|
ports:
|
|
- "${MONGO_EXPRESS_PORT:-8081}:8081"
|
|
environment:
|
|
ME_CONFIG_MONGODB_URL: mongodb://mongodb:27017/
|
|
ME_CONFIG_BASICAUTH: false
|
|
depends_on:
|
|
mongodb:
|
|
condition: service_healthy
|
|
networks:
|
|
- recipe-network
|
|
|
|
volumes:
|
|
mongodb_data:
|
|
driver: local
|
|
|
|
networks:
|
|
recipe-network:
|
|
driver: bridge
|