haloy-config
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseHaloy Configuration
Haloy 配置
Create configuration files for deploying applications with haloy.
haloy.yamlIf no Dockerfile exists and the user needs one, inform them:
"No Dockerfile found in this project. Haloy deploys Docker containers, so you'll need a Dockerfile first. Would you like me to create one using theskill?"dockerize
为使用haloy部署应用创建配置文件。
haloy.yaml如果项目中不存在Dockerfile且用户需要,告知用户:
"当前项目中未找到Dockerfile。Haloy部署的是Docker容器,因此你需要先创建一个Dockerfile。是否需要我使用技能为你创建?"dockerize
How It Works
工作流程
- Check for Dockerfile - Verify the project can be containerized
- Check for configured haloy servers - Look for existing server configurations
- Detect the project type by examining:
- with framework dependencies (Next.js, TanStack Start, Express, etc.)
package.json - ,
pyproject.toml,requirements.txt(Python/Django/FastAPI)Pipfile - (Go)
go.mod - (Rust)
Cargo.toml - (Ruby/Rails)
Gemfile - (PHP/Laravel)
composer.json
- Detect database dependencies (Prisma, Drizzle, pg, SQLAlchemy, etc.)
- Infer defaults for app name, port, and health check path
- Ask the user for server (from configured list or manual entry) and domain
- If database detected, ask if they want self-hosted or external
- Generate haloy.yaml with appropriate configuration
- Provide next steps for validation and deployment
- 检查Dockerfile - 验证项目是否可容器化
- 检查已配置的haloy服务器 - 查找现有的服务器配置
- 检测项目类型,通过检查以下文件:
- 包含框架依赖的(Next.js、TanStack Start、Express等)
package.json - 、
pyproject.toml、requirements.txt(Python/Django/FastAPI)Pipfile - (Go语言)
go.mod - (Rust语言)
Cargo.toml - (Ruby/Rails)
Gemfile - (PHP/Laravel)
composer.json
- 包含框架依赖的
- 检测数据库依赖(Prisma、Drizzle、pg、SQLAlchemy等)
- 推断默认值,包括应用名称、端口和健康检查路径
- 询问用户服务器信息(从已配置列表选择或手动输入)和域名
- 如果检测到数据库,询问用户是使用自托管数据库还是外部数据库
- 生成haloy.yaml,配置相应的参数
- 提供后续步骤,包括验证和部署
Project Detection
项目检测
Detect the framework to determine the default port:
| Framework | Indicator | Default Port |
|---|---|---|
| Next.js | | 3000 |
| TanStack Start | | 3000 |
| Express/Node.js | | 3000 |
| Vite | | 5173 (dev) / 3000 (prod) |
| Django | | 8000 |
| FastAPI | | 8000 |
| Flask | | 5000 |
| Go | | 8080 |
| Rust | | 8080 |
| Ruby/Rails | | 3000 |
| PHP/Laravel | | 8000 |
| Default | Unknown framework | 8080 |
Also check the Dockerfile for directives which override framework defaults.
EXPOSE通过检测框架来确定默认端口:
| 框架 | 识别标识 | 默认端口 |
|---|---|---|
| Next.js | | 3000 |
| TanStack Start | | 3000 |
| Express/Node.js | | 3000 |
| Vite | | 5173(开发环境)/ 3000(生产环境) |
| Django | | 8000 |
| FastAPI | | 8000 |
| Flask | | 5000 |
| Go | 存在 | 8080 |
| Rust | 存在 | 8080 |
| Ruby/Rails | | 3000 |
| PHP/Laravel | | 8000 |
| 默认 | 未知框架 | 8080 |
同时检查Dockerfile中的指令,该指令会覆盖框架默认端口。
EXPOSEDatabase Detection
数据库检测
Scan for database dependencies to determine if the project uses a database:
| Indicator | Database Type |
|---|---|
| Check schema for provider |
| Check config for driver |
| PostgreSQL |
| MySQL |
| SQLite (no service needed) |
| Check config for dialect |
| PostgreSQL |
| Check config for driver |
| Check settings for database |
| Check |
Prisma schema example - look for the provider:
prisma
datasource db {
provider = "postgresql" // or "mysql", "sqlite"
url = env("DATABASE_URL")
}扫描数据库依赖以确定项目是否使用数据库:
| 识别标识 | 数据库类型 |
|---|---|
| 检查schema中的provider |
| 检查配置中的driver |
| PostgreSQL |
| MySQL |
| SQLite(无需服务) |
| 检查配置中的dialect |
| PostgreSQL |
| 检查配置中的driver |
| 检查settings中的数据库配置 |
存在 | 检查datasource块中的 |
Prisma schema示例 - 查找provider:
prisma
datasource db {
provider = "postgresql" // 或 "mysql", "sqlite"
url = env("DATABASE_URL")
}Decision Flow
决策流程
Use defaults unless a critical value is missing. Only ask the user when necessary.
除非缺少关键值,否则使用默认值。仅在必要时询问用户。
App Name
应用名称
- First choice: field in
namepackage.json - Second choice: Project folder name
- Ask if: Name contains invalid characters or is generic (e.g., "app", "project")
- 首选:中的
package.json字段name - 次选:项目文件夹名称
- 询问情况:名称包含无效字符或过于通用(例如"app"、"project")
Server URL
服务器URL
Check for configured servers in :
~/.config/haloy/client.yamlyaml
undefined检查中的已配置服务器:
~/.config/haloy/client.yamlyaml
undefinedExample client.yaml structure
示例client.yaml结构
servers:
example.haloy.dev:
token_env: HALOY_API_TOKEN_example_HALOY_DEV
prod.mycompany.com:
token_env: HALOY_API_TOKEN_PROD
**Decision flow:**
1. **If servers found**: Present them as options and let the user choose. The server keys (e.g., `example.haloy.dev`) are the values to use in the config.
> "I found these configured haloy servers. Which one would you like to deploy to?"
> - example.haloy.dev
> - prod.mycompany.com
> - Enter a different server
2. **If no servers found**: Check if haloy CLI is installed by running `which haloy` or `haloy --version`
- **If haloy is installed**: Ask for the server URL manually
> "What is your haloy server URL? (e.g., haloy.yourserver.com)"
- **If haloy is not installed**: Inform the user they need to install and configure the CLI first
> "No haloy servers configured. To deploy with haloy, you'll need to install the CLI and add a server. See: https://haloy.dev/docs/client-installation"servers:
example.haloy.dev:
token_env: HALOY_API_TOKEN_example_HALOY_DEV
prod.mycompany.com:
token_env: HALOY_API_TOKEN_PROD
**决策流程**:
1. **如果找到服务器**:将其作为选项展示,让用户选择。服务器键(例如`example.haloy.dev`)是配置中要使用的值。
> "我找到了这些已配置的haloy服务器。你想部署到哪一个?"
> - example.haloy.dev
> - prod.mycompany.com
> - 输入其他服务器
2. **如果未找到服务器**:通过运行`which haloy`或`haloy --version`检查是否安装了haloy CLI
- **如果已安装haloy**:手动询问服务器URL
> "你的haloy服务器URL是什么?(例如haloy.yourserver.com)"
- **如果未安装haloy**:告知用户需要先安装并配置CLI
> "未配置haloy服务器。要使用haloy部署,你需要安装CLI并添加服务器。查看:https://haloy.dev/docs/client-installation"Domain
域名
- Always ask - Required for web applications
- Example prompt: "What domain should this app be accessible at? (e.g., myapp.example.com)"
- If user says "none" or "skip", omit the domains section
- 必须询问 - Web应用必填
- 示例提示:"这个应用应该通过哪个域名访问?(例如myapp.example.com)"
- 如果用户说"none"或"skip",则省略domains部分
Domain Aliases
域名别名
- Ask after domain: Once the user provides a domain, ask if they want to add any aliases
- Example prompt: "Would you like to add any domain aliases? (e.g., www.myapp.example.com)"
- Common alias: prefix of the main domain
www. - If user says "none" or "skip", omit the aliases
- 询问域名后:用户提供域名后,询问是否要添加别名
- 示例提示:"你想添加域名别名吗?(例如www.myapp.example.com)"
- 常见别名:主域名的前缀
www. - 如果用户说"none"或"skip",则省略aliases部分
DNS Reminder
DNS提醒
After gathering domain information, remind the user to configure DNS:
"Remember to configure DNS with your domain provider. Point your domain(s) to your haloy server's IP address using an A record, or use a CNAME record if your server has a domain name."
收集域名信息后,提醒用户配置DNS:
"请记得在域名提供商处配置DNS。使用A记录将域名指向你的haloy服务器IP地址,或者如果服务器有域名,使用CNAME记录。"
Port
端口
- Use framework default from the table above
- Check Dockerfile for directive which takes precedence
EXPOSE - Ask only if: Multiple ports exposed or no clear default
- 使用框架默认值:来自上方的表格
- 检查Dockerfile:指令优先级更高
EXPOSE - 询问情况:存在多个暴露端口或无明确默认值
Health Check Path
健康检查路径
- Search for existing endpoints: ,
/health,/healthz,/api/health/_health - If found: Use the existing health endpoint
- If not found: Use (root path)
/ - Do NOT ask - haloy will use by default which works for most apps
/
- 搜索现有端点:、
/health、/healthz、/api/health/_health - 如果找到:使用现有健康端点
- 如果未找到:使用(根路径)
/ - 无需询问 - haloy默认使用,适用于大多数应用
/
Database
数据库
If database dependencies are detected (see Database Detection section):
-
Ask the user:"I detected database dependencies ([detected type]). Would you like to add a self-hosted database service, or will you use an external provider (Supabase, Neon, RDS, etc.)?"
- Add self-hosted database
- Use external provider (I'll configure DATABASE_URL myself)
-
If self-hosted:
- Generate multi-target config with database service + app target
- Use the preset for the database target
database - Add appropriate environment variables with placeholder values
- Add volume for data persistence
- Database defaults by type:
Database Image Port Volume Path PostgreSQL postgres:175432 /var/lib/postgresql/dataMySQL mysql:83306 /var/lib/mysql -
If external provider:
- Generate single-target config as usual
- Remind user: "Remember to set the environment variable for your external database."
DATABASE_URL
如果检测到数据库依赖(请参阅数据库检测部分):
-
询问用户:"我检测到数据库依赖([检测到的类型])。你想添加自托管数据库服务,还是使用外部提供商(Supabase、Neon、RDS等)?"
- 添加自托管数据库
- 使用外部提供商(我会自行配置DATABASE_URL)
-
如果选择自托管:
- 生成包含数据库服务和应用目标的多目标配置
- 为数据库目标使用预设
database - 添加带有占位符值的相应环境变量
- 添加用于数据持久化的卷
- 按类型设置数据库默认值:
数据库 镜像 端口 卷路径 PostgreSQL postgres:175432 /var/lib/postgresql/dataMySQL mysql:83306 /var/lib/mysql -
如果选择外部提供商:
- 按常规生成单目标配置
- 提醒用户:"请记得为外部数据库设置环境变量。"
DATABASE_URL
Configuration Reference
配置参考
Haloy supports two modes:
- Single Deployment: No defined, root configuration is the deployment target
targets - Multi-Target: defined, root acts as base/default configuration
targets
Haloy支持两种模式:
- 单部署:未定义,根配置即为部署目标
targets - 多目标:定义,根配置作为基础/默认配置
targets
Minimal Configuration (Single Deployment)
最小配置(单部署)
yaml
name: "my-app"
server: "haloy.yourserver.com"yaml
name: "my-app"
server: "haloy.yourserver.com"With Domain and Port
包含域名和端口的配置
yaml
name: "my-app"
server: "haloy.yourserver.com"
domains:
- domain: "my-app.example.com"
aliases:
- "www.my-app.example.com"
port: "3000"
health_check_path: "/health"yaml
name: "my-app"
server: "haloy.yourserver.com"
domains:
- domain: "my-app.example.com"
aliases:
- "www.my-app.example.com"
port: "3000"
health_check_path: "/health"With Environment Variables
包含环境变量的配置
yaml
name: "my-app"
server: "haloy.yourserver.com"
domains:
- domain: "my-app.example.com"
port: "3000"
env:
- name: "NODE_ENV"
value: "production"
- name: "DATABASE_URL"
value: "postgres://user:pass@db:5432/myapp"yaml
name: "my-app"
server: "haloy.yourserver.com"
domains:
- domain: "my-app.example.com"
port: "3000"
env:
- name: "NODE_ENV"
value: "production"
- name: "DATABASE_URL"
value: "postgres://user:pass@db:5432/myapp"With Volumes (for persistent data)
包含卷的配置(用于持久化数据)
yaml
name: "my-app"
server: "haloy.yourserver.com"
domains:
- domain: "my-app.example.com"
volumes:
- "app-data:/app/data"yaml
name: "my-app"
server: "haloy.yourserver.com"
domains:
- domain: "my-app.example.com"
volumes:
- "app-data:/app/data"With Self-Hosted Database (Multi-Target)
包含自托管数据库的配置(多目标)
yaml
server: "haloy.yourserver.com"
env:
- name: POSTGRES_USER
value: "postgres"
- name: POSTGRES_PASSWORD
value: "change-me-in-production"
- name: POSTGRES_DB
value: "my_app"
targets:
postgres:
preset: database
image:
repository: postgres:17
port: 5432
volumes:
- postgres-data:/var/lib/postgresql/data
my-app:
domains:
- domain: "my-app.example.com"
port: 3000
env:
- name: DATABASE_URL
value: "postgres://postgres:change-me-in-production@postgres:5432/my_app"
- name: NODE_ENV
value: "production"yaml
server: "haloy.yourserver.com"
env:
- name: POSTGRES_USER
value: "postgres"
- name: POSTGRES_PASSWORD
value: "change-me-in-production"
- name: POSTGRES_DB
value: "my_app"
targets:
postgres:
preset: database
image:
repository: postgres:17
port: 5432
volumes:
- postgres-data:/var/lib/postgresql/data
my-app:
domains:
- domain: "my-app.example.com"
port: 3000
env:
- name: DATABASE_URL
value: "postgres://postgres:change-me-in-production@postgres:5432/my_app"
- name: NODE_ENV
value: "production"Multi-Target Example
多目标示例
yaml
undefinedyaml
undefinedBase settings inherited by all targets
所有目标继承的基础设置
image:
repository: "my-app"
tag: "latest"
port: "3000"
targets:
production:
server: "prod.haloy.com"
domains:
- domain: "my-app.com"
replicas: 2
staging:
server: "staging.haloy.com"
domains:
- domain: "staging.my-app.com"
replicas: 1
undefinedimage:
repository: "my-app"
tag: "latest"
port: "3000"
targets:
production:
server: "prod.haloy.com"
domains:
- domain: "my-app.com"
replicas: 2
staging:
server: "staging.haloy.com"
domains:
- domain: "staging.my-app.com"
replicas: 1
undefinedFull Reference
完整参考
For all configuration options, see: https://haloy.dev/docs/configuration-reference
Key options:
- - Application name (required for single deployment)
name - - Haloy server URL (required)
server - - Docker image configuration (repository, tag)
image - - Array of domain objects with
domainsand optionaldomainaliases - - Container port (default: "8080")
port - - Health check endpoint (default: "/")
health_check_path - - Environment variables as name/value pairs
env - - Volume mounts for persistent data
volumes - - Number of container instances (default: 1)
replicas - - "rolling" (default) or "replace"
deployment_strategy - - Define multiple deployment targets (multi-target mode)
targets - - Apply preset configuration ("database" or "service")
preset
关键选项:
- - 应用名称(单部署必填)
name - - Haloy服务器URL(必填)
server - - Docker镜像配置(repository、tag)
image - - 包含
domains和可选domain的域名对象数组aliases - - 容器端口(默认:"8080")
port - - 健康检查端点(默认:"/")
health_check_path - - 键值对形式的环境变量
env - - 用于持久化数据的卷挂载
volumes - - 容器实例数量(默认:1)
replicas - - "rolling"(默认)或"replace"
deployment_strategy - - 定义多个部署目标(多目标模式)
targets - - 应用预设配置("database"或"service")
preset
Output Format
输出格式
After gathering information, create the file and provide:
haloy.yaml- The haloy.yaml file - Written to the project root
- Update .dockerignore - Add to
haloy.yamlif not already present. This improves Docker layer caching since changes to.dockerignorewon't invalidate the build cache.haloy.yaml - Validation command:
bash
haloy validate-config - Deployment command:
bash
haloy deploy - If haloy CLI is not installed, show installation options:
bash
# Shell script curl -fsSL https://sh.haloy.dev/install-haloy.sh | sh # Homebrew brew install haloydev/tap/haloy # npm/pnpm/bun npm install -g haloy pnpm add -g haloy bun add -g haloy
收集信息后,创建文件并提供:
haloy.yaml- haloy.yaml文件 - 写入项目根目录
- 更新.dockerignore - 如果尚未存在,将其添加到
haloy.yaml中。这可以改善Docker层缓存,因为.dockerignore的更改不会使构建缓存失效。haloy.yaml - 验证命令:
bash
haloy validate-config - 部署命令:
bash
haloy deploy - 如果未安装haloy CLI,显示安装选项:
bash
# Shell脚本 curl -fsSL https://sh.haloy.dev/install-haloy.sh | sh # Homebrew brew install haloydev/tap/haloy # npm/pnpm/bun npm install -g haloy pnpm add -g haloy bun add -g haloy
Example Interactions
示例交互
See for detailed interaction examples covering:
references/examples.md- Deploying with configured servers
- Database detection and self-hosted database setup
- Handling missing server configuration
详细的交互示例请查看,包括:
references/examples.md- 使用已配置服务器部署
- 数据库检测和自托管数据库设置
- 处理缺失的服务器配置