配置文件
配置文件
np.yaml 配置参考
# np.yaml — 完整配置参考
version: "1"
project: my-app
services:
- name: my-service # 服务名(必需,项目内唯一)
type: container # "binary" 或 "container"
source: my-image:tag # 二进制路径或容器镜像
port: 8080 # 对外暴露的端口
replicas: 2 # 实例数量
domain: api.example.com # (可选)Traefik 自动配置路由
runtime: podman # (可选)容器运行时:"podman"(默认)或 "docker"
env: # 环境变量
FOO: bar
LOG_LEVEL: debug
resources: # 每个实例的资源限制
cpu: "200" # MHz(例如 200 = 0.2 核)
memory: "256" # MB
tags: # (可选)自定义标签
- env=staging字段参考
| 字段 | 必需 | 默认值 | 说明 |
|---|---|---|---|
name |
✅ | — | 服务名(项目内唯一) |
type |
✅ | — | binary 用于原生二进制,container 用于 podman/Docker |
source |
✅ | — | 二进制路径或容器镜像名 |
port |
❌ | — | 通过 Traefik 暴露的端口 |
replicas |
❌ | 1 | 运行实例数 |
domain |
❌ | — | 设置后 Traefik 自动配置路由 |
runtime |
❌ | podman |
容器运行时:podman 或 docker |
env |
❌ | — | 键值对环境变量 |
resources.cpu |
❌ | 100 | 每实例 CPU MHz |
resources.memory |
❌ | 256 | 每实例内存 MB |
tags |
❌ | — | 任意 key=value 标签 |
容器运行时
np 默认使用 Podman 作为容器运行时。如需使用 Docker:
# 环境变量(全局覆盖)
export NP_CONTAINER_RUNTIME=docker
# np.yaml 中按服务覆盖
services:
- name: legacy-app
type: container
source: my-image:latest
runtime: docker最小示例
version: "1"
services:
- name: hello
type: container
source: nginx:alpine
port: 80完整示例
version: "1"
project: my-api
services:
- name: api
type: binary
source: ./api-server
port: 8080
replicas: 3
runtime: podman
env:
ENV: production
PORT: "8080"
resources:
cpu: "200"
memory: "256"
tags:
- env=prod
- team=backendNext: Commands reference →