version: '3.8'

services:
    mongodb:
        container_name: mongodb
        image: mongo:latest
        restart: unless-stopped
        ports:
            - 27017:27017
        volumes:
            - db:/data/db
    app:
        container_name: api
        depends_on:
            - mongodb
        user: 'node'
        restart: unless-stopped
        env_file: .env
        command: 'npm start'
        ports:
            - ${PORT}:${PORT}
        environment:
            - TOKEN=${TOKEN}
            - PORT=${PORT}
            - MONGODB_ENABLED=${MONGODB_ENABLED}
            - MONGODB_URL=mongodb://mongodb:27017
            - WEBHOOK_ENABLED=${WEBHOOK_ENABLED}
            - WEBHOOK_URL=${WEBHOOK_URL}
            - WEBHOOK_BASE64=${WEBHOOK_BASE64}
        volumes:
            - ./:/home/node/app
        working_dir: /home/node/app
        image: node:17.2.0-alpine

volumes:
    db:
