version: "3.9" services: postgres: image: postgres:16-alpine container_name: finance_db restart: unless-stopped environment: POSTGRES_DB: ${POSTGRES_DB:-financedb} POSTGRES_USER: ${POSTGRES_USER:-financeuser} POSTGRES_PASSWORD: ${POSTGRES_PASSWORD} volumes: - postgres_data:/var/lib/postgresql/data - ./backend/sql/init_roles.sql:/docker-entrypoint-initdb.d/01_init_roles.sql:ro ports: - "5432:5432" networks: - finance_net healthcheck: test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-financeuser} -d ${POSTGRES_DB:-financedb}"] interval: 10s timeout: 5s retries: 5 backend: build: context: ./backend dockerfile: Dockerfile container_name: finance_backend restart: unless-stopped environment: DATABASE_URL: postgresql://${POSTGRES_USER:-financeuser}:${POSTGRES_PASSWORD}@postgres:5432/${POSTGRES_DB:-financedb} SECRET_KEY: ${SECRET_KEY} ALGORITHM: HS256 ACCESS_TOKEN_EXPIRE_MINUTES: 30 REFRESH_TOKEN_EXPIRE_DAYS: 7 DEBUG: "false" ALLOWED_ORIGINS: ${ALLOWED_ORIGINS:-http://localhost,http://localhost:3000} depends_on: postgres: condition: service_healthy networks: - finance_net volumes: - ./backend:/app expose: - "8000" frontend: build: context: ./frontend dockerfile: Dockerfile container_name: finance_frontend restart: unless-stopped networks: - finance_net expose: - "80" nginx: image: nginx:alpine container_name: finance_nginx restart: unless-stopped ports: - "80:80" - "443:443" volumes: - ./nginx/nginx.conf:/etc/nginx/nginx.conf:ro - ./nginx/certs:/etc/nginx/certs:ro depends_on: - backend - frontend networks: - finance_net volumes: postgres_data: networks: finance_net: driver: bridge