services:
{% if database.value == "PostgreSQL" %}
  postgres:
    image: postgres:17.7-alpine3.23
    container_name: {{ project_slug }}_postgres_db
    environment:
      POSTGRES_DB: mydb
      POSTGRES_USER: myuser
      POSTGRES_PASSWORD: mypassword
    volumes:
      - {{ project_slug }}_postgres_db:/var/lib/postgresql/data
    ports:
      - "5432:5432"
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U myuser -d mydb"]
      interval: 10s
      timeout: 5s
      retries: 5
    restart: unless-stopped

volumes:
  {{ project_slug }}_postgres_db: {}
{% elif database.value == "MySQL" %}
  mysql:
    image: mysql:8.4.8-oraclelinux9
    container_name: {{ project_slug }}_mysql_db
    environment:
      MYSQL_DATABASE: mydb
      MYSQL_USER: myuser
      MYSQL_PASSWORD: mypassword
      MYSQL_ROOT_PASSWORD: rootpassword
    volumes:
      - {{ project_slug }}_mysql_db:/var/lib/mysql
    ports:
      - "3306:3306"
    healthcheck:
      test: ["CMD", "mysqladmin", "ping", "-h", "localhost"]
      interval: 10s
      timeout: 5s
      retries: 5
    restart: unless-stopped

volumes:
  {{ project_slug }}_mysql_db: {}
{% endif %}
