chore: add production docker-compose with Traefik labels
This commit is contained in:
parent
f8b8ad7033
commit
f8ddc1c349
1 changed files with 51 additions and 8 deletions
|
|
@ -4,39 +4,82 @@ services:
|
|||
backend:
|
||||
build: ./backend
|
||||
ports:
|
||||
- "8000:8000"
|
||||
- "127.0.0.1:8020:8000"
|
||||
volumes:
|
||||
- ./backend:/app
|
||||
- backend_data:/app/data
|
||||
environment:
|
||||
- DATABASE_URL=postgresql://user:password@db:5432/elmeg_db
|
||||
- DATABASE_URL=postgresql://elmeg:elmeg_password@db:5432/elmeg_db
|
||||
- SECRET_KEY=${SECRET_KEY:-demo-secret-change-in-production}
|
||||
depends_on:
|
||||
- db
|
||||
restart: unless-stopped
|
||||
healthcheck:
|
||||
test: ["CMD", "curl", "-f", "http://localhost:8000/docs"]
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
networks:
|
||||
- elmeg
|
||||
- traefik
|
||||
labels:
|
||||
- "traefik.enable=true"
|
||||
- "traefik.http.routers.elmeg-api.rule=Host(`elmeg.runfoo.run`) && PathPrefix(`/api`, `/docs`, `/openapi.json`)"
|
||||
- "traefik.http.routers.elmeg-api.entrypoints=websecure"
|
||||
- "traefik.http.routers.elmeg-api.tls.certresolver=letsencrypt"
|
||||
- "traefik.http.services.elmeg-api.loadbalancer.server.port=8000"
|
||||
- "traefik.docker.network=traefik"
|
||||
|
||||
frontend:
|
||||
build:
|
||||
context: ./frontend
|
||||
dockerfile: Dockerfile
|
||||
ports:
|
||||
- "3000:3000"
|
||||
- "127.0.0.1:3020:3000"
|
||||
volumes:
|
||||
- ./frontend:/app
|
||||
- /app/node_modules
|
||||
- /app/.next
|
||||
environment:
|
||||
- NEXT_PUBLIC_API_URL=http://localhost:8000
|
||||
- NEXT_PUBLIC_API_URL=https://elmeg.runfoo.run/api
|
||||
- INTERNAL_API_URL=http://backend:8000
|
||||
depends_on:
|
||||
- backend
|
||||
restart: unless-stopped
|
||||
networks:
|
||||
- elmeg
|
||||
- traefik
|
||||
labels:
|
||||
- "traefik.enable=true"
|
||||
- "traefik.http.routers.elmeg.rule=Host(`elmeg.runfoo.run`)"
|
||||
- "traefik.http.routers.elmeg.entrypoints=websecure"
|
||||
- "traefik.http.routers.elmeg.tls.certresolver=letsencrypt"
|
||||
- "traefik.http.routers.elmeg.priority=1"
|
||||
- "traefik.http.services.elmeg.loadbalancer.server.port=3000"
|
||||
- "traefik.docker.network=traefik"
|
||||
|
||||
db:
|
||||
image: postgres:15-alpine
|
||||
ports:
|
||||
- "5432:5432"
|
||||
environment:
|
||||
- POSTGRES_USER=user
|
||||
- POSTGRES_PASSWORD=password
|
||||
- POSTGRES_USER=elmeg
|
||||
- POSTGRES_PASSWORD=elmeg_password
|
||||
- POSTGRES_DB=elmeg_db
|
||||
volumes:
|
||||
- postgres_data:/var/lib/postgresql/data
|
||||
restart: unless-stopped
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "pg_isready -U elmeg"]
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
networks:
|
||||
- elmeg
|
||||
|
||||
volumes:
|
||||
postgres_data:
|
||||
backend_data:
|
||||
|
||||
networks:
|
||||
elmeg:
|
||||
traefik:
|
||||
external: true
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue