name: opencode

include:
    - path: ./app/backend/tools/db/docker-compose.yml

services:
    data-provider:
        depends_on:
            db:
                condition: service_healthy
                required: true
        image: data-provider
        build:
            context: .
            args:
                - UID=${LOCAL_USER_ID}
                - GID=${LOCAL_GROUP_ID}
        environment:
            - SPRING_PROFILES_ACTIVE=local
            - OCCMD_PATH=/app/scripts/occmd.sh
            - XDG_CONFIG_HOME=/app/.config/
            - GIT_CLONE_TARGET_DIRECTORY=/app/git/
            - host=db

            - OC_GL_USER=${OC_GL_USER}
            - OC_GL_APIKEY=${OC_GL_APIKEY}

            - MANAGEMENT_PORT=${MANAGEMENT_PORT}
            - PROJECT_IDS=${PROJECT_IDS} # occmd-public, Covid19 fraud detection, Opendesk, Helm chart, e2e tests
            - CORS_ORIGIN=${CORS_ORIGIN} # Must be without quotes i.e. allow everything: * | originally https://sec-kpi.opencode.de
            - PORT=${PORT}
            - DB_USER=${DB_USER}
            - DB_NAME=${DB_NAME}
            - DB_PORT=${DB_PORT}
            - ADMIN_PASSWORD=${ADMIN_PASSWORD}
            - ADMIN_USERNAME=${ADMIN_USERNAME}
            - HMAC_KEY=${HMAC_KEY}
            - API_KEY=${API_KEY}
        ports:
            - ${PORT}:${PORT}
    occmd:
        profiles: [occmd]
        image: data-provider
        entrypoint: ["tail", "-f", "/dev/null"]
        environment:
            - OC_GL_USER=${OC_GL_USER}
            - OC_GL_APIKEY=${OC_GL_APIKEY}
        volumes:
            - type: bind
              source: app/backend/.tmp
              target: /occmd/.tmp/
