services:
  web:
    build:
      context: .
      dockerfile: Dockerfile
    container_name: web
    networks:
      - caddy_shared
      - ass5_net
    environment:
      ASPNETCORE_ENVIRONMENT: Production
    restart: always
    depends_on:
      - db
    expose:
      - "8080"

  db:
    image: postgres:16
    container_name: db
    networks:
      - ass5_net
    environment:
      POSTGRES_DB: db
      POSTGRES_USER: user
      POSTGRES_PASSWORD: password
    volumes:
      - postgres_data:/var/lib/postgresql/data
    restart: always
    expose:
      - "5432"

  caddy:
    image: caddy:2
    networks:
      - caddy_shared
    container_name: caddy
    restart: always
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - ./Caddyfile:/etc/caddy/Caddyfile
      - caddy_data:/data
      - caddy_config:/config

volumes:
  postgres_data:
  caddy_data:
  caddy_config:

networks:
  caddy_shared:
    external: true
  ass5_net:
    external: false
