version: "3.9"
services:
#  app:
#    image: registry.master3.takima.io/gdemonteynard/takima-store/app:${TAG:-latest}
#    env_file:
#      - .env
#    networks:
#      - db
#    depends_on:
#      db:
#        condition: service_healthy
#    restart: on-failure
#    ports:
#      - "8080:8080"
  db:
    image: postgres:15.2-alpine
    restart: unless-stopped
    networks:
      - db
    environment:
      - POSTGRES_PASSWORD=${DATABASE_PASSWORD:-ilovethierion}
      - POSTGRES_USER=${DATABASE_USERNAME:-ilovethierion}
      - POSTGRES_DB=${DATABASE_NAME:-entrainement_db}
    volumes:
      - db-data:/var/lib/postgresql/data
    healthcheck:
      test:
        [
          "CMD-SHELL",
          "sh -c 'pg_isready -U ${DATABASE_USERNAME} -d ${DATABASE_NAME}'",
        ]
      interval: 10s
      timeout: 3s
      retries: 3
    ports:
      - "5432:5432"

  flyway:
    image: flyway/flyway:9-alpine
    command: -connectRetries=60 -baselineVersion="0.0" baseline migrate info
    volumes:
      - ./flyway/sql:/flyway/sql:ro
    environment:
      - FLYWAY_URL=${JDBC_URL}
      - FLYWAY_USER=${DATABASE_USERNAME}
      - FLYWAY_PASSWORD=${DATABASE_PASSWORD}
    depends_on:
      - db
    networks:
      - db
networks:
  db:

volumes:
  db-data:
