services:
  redis:
    image: redis:7-alpine
    container_name: graphql-abacus-redis
    ports:
      - '6379:6379'
  service:
    platform: linux/amd64
    build:
      context: .
      target: dev
      args:
        DOCKER_BUILDKIT: 1
      secrets:
        - GITHUB_NPM_TOKEN
    depends_on:
      - redis
    environment:
      - GITHUB_NPM_TOKEN=/run/secrets/GITHUB_NPM_TOKEN
      - ENV=qa
      - PORT=8080
      - NODE_ENV=dev
      - APOLLO_INTROSPECTION=true
      - APOLLO_PLAYGROUND=true
      - AUTH_ISSUERS='https://qalogin.theorchard.com/, https://qa-orchard.auth0.com/'
      - BUCKET_UPLOAD_ROLE_ARN=arn:aws:iam::437795906767:role/qa-graphql-abacus-browser-upload-role
      - BUCKET_UPLOAD_TOKEN_DURATION=3600
      - DD_TRACE_ENABLED=false
      - ENABLE_JWT_SERVICE_CACHE=false
      - LOG_LEVEL=info
      - OWS_ABACUS_ACCOUNT_URL=https://qa-ows-abacus-account.theorchard.io/
      - OWS_ABACUS_EVENT_URL=https://qa-ows-abacus-event.theorchard.io/
      - OWS_ABACUS_STATE_URL=https://qa-ows-abacus-state.theorchard.io/
      - OWS_ABACUS_WORKSHEET_URL=https://qa-ows-abacus-worksheet.theorchard.io/
      - OWS_LEDGER_URL=https://qa-ows-ledger.theorchard.io/
      - OWS_MONEYHUB_URL=https://qa-ows-moneyhub.theorchard.io/
      - OWS_PAYEE_URL=https://qa-ows-payee.theorchard.io/
      - OWS_PAYMENT_URL=https://qa-ows-payment.theorchard.io/
      - OWS_ROYALTIES_URL=https://qa-ows-royalties.theorchard.io/
      - PAYONEER_API_URL=https://api.sandbox.payoneer.com/v2/programs
      - S3_ADJUSTMENTS_BUCKET_NAME=qa-abacus-adjustments
      - S3_PAYMENTS_BUCKET_NAME=qa-abacus-payments
      - REDIS_URL=redis:6379
    container_name: graphql-abacus
    ports:
      - '8080:8080'
    volumes:
      - ./src:/var/app/src
  service-deploy:
    platform: linux/amd64
    build:
      context: .
      target: deploy
      args:
        DOCKER_BUILDKIT: 1
      secrets:
        - GITHUB_NPM_TOKEN
    environment:
      - GITHUB_NPM_TOKEN=/run/secrets/GITHUB_NPM_TOKEN
      - ENV=qa
      - PORT=8080
      - NODE_ENV=dev
      - APOLLO_INTROSPECTION=true
      - APOLLO_PLAYGROUND=true
      - AUTH_ISSUERS='https://qalogin.theorchard.com/, https://qa-orchard.auth0.com/'
      - BUCKET_UPLOAD_ROLE_ARN=arn:aws:iam::437795906767:role/qa-graphql-abacus-browser-upload-role
      - BUCKET_UPLOAD_TOKEN_DURATION=3600
      - DD_TRACE_ENABLED=false
      - ENABLE_JWT_SERVICE_CACHE=false
      - LOG_LEVEL=info
      - OWS_ABACUS_ACCOUNT_URL=https://qa-ows-abacus-account.theorchard.io/
      - OWS_ABACUS_EVENT_URL=https://qa-ows-abacus-event.theorchard.io/
      - OWS_ABACUS_STATE_URL=https://qa-ows-abacus-state.theorchard.io/
      - OWS_ABACUS_WORKSHEET_URL=https://qa-ows-abacus-worksheet.theorchard.io/
      - OWS_LEDGER_URL=https://qa-ows-ledger.theorchard.io/
      - OWS_MONEYHUB_URL=https://qa-ows-moneyhub.theorchard.io/
      - OWS_PAYEE_URL=https://qa-ows-payee.theorchard.io/
      - OWS_PAYMENT_URL=https://qa-ows-payment.theorchard.io/
      - OWS_ROYALTIES_URL=https://qa-ows-royalties.theorchard.io/
      - PAYONEER_API_URL=https://api.sandbox.payoneer.com/v2/programs
      - S3_ADJUSTMENTS_BUCKET_NAME=qa-abacus-adjustments
      - S3_PAYMENTS_BUCKET_NAME=qa-abacus-payments
    container_name: graphql-abacus-deploy
    ports:
      - '8081:8080'
  lint-and-test:
    build:
      context: .
      target: lint-and-test
      args:
        - DOCKER_BUILDKIT=1
      secrets:
        - GITHUB_NPM_TOKEN
    environment:
      - NODE_ENV=test
      - ENV=dev
      - GITHUB_NPM_TOKEN=/run/secrets/GITHUB_NPM_TOKEN
  integration-tests:
    build:
      context: .
      target: integration-tests
      args:
        - DOCKER_BUILDKIT=1
      secrets:
        - GITHUB_NPM_TOKEN
    environment:
      - NODE_ENV=test
      - ENV=dev
      - GITHUB_NPM_TOKEN=/run/secrets/GITHUB_NPM_TOKEN
secrets:
  GITHUB_NPM_TOKEN:
    environment: 'GITHUB_NPM_TOKEN'
