{% set runtime = runtime | default('python') %}
{% set include_postgres = include_postgres | default(true) %}
{% set package_manager_command = package_manager_command | default(package_manager | default('npm')) %}
version: "3.9"

services:
  app:
    build:
      context: .
      dockerfile: Dockerfile
    image: {{ project_name | default('rapidkit-app') }}:latest
    env_file:
      - .env
    ports: ["{{ '8000:8000' if runtime == 'python' else '3000:3000' }}"]
    command: "{{ 'poetry run uvicorn src.main:app --host 0.0.0.0 --port 8000' if runtime == 'python' else package_manager_command ~ ' run start:dev' }}"
    volumes:
      - .:/app
    restart: unless-stopped
{% if include_postgres %}
  postgres:
    image: postgres:15
    restart: unless-stopped
    environment:
      POSTGRES_DB: {{ project_name | default('rapidkit') }}
      POSTGRES_USER: postgres
      POSTGRES_PASSWORD: postgres
    ports:
      - "5432:5432"
    volumes:
      - postgres-data:/var/lib/postgresql/data
{% endif %}

volumes:
{% if include_postgres %}  postgres-data:
    driver: local
{% else %}  rapidkit-data:
    driver: local
{% endif %}
