services:
  ###> doctrine/doctrine-bundle ###
  database:
    image: postgres:${POSTGRES_VERSION:-16}-alpine
    environment:
      POSTGRES_DB: ${POSTGRES_DB:-cms}
      # You should definitely change the password in production
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-mypassword}
      POSTGRES_USER: ${POSTGRES_USER:-cms}
    ports:
      - "5434:5432"
    healthcheck:
      test:
        [
          "CMD",
          "pg_isready",
          "-d",
          "${POSTGRES_DB:-cms}",
          "-U",
          "${POSTGRES_USER:-cms}",
        ]
      timeout: 5s
      retries: 5
      start_period: 60s
    volumes:
      - database_data:/var/lib/postgresql/data:rw
      # You may use a bind-mounted host directory instead, so that it is harder to accidentally remove the volume and lose all your data!
      # - ./docker/db/data:/var/lib/postgresql/data:rw
  ###< doctrine/doctrine-bundle ###

  keycloak-database:
    image: postgres:16.2
    volumes:
      - postgres_data:/var/lib/postgresql/data
    environment:
      POSTGRES_DB: keycloak
      POSTGRES_USER: postgres
      POSTGRES_PASSWORD: postgres
    networks:
      - keycloak_network

  keycloak:
    image: quay.io/keycloak/keycloak:latest
    command: start
    environment:
      KC_HOSTNAME: ${KEYCLOAK_HOSTNAME:-127.0.0.1}
      KC_HOSTNAME_PORT: 8080
      KC_HOSTNAME_STRICT_BACKCHANNEL: false
      KC_HTTP_ENABLED: true
      KC_HOSTNAME_STRICT_HTTPS: false
      KC_HEALTH_ENABLED: true
      KEYCLOAK_ADMIN: admin
      KEYCLOAK_ADMIN_PASSWORD: password
      KC_DB: postgres
      KC_DB_URL: jdbc:postgresql://keycloak-database/keycloak
      KC_DB_USERNAME: postgres
      KC_DB_PASSWORD: postgres
    ports:
      - 8080:8080
    restart: always
    depends_on:
      - keycloak-database
    networks:
      - keycloak_network

  minio:
    image: quay.io/minio/minio:latest
    ports:
      - "9000:9000"
      - "9001:9001"
    command: ["server", "--console-address", ":9001", "/data"]
    volumes:
      - data-minio:/data
    environment:
      MINIO_ROOT_USER: admin
      MINIO_ROOT_PASSWORD: password

  minio-buckets:
    image: quay.io/minio/mc:latest
    depends_on:
      - minio
    restart: on-failure
    entrypoint: >
      /bin/sh -c "
      /usr/bin/mc alias set dockerminio http://minio:9000 admin password;
      /usr/bin/mc mb dockerminio/cms;
      exit 0;
      "

volumes:
  ###> doctrine/doctrine-bundle ###
  database_data:
  postgres_data:
  data-minio:

###< doctrine/doctrine-bundle ###

networks:
  keycloak_network:
    driver: bridge
