services:
  coolify:
    image: coolify:dev
    pull_policy: never
    build:
      context: .
      dockerfile: ./docker/development/Dockerfile
      args:
        - USER_ID=${USERID:-1000}
        - GROUP_ID=${GROUPID:-1000}
        - COOLIFY_FLUX_VERSION=${COOLIFY_FLUX_VERSION:-nightly}
        - COOLIFY_FLUX_CHECKSUM=${COOLIFY_FLUX_CHECKSUM:-unknown}
        - COOLIFY_CLI_VERSION=${COOLIFY_CLI_VERSION:-nightly}
        - COOLIFY_CLI_CHECKSUM=${COOLIFY_CLI_CHECKSUM:-unknown}
    ports:
      - "${DEV_BIND_ADDRESS:-0.0.0.0}:${APP_PORT:-8000}:8080"
      - "${FORWARD_FLUX_PORT:-6443}:6443"
    extra_hosts:
      - "host.docker.internal:host-gateway"
    environment:
      AUTORUN_ENABLED: false
      COOLIFY_CONTAINER_ROLE: "${COOLIFY_CONTAINER_ROLE:-all}"
      COOLIFY_COOLD_VERSION: "${COOLIFY_COOLD_VERSION:-nightly}"
      COOLIFY_FLUX_VERSION: "${COOLIFY_FLUX_VERSION:-nightly}"
      COOLIFY_FLUX_REQUIRE_HOST_BINDING: "${COOLIFY_FLUX_REQUIRE_HOST_BINDING:-0}"
      COOLIFY_CLI_VERSION: "${COOLIFY_CLI_VERSION:-nightly}"
      COOLIFY_CLI_SSH_USER: "${COOLIFY_CLI_SSH_USER:-}"
      COOLIFY_CORROSION_VERSION: "${COOLIFY_CORROSION_VERSION:-v1.0.0}"
      PUSHER_HOST: "${PUSHER_HOST:-}"
      PUSHER_PORT: "${PUSHER_PORT:-}"
      PUSHER_SCHEME: "${PUSHER_SCHEME:-http}"
      PUSHER_APP_ID: "${PUSHER_APP_ID:-coolify}"
      PUSHER_APP_KEY: "${PUSHER_APP_KEY:-coolify}"
      PUSHER_APP_SECRET: "${PUSHER_APP_SECRET:-coolify}"
    healthcheck:
      test: curl -sf http://127.0.0.1:8080/api/health || exit 1
      interval: 5s
      retries: 10
      timeout: 2s
    volumes:
      - .:/var/www/html/:cached
      - dev_backups_data:/var/www/html/storage/app/backups
    networks:
      - coolify
  postgres:
    pull_policy: always
    ports:
      - "${FORWARD_DB_PORT:-5432}:5432"
    env_file:
      - .env
    environment:
      POSTGRES_USER: "${DB_USERNAME:-coolify}"
      POSTGRES_PASSWORD: "${DB_PASSWORD:-password}"
      POSTGRES_DB: "${DB_DATABASE:-coolify}"
      POSTGRES_HOST_AUTH_METHOD: "trust"
    healthcheck:
      test: [ "CMD-SHELL", "pg_isready -U $$POSTGRES_USER -d $$POSTGRES_DB" ]
      interval: 5s
      retries: 10
      timeout: 2s
    volumes:
      - dev_postgres_data:/var/lib/postgresql/data
  redis:
    pull_policy: always
    ports:
      - "${FORWARD_REDIS_PORT:-6379}:6379"
    env_file:
      - .env
    healthcheck:
      test: redis-cli ping
      interval: 5s
      retries: 10
      timeout: 2s
    volumes:
      - dev_redis_data:/data
  soketi:
    image: coolify-realtime:dev
    pull_policy: never
    build:
      context: .
      dockerfile: ./docker/coolify-realtime/Dockerfile
    env_file:
      - .env
    ports:
      - "${DEV_BIND_ADDRESS:-0.0.0.0}:${FORWARD_SOKETI_PORT:-6001}:6001"
      - "${DEV_BIND_ADDRESS:-0.0.0.0}:6002:6002"
    extra_hosts:
      - "host.docker.internal:host-gateway"
    volumes:
      - ./storage:/var/www/html/storage
      - ./docker/coolify-realtime/terminal-server.js:/terminal/terminal-server.js
      - ./docker/coolify-realtime/terminal-utils.js:/terminal/terminal-utils.js
    environment:
      SOKETI_DEBUG: "false"
      SOKETI_DEFAULT_APP_ID: "${PUSHER_APP_ID:-coolify}"
      SOKETI_DEFAULT_APP_KEY: "${PUSHER_APP_KEY:-coolify}"
      SOKETI_DEFAULT_APP_SECRET: "${PUSHER_APP_SECRET:-coolify}"
      SOKETI_HOST: "${SOKETI_HOST:-0.0.0.0}"
    healthcheck:
      test: [ "CMD-SHELL", "curl -fsS http://127.0.0.1:6001/ready && curl -fsS http://127.0.0.1:6002/ready || exit 1" ]
      interval: 5s
      retries: 10
      timeout: 2s
    entrypoint: ["/bin/sh", "/soketi-entrypoint.sh"]
  vite:
    image: node:24-alpine
    pull_policy: always
    container_name: coolify-vite
    working_dir: /var/www/html
    environment:
      # Set VITE_HOST in .env to a browser-reachable IP/hostname for LAN/Tailscale access
      VITE_HOST: "${VITE_HOST:-localhost}"
      VITE_PORT: "${VITE_PORT:-5173}"
      VITE_PROTOCOL: "${VITE_PROTOCOL:-http}"
    ports:
      - "${DEV_BIND_ADDRESS:-0.0.0.0}:${VITE_PORT:-5173}:${VITE_PORT:-5173}"
    volumes:
      - .:/var/www/html/:cached
    command: sh -c "npm install && npm run dev"
    networks:
      - coolify
  testing-host:
    image: coolify-testing-host:dev
    pull_policy: never
    build:
      context: .
      dockerfile: ./docker/testing-host/Dockerfile
    init: true
    container_name: coolify-testing-host
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - dev_coolify_data:/data/coolify
      - dev_coolify_data:/var/lib/docker/volumes/coolify_dev_coolify_data/_data
      - dev_backups_data:/data/coolify/backups
      - dev_postgres_data:/data/coolify/_volumes/database
      - dev_redis_data:/data/coolify/_volumes/redis
      - dev_minio_data:/data/coolify/_volumes/minio
    networks:
      - coolify
  mailpit:
    image: axllent/mailpit:latest
    pull_policy: always
    container_name: coolify-mail
    ports:
      - "${FORWARD_MAILPIT_PORT:-1025}:1025"
      - "${FORWARD_MAILPIT_DASHBOARD_PORT:-8025}:8025"
    networks:
      - coolify
  minio:
    image: coollabsio/maxio:latest
    pull_policy: always
    container_name: coolify-minio
    ports:
      - "${FORWARD_MINIO_PORT:-9000}:9000"
      - "${FORWARD_MINIO_PORT_CONSOLE:-9001}:9001"
    environment:
      MINIO_ACCESS_KEY: "${MINIO_ACCESS_KEY:-minioadmin}"
      MINIO_SECRET_KEY: "${MINIO_SECRET_KEY:-minioadmin}"
    volumes:
      - dev_minio_data:/data
    networks:
      - coolify
  minio-init:
    image: minio/mc:latest
    pull_policy: always
    container_name: coolify-minio-init
    restart: no
    depends_on:
      - minio
    entrypoint: >
      /bin/sh -c "
      echo 'Waiting for MinIO to be ready...';
      until mc alias set local http://coolify-minio:9000 minioadmin minioadmin 2>/dev/null; do
        echo 'MinIO not ready yet, waiting...';
        sleep 2;
      done;
      echo 'MinIO is ready, creating bucket if needed...';
      mc mb local/local --ignore-existing;
      echo 'MinIO initialization complete - bucket local is ready';
      "
    networks:
      - coolify

volumes:
  dev_backups_data:
  dev_postgres_data:
  dev_redis_data:
  dev_coolify_data:
  dev_minio_data:

networks:
  coolify:
    name: coolify
    external: false
