networks:
  portfolio:
    driver: bridge

volumes:
  pg_date: null


services:
  nginx:
    networks:
      - portfolio
    ports:
      - ${PORT-8001}:80
    volumes:
      - ./resources/layout/nginx.conf:/etc/nginx/nginx.conf
      - ./resources:/usr/share/nginx/html/resources/
    build: 
      context: .
      dockerfile: ./docker/Dockerfile.nginx
    depends_on:
      - web
  
  web:
    networks:
      - portfolio
    build:
      context: .
      dockerfile: ./docker/Dockerfile.web
    command: sh resources/scripts/entrypoint.sh
    environment:
      - PYTHONPYCACHEPREFIX=/var/cache/pycache
    volumes:
      - './:/code'
    depends_on:
      - db
    restart: always

  db:
    image: postgres:16
    networks:
      - portfolio
    restart: always
    environment:
      POSTGRES_DB: ${DB_NAME}
      POSTGRES_USER: ${DB_USER}
      POSTGRES_PASSWORD: ${DB_PASSWORD}
      POSTGRES_HOST: ${DB_HOST}
      POSTGRES_PORT: ${DB_PORT}
    volumes:
      - pg_date:/var/lib/postgresql/data