version: '3.8'

services:
  homework-backend:
    image: ${DOCKER_REGISTRY}/homework-backend:${DOCKER_TAG}
    ports:
      - "8080:8080"
    environment:
      - ASPNETCORE_ENVIRONMENT=Staging
      - ASPNETCORE_URLS=http://+:8080
    volumes:
      - ./Homework/Logs:/app/Logs
    networks:
      - homework-network
    depends_on:
      - postgres-staging
    restart: unless-stopped
    deploy:
      replicas: 2
      resources:
        limits:
          cpus: '0.50'
          memory: 512M
        reservations:
          cpus: '0.25'
          memory: 256M

  postgres-staging:
    image: postgres:15-alpine
    environment:
      - POSTGRES_DB=homework_staging
      - POSTGRES_USER=homework_user
      - POSTGRES_PASSWORD=${DB_PASSWORD}
    volumes:
      - postgres_staging_data:/var/lib/postgresql/data
    networks:
      - homework-network
    restart: unless-stopped
    deploy:
      resources:
        limits:
          cpus: '0.50'
          memory: 512M

volumes:
  postgres_staging_data:

networks:
  homework-network:
    driver: bridge