# «Заметки»: приложение и nginx перед ним
name: rpd

services:
  app:
    build: .
    image: rpd-notes:compose
    environment:
      GREETING: ${GREETING:-Заметки}
      STARTUP_DELAY: ${STARTUP_DELAY:-5}
    volumes:
      - notes-data:/data
    healthcheck:
      # Готово, если /health отвечает 200. Ответ 503 или ошибка соединения — код 1
      test: ["CMD", "python3", "-c", "import urllib.request; urllib.request.urlopen('http://127.0.0.1:8000/health', timeout=2)"]
      interval: 5s
      timeout: 3s
      retries: 3
      start_period: 15s
    restart: unless-stopped

  web:
    image: nginx:1.30-alpine
    ports:
      - "127.0.0.1:${WEB_PORT:-8080}:80"
    volumes:
      - ./nginx/default.conf:/etc/nginx/conf.d/default.conf:ro
    depends_on:
      app:
        condition: service_healthy
    restart: unless-stopped

volumes:
  notes-data:
    name: rpd-notes-data

networks:
  default:
    name: rpd-net
