version: '3.8'

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

    frontend-dev:
        container_name: fusero-frontend-dev
        build:
            context: ./frontend
            dockerfile: Dockerfile.dev
        ports:
            - '8080:8080'
        volumes:
            - ./frontend:/app
            - /app/node_modules
        environment:
            - NODE_ENV=development
        command: npm run dev
        networks:
            - fusero-network
        depends_on:
            - fusero-app-boilerplate

    fusero-app-boilerplate:
        environment:
            - POSTGRES_HOST=fusero-boilerplate-db
        build:
            context: .
            dockerfile: Dockerfile
        env_file: .env
        restart: always
        ports:
            - '5000:14000'
        depends_on:
            - fusero-boilerplate-db
        container_name: fusero-app-boilerplate
        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

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

networks:
    fusero-network:
        name: fusero-network
