"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.generateDockerComposeYaml = generateDockerComposeYaml;
function generateDockerComposeYaml({ database, keycloak }) {
    return /*yml*/ `
services:
  ${database ? dbService(database) : ''}

  ${keycloak ? keycloakService(keycloak) : ''}

networks:
  backend: {}

${database ? volumes : ''}
`;
}
const dbService = ({ username, password, database }) => `
  db:
    image: postgres:13
    restart: always
    ports:
      - '5432:5432'
    expose:
      - '5432'
    environment:
      POSTGRES_USER: ${username}
      POSTGRES_PASSWORD: ${password}
      POSTGRES_DB: ${database}
    command: ['postgres']
    volumes:
      - postgres:/var/lib/postgresql/data
    networks:
      - backend
    healthcheck:
      test: ['CMD-SHELL', 'pg_isready -U ${username} -d ${database}']
      interval: 10s
      timeout: 5s
      retries: 5
`;
const keycloakService = ({ host, pathPrefix, clientId, clientSecret, realm }) => `
  keycloak:
    build:
      context: ./
      dockerfile: ./docker/keycloak/Dockerfile
    ports:
      - '8080:8080'
      - '8443:8443'
      - '9000:9000'
    expose:
      - '8080'
      - '8443'
      - '9000'
    environment:
      KEYCLOAK_URL: ${host}${pathPrefix}
      KEYCLOAK_ADMIN_URL: ${host}${pathPrefix}
      KEYCLOAK_ADMIN: admin
      KEYCLOAK_ADMIN_PASSWORD: admin
      KEYCLOAK_REALM: ${realm}
      KEYCLOAK_CLIENT_ID: ${clientId}
      KEYCLOAK_REDIRECT_URL: http://localhost:3001/auth/callback
      KEYCLOAK_CLIENT_SECRET: ${clientSecret}
      DEV_USERNAME: developer
      DEV_PASSWORD: root
      # KC_LOG_LEVEL: DEBUG
    healthcheck:
      test: ['CMD-SHELL', 'curl -f http://localhost:9000/auth/health || exit 1']
      interval: 10s
      timeout: 5s
      retries: 10
      start_period: 45s
    networks:
      - backend
`;
const volumes = `
volumes:
  postgres:
`;
//# sourceMappingURL=docker-compose-yml.generator.js.map