version: '3.8' services: db: image: postgres:15-alpine container_name: shortener-db environment: POSTGRES_DB: shortener POSTGRES_USER: shortener POSTGRES_PASSWORD: shortener123 ports: - "5432:5432" volumes: - shortener-data:/var/lib/postgresql/data healthcheck: test: ["CMD-SHELL", "pg_isready -U shortener"] interval: 5s timeout: 5s retries: 5 networks: - shortener-network app: build: context: . dockerfile: Dockerfile args: - API_URL=${API_URL:-http://localhost:3000} container_name: shortener-app ports: - "3000:3000" environment: - DATABASE_URL=postgresql://shortener:shortener123@db:5432/shortener - SERVER_HOST=0.0.0.0 - SERVER_PORT=3000 depends_on: db: condition: service_healthy healthcheck: test: ["CMD", "curl", "-f", "http://localhost:8080/api/health"] interval: 30s timeout: 10s retries: 3 start_period: 40s networks: - shortener-network deploy: restart_policy: condition: on-failure max_attempts: 3 window: 120s networks: shortener-network: driver: bridge volumes: shortener-data: