services:
  nginx:
    image: nginx:1.15.3
    ports:
      - 80:80
    volumes:
      - ./docker/conf/nginx/development.conf:/etc/nginx/conf.d/default.conf
    depends_on:
      - backend
      - event_proxy
    networks:
      - main

  backend:
    build:
      context: backend
      dockerfile: ../docker/conf/backend/Dockerfile
    restart: unless-stopped
    env_file: ./backend/.env
    environment:
      DATABASE_CLIENT: ${DATABASE_CLIENT}
      DATABASE_HOST: ${DATABASE_HOST}
      DATABASE_PORT: ${DATABASE_PORT}
      DATABASE_NAME: ${DATABASE_NAME}
      DATABASE_USERNAME: ${DATABASE_USERNAME}
      DATABASE_PASSWORD: ${DATABASE_PASSWORD}
      JWT_SECRET: ${JWT_SECRET}
      ADMIN_JWT_SECRET: ${ADMIN_JWT_SECRET}
      APP_KEYS: ${APP_KEYS}
      NODE_ENV: ${NODE_ENV}
    volumes:
      - ./backend/config:/opt/app/config
      - ./backend/src:/opt/app/src
      - ./backend/package.json:/opt/package.json
      - ./backend/yarn.lock:/opt/yarn.lock
      - ./backend/.env:/opt/app/.env
      - ./backend/public:/opt/app/public
    ports:
      - "1337:1337"
    networks:
      - main
    depends_on:
      - database

  event_proxy:
    build:
      context: event-proxy
      dockerfile: ../docker/conf/event-proxy/Dockerfile
    restart: unless-stopped
    env_file: ./event-proxy/.env
    volumes:
      - ./event-proxy:/opt/app/
    ports:
      - "3010:3010"
    networks:
      - main

  database:
    platform: linux/amd64
    restart: unless-stopped
    env_file: ./backend/.env
    image: postgres:16.3
    environment:
      POSTGRES_USER: ${DATABASE_USERNAME}
      POSTGRES_PASSWORD: ${DATABASE_PASSWORD}
      POSTGRES_DB: ${DATABASE_NAME}
    volumes:
      - database-data:/var/lib/postgresql/data/
    ports:
      - "5432:5432"
    networks:
      - main

volumes:
  database-data:

networks:
  main:
    name: Main
    driver: bridge
