version: '3.1'

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:
      - '5432:5432'

  nginx:
    image: nginx:stable-alpine
    container_name: ${APP_NAME}-nginx
    ports:
      - '80:80'
    volumes:
      - ./app:/var/www/project
      - ./nginx/default.conf:/etc/nginx/conf.d/default.conf
      - ./.env:/var/www/project/.env
    networks:
      - app
    links:
      - app
    depends_on:
      - app

  app:
    build:
      context: .
      dockerfile: docker/App.Dockerfile
    container_name: ${APP_NAME}-app
    ports:
      - '9000:9000'
    volumes:
      - ./app:/var/www/project
    networks:
      - app
    depends_on:
      - db

networks:
  app:
    driver: bridge