version: "3.7"

services:
  minio:
    image: minio/minio
    command: server --console-address ":9001" /data
    ports:
      - "127.0.0.127:9000:9000"
      - "127.0.0.127:9001:9001"
    expose:
      - 9000
      - 9001
    environment:
     MINIO_ROOT_USER: &s3_key minio
     MINIO_ROOT_PASSWORD: &s3_secret changeme
    healthcheck:
      test: [ "CMD", "curl", "-f", "http://localhost:9000/minio/health/live" ]
      interval: 30s
      timeout: 20s
      retries: 3
    volumes:
      - ./.minio/data:/data

  postgres-14:
    image: benzine/postgres:14
    build:
      context: .
      target: postgres
      args:
        PGSQL_VERSION: 14
    environment:
      POSTGRES_USER: example
      POSTGRES_PASSWORD: changeme
      S3_ENDPOINT: http://minio:9000/
      S3_API_KEY: *s3_key
      S3_API_SECRET: *s3_secret
      S3_USE_PATH_STYLE_ENDPOINT: "yes"
      S3_BUCKET: "s3db"
      S3_PREFIX: "test/postgres/"
    ports:
      - "127.0.0.127:5432:5432"
    depends_on:
      - minio
    volumes:
      - ./:/sync