114 lines
2.7 KiB
YAML
114 lines
2.7 KiB
YAML
version: '3.8'
|
|
services:
|
|
backend:
|
|
build:
|
|
context: .
|
|
dockerfile: Dockerfile.backend
|
|
container_name: dressed-for-success-backend
|
|
hostname: backend
|
|
expose:
|
|
- "8000"
|
|
environment:
|
|
# - DATABASE_URL=postgresql://postgres:postgres@postgres:5432/shop_db
|
|
- DEBUG=0
|
|
- SECRET_KEY=${SECRET_KEY:-supersecretkey}
|
|
- UPLOAD_DIRECTORY=/app/uploads
|
|
depends_on:
|
|
postgres:
|
|
condition: service_healthy
|
|
volumes:
|
|
- ./backend/uploads:/app/uploads
|
|
networks:
|
|
app_network:
|
|
aliases:
|
|
- backend
|
|
restart: always
|
|
healthcheck:
|
|
test: ["CMD", "curl", "--fail", "http://localhost:8000/" ]
|
|
interval: 10s
|
|
timeout: 5s
|
|
retries: 3
|
|
start_period: 15s
|
|
|
|
frontend:
|
|
build:
|
|
context: .
|
|
dockerfile: Dockerfile.frontend
|
|
container_name: dressed-for-success-frontend
|
|
hostname: frontend
|
|
expose:
|
|
- "3000"
|
|
environment:
|
|
- NEXT_PUBLIC_API_URL=https://${DOMAIN_NAME}/api
|
|
- NEXT_PUBLIC_BASE_URL=https://${DOMAIN_NAME}
|
|
- NODE_ENV=production
|
|
depends_on:
|
|
backend:
|
|
condition: service_healthy
|
|
networks:
|
|
app_network:
|
|
aliases:
|
|
- frontend
|
|
restart: always
|
|
|
|
nginx:
|
|
image: nginx:alpine
|
|
container_name: dressed-for-success-nginx
|
|
ports:
|
|
- "80:80"
|
|
- "443:443"
|
|
volumes:
|
|
- ./nginx/nginx.prod.conf:/etc/nginx/conf.d/default.conf:ro
|
|
- ./backend/uploads:/app/uploads:ro
|
|
- ./certbot/conf:/etc/letsencrypt:ro
|
|
- ./certbot/www:/var/www/certbot:ro
|
|
depends_on:
|
|
- frontend
|
|
- backend
|
|
networks:
|
|
- app_network
|
|
restart: always
|
|
command: "/bin/sh -c 'while :; do sleep 6h & wait $${!}; nginx -s reload; done & nginx -g \"daemon off;\"'"
|
|
|
|
certbot:
|
|
image: certbot/certbot
|
|
container_name: dressed-for-success-certbot
|
|
volumes:
|
|
- ./certbot/conf:/etc/letsencrypt
|
|
- ./certbot/www:/var/www/certbot
|
|
networks:
|
|
- app_network
|
|
depends_on:
|
|
- nginx
|
|
entrypoint: "/bin/sh -c 'trap exit TERM; while :; do certbot renew; sleep 12h & wait $${!}; done;'"
|
|
|
|
postgres:
|
|
image: postgres:15
|
|
container_name: dressed-for-success-db
|
|
hostname: postgres
|
|
environment:
|
|
POSTGRES_DB: shop_db
|
|
POSTGRES_USER: postgres
|
|
POSTGRES_PASSWORD: ${DB_PASSWORD:-postgres}
|
|
expose:
|
|
- "5432"
|
|
volumes:
|
|
- postgres_data:/var/lib/postgresql/data
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "pg_isready -U postgres"]
|
|
interval: 5s
|
|
timeout: 5s
|
|
retries: 5
|
|
networks:
|
|
app_network:
|
|
aliases:
|
|
- postgres
|
|
restart: always
|
|
|
|
networks:
|
|
app_network:
|
|
driver: bridge
|
|
|
|
volumes:
|
|
postgres_data:
|
|
driver: local |