services:
  db:
    image: postgres:16.2
    container_name: ${APP_NAME}-db
    environment:
      POSTGRES_PASSWORD: ${DB_PASSWORD}
      POSTGRES_USER: ${DB_USER}
      POSTGRES_DB: ${DB_NAME}
    networks:
      - app
    ports:
      - '${DB_PORT}:5432'

  nginx:
    build:
      context: .
      dockerfile: docker/nginx/Dockerfile
    container_name: ${APP_NAME}-nginx
    ports:
      - '${NGINX_PORT}:80'
    volumes:
      - ./app/public:/app/public
    networks:
      - app
    links:
      - app
    depends_on:
      - app

  app:
    build:
      context: .
      dockerfile: docker/app/Dockerfile
    container_name: ${APP_NAME}-app
    volumes:
      - ./app:/app
      - ./.env:/app/.env
    networks:
      - app
    depends_on:
      - db

networks:
  app:
    driver: bridge
