version: "3.8"

services:
  deploy:
    image: flyway/flyway:10
    environment:
      - FLYWAY_URL=jdbc:postgresql://db:5432/permissions
      - FLYWAY_SCHEMAS=public
    command: migrate
    depends_on:
      - db

  db:
    image: postgres:15
    environment:
      POSTGRES_DB: permissions

  ows-permissions-service:
    build:
      context: .
      dockerfile: Dockerfile
      target: deploy
      secrets:
        - github_npm_token
    image: ows-permissions-ows-permissions-service:latest
    ports:
      - "8080:8080"

  test:
    build:
      context: .
      dockerfile: Dockerfile
      target: test
    command: pytest

secrets:
  github_npm_token:
    environment: GITHUB_NPM_TOKEN
