version: '3.8'

services:
  fusero-app-frontend:
    container_name: fusero-app-frontend
    build:
      context: ./frontend
      dockerfile: Dockerfile
    ports:
      - '3000:80'
    networks:
      - fusero-network
    depends_on:
      - fusero-app-backend

  fusero-app-frontend-dev:
    image: node:18
    container_name: fusero-app-frontend-dev
    working_dir: /app
    volumes:
      - ./frontend:/app
    ports:
      - '8080:8080'
    command: sh -c "cd /app && npm install && npm run dev -- --host 0.0.0.0 --port 8080"
    networks:
      - fusero-network
    depends_on:
      - fusero-app-backend

  fusero-app-backend:
    build:
      context: .
      dockerfile: Dockerfile
    env_file: .env
    restart: always
    ports:
      - '5000:14000'
    depends_on:
      - fusero-boilerplate-db
    container_name: fusero-app-backend
    networks:
      - fusero-network

  fusero-boilerplate-db:
    image: postgres:15
    env_file: .env
    restart: always
    volumes:
      - fusero_boilerplate_pgdata:/var/lib/postgresql/data
    ports:
      - '19095:5432'
    container_name: fusero-boilerplate-db
    networks:
      - fusero-network

  fusero-boilerplate-test-db:
    image: postgres:15
    env_file: .env
    restart: always
    volumes:
      - fusero_boilerplate_test_pgdata:/var/lib/postgresql/data
    ports:
      - '19096:5432'
    container_name: fusero-boilerplate-test-db
    networks:
      - fusero-network
    environment:
      - POSTGRES_DB=test-db

  nginx:
    image: nginx:alpine
    container_name: fusero-nginx
    ports:
      - '14001:80'
      - '14443:14443'
    volumes:
      - ./nginx/nginx.conf:/etc/nginx/conf.d/default.conf:ro
      - ./nginx/certs:/etc/nginx/certs:ro
    depends_on:
      - fusero-app-frontend-dev
      - fusero-app-backend
    networks:
      - fusero-network

volumes:
  fusero_boilerplate_pgdata:
    external: true
  fusero_boilerplate_test_pgdata:
    external: false

networks:
  fusero-network:
    name: fusero-network