# Generated by Shiplet — PHP/symfony project
# Runtime: podman
# PHP: 8.2  Web: nginx
#
# Commands:
#   shiplet up -d                   Start everything
#   shiplet composer install        Install PHP deps
#   shiplet php artisan migrate     Run Artisan commands (Laravel)
#   shiplet php bin/console         Run Symfony console
#   shiplet shell                   Shell into app container
#   shiplet db                      Open database CLI

name: shiplet-symfony

services:
  # ── PHP Application (FPM) ──────────────────────────────────────────────────
  app:
    build:
      context: .
      dockerfile: .shiplet/Dockerfile
      args:
        PHP_VERSION: "8.2"
        TZ: "UTC"
    image: shiplet-symfony/app
    extra_hosts:
      - "host.docker.internal:host-gateway"
    volumes:
      - ".:/var/www/html"
      - "composer_cache:/root/.composer/cache"
    networks:
      - shiplet
    environment:
      APP_ENV:    "${APP_ENV:-dev}"
      APP_SECRET: "${APP_SECRET}"
      DATABASE_URL: "${DATABASE_URL}"
    depends_on:
      - postgres
      - redis
      - mailpit
    restart: unless-stopped

  # ── Web Server ─────────────────────────────────────────────────────────────
  nginx:
    image: "nginx:alpine"
    ports:
      - "${APP_PORT:-80}:80"
    volumes:
      - ".:/var/www/html:ro"
      - "./.shiplet/nginx/default.conf:/etc/nginx/conf.d/default.conf:ro"
    networks:
      - shiplet
    depends_on:
      - app
    restart: unless-stopped

  postgres:
      image: "postgres:16-alpine"
      environment:
        POSTGRES_USER:     "${POSTGRES_USER:-shiplet}"
        POSTGRES_PASSWORD: "${POSTGRES_PASSWORD:-secret}"
        POSTGRES_DB:       "${POSTGRES_DB:-app}"
      ports:
        - "${POSTGRES_PORT:-5432}:5432"
      volumes:
        - "postgres_data:/var/lib/postgresql/data"
      networks:
        - shiplet
      healthcheck:
        test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-shiplet}"]
        interval: 5s
        retries: 10

  redis:
      image: "redis:7-alpine"
      ports:
        - "${REDIS_PORT:-6379}:6379"
      networks:
        - shiplet
      healthcheck:
        test: ["CMD", "redis-cli", "ping"]
        interval: 5s
        retries: 10

  mailpit:
      image: "axllent/mailpit"
      ports:
        - "${MAILPIT_SMTP_PORT:-1025}:1025"
        - "${MAILPIT_UI_PORT:-8025}:8025"
      networks:
        - shiplet

volumes:
  postgres_data:
    driver: local
  redis_data:
    driver: local
  composer_cache:
    driver: local

networks:
  shiplet:
    driver: bridge
