services:
  app:
    image: songwhip-api

    build:
      context: ../../
      secrets:
        - GITHUB_NPM_TOKEN
        - POEDITOR_API_TOKEN

    ports:
      - '${PORT}:${PORT}'

    depends_on:
      database:
        condition: service_healthy

    env_file: ../../.env

  database:
    image: 'postgres:13.20-alpine'

    environment:
      - POSTGRES_DB=songwhip_api
      - POSTGRES_PASSWORD=postgres

    healthcheck:
      test: ['CMD-SHELL', 'pg_isready -U postgres']
      interval: 5s
      timeout: 5s
      retries: 5

secrets:
  GITHUB_NPM_TOKEN:
    environment: GITHUB_NPM_TOKEN
  POEDITOR_API_TOKEN:
    environment: POEDITOR_API_TOKEN
