meteor-deployment
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseMeteor deployment
Meteor 部署
meteor buildMatch the Node version to the bundled Meteor Node:
| Meteor | Node major |
|---|---|
| 3.0 | 20 |
| 3.1 through 3.4 | 22 |
| 3.5+ | 24 |
Mismatch causes runtime errors. Run to confirm.
meteor node -vmeteor build请确保Node版本与Meteor打包时使用的Node版本匹配:
| Meteor | Node major |
|---|---|
| 3.0 | 20 |
| 3.1 至 3.4 | 22 |
| 3.5+ | 24 |
版本不匹配会导致运行时错误。运行来确认版本。
meteor node -vDecision flow
决策流程
- Galaxy? Choose Git Push to Deploy or the Meteor CLI. Configure Galaxy's
settings source, build hooks, health checks, and domains from
.
references/galaxy.md - Docker / Kubernetes? skips platform-specific mobile artifacts. Use
meteor build --directory ./build --server-onlyfor a cross-build.--architecture os.linux.x86_64 - SSH to a Node host? Same , scp the bundle, install prod deps under
meteor build, runbundle/programs/server.node main.js - Vercel / Netlify / serverless? Not supported. Meteor needs a long-lived Node process with a WebSocket.
- 使用Galaxy?选择Git Push to Deploy或Meteor CLI。从中配置Galaxy的设置源、构建钩子、健康检查和域名。
references/galaxy.md - 使用Docker / Kubernetes?执行可跳过特定平台的移动端产物。使用
meteor build --directory ./build --server-only进行跨架构构建。--architecture os.linux.x86_64 - 通过SSH连接到Node主机?执行相同的命令,将包通过scp传输,在
meteor build下安装生产依赖,然后运行bundle/programs/server。node main.js - 使用Vercel / Netlify / Serverless?不支持。Meteor需要一个长期运行的Node进程并支持WebSocket。
Required environment
必需环境变量
| Var | Purpose |
|---|---|
| Absolute external URL (e.g. |
| |
| Optional Mongo replica oplog URL. |
| Listen port. Default 3000. |
| Network interface. Default 0.0.0.0. |
| JSON; populates |
| SMTP for |
ROOT_URLMeteor.absoluteUrlOn Meteor 3.0 through 3.4, configure for oplog-backed
reactivity; without it, Meteor polls. Meteor 3.5+ can use core change streams
without that variable and falls back to oplog or polling when needed. Atlas
hosting alone does not add core change-stream support to an older Meteor app.
MONGO_OPLOG_URL| 变量名 | 用途 |
|---|---|
| 外部绝对URL(例如 |
| |
| 可选的Mongo副本集oplog URL。 |
| 监听端口,默认值为3000。 |
| 网络接口,默认值为0.0.0.0。 |
| JSON格式数据,会填充到 |
| 用于 |
ROOT_URLMeteor.absoluteUrl在Meteor 3.0至3.4版本中,需配置以实现基于oplog的响应式;若未配置,Meteor会采用轮询方式。Meteor 3.5+版本无需该变量即可使用核心变更流,并在需要时回退到oplog或轮询方式。仅使用Atlas托管不会为旧版Meteor应用添加核心变更流支持。
MONGO_OPLOG_URLsettings.json
settings.jsonsettings.json
settings.jsonjson
{
"public": { "appName": "My App", "stripePublishableKey": "pk_live_..." },
"stripeSecretKey": "sk_live_...",
"oauthSecretKey": "16-byte-base64==",
"mailgun": { "apiKey": "..." }
}Top-level keys: server only. subtree: shipped to the client.
publicLoad:
bash
undefinedjson
{
"public": { "appName": "My App", "stripePublishableKey": "pk_live_..." },
"stripeSecretKey": "sk_live_...",
"oauthSecretKey": "16-byte-base64==",
"mailgun": { "apiKey": "..." }
}顶层键:仅服务器端可用。子树:会发送到客户端。
public加载方式:
bash
undefineddev
开发环境
meteor run --settings settings.json
meteor run --settings settings.json
production
生产环境
METEOR_SETTINGS=$(cat settings.json) node bundle/main.js
undefinedMETEOR_SETTINGS=$(cat settings.json) node bundle/main.js
undefinedGalaxy
Galaxy
Choose one deployment path:
| Path | Use when | Trigger |
|---|---|---|
| Push to Deploy | Galaxy should build a connected GitHub or Bitbucket branch. | Every push to the selected branch. |
| Meteor CLI | A person or CI pipeline controls each upload. | |
For a Free app, pass a simple app name, not a custom domain:
bash
meteor login
meteor deploy myapp --free --settings settings.json
DEPLOY_HOSTNAME=eu-west-1.galaxy-deploy.meteor.com \
meteor deploy myapp --plan essentials --settings settings.jsonGalaxy assigns a hostname on Free or a
regional hostname on paid plans. Add custom
domains in the dashboard. The active primary domain controls .
myapp.sandbox.galaxycloud.appmyapp.<region>.galaxycloud.appROOT_URLGalaxy injects , , and . Put ,
, and other server environment values under
in the Galaxy settings JSON. Do not assume a CLI
file overrides Repository Mode.
PORTROOT_URLMETEOR_SETTINGSMONGO_URLMAIL_URLgalaxy.meteor.com.env--settingsSee for settings modes, Push to Deploy builds,
zero-downtime rollout and rollback, proxies, Mongo TLS, memory, and custom
base images.
references/galaxy.md选择以下一种部署路径:
| 路径 | 适用场景 | 触发条件 |
|---|---|---|
| Push to Deploy | Galaxy需构建关联的GitHub或Bitbucket分支时。 | 每次推送到选定分支时触发。 |
| Meteor CLI | 由人员或CI管道控制每次上传时。 | 执行 |
对于免费应用,只需传入简单的应用名称,无需自定义域名:
bash
meteor login
meteor deploy myapp --free --settings settings.json
DEPLOY_HOSTNAME=eu-west-1.galaxy-deploy.meteor.com \
meteor deploy myapp --plan essentials --settings settings.jsonGalaxy会为免费应用分配域名,为付费应用分配区域化的域名。可在控制台中添加自定义域名。当前的主域名会控制。
myapp.sandbox.galaxycloud.appmyapp.<region>.galaxycloud.appROOT_URLGalaxy会自动注入、和。将、和其他服务器环境变量配置在Galaxy设置JSON的下。不要假设CLI的文件会覆盖仓库模式的设置。
PORTROOT_URLMETEOR_SETTINGSMONGO_URLMAIL_URLgalaxy.meteor.com.env--settings有关设置模式、Push to Deploy构建、零停机发布与回滚、代理、Mongo TLS、内存和自定义基础镜像的内容,请查看。
references/galaxy.mdDocker
Docker
See for a working multi-stage Dockerfile. Build
the bundle in one stage, install server deps and run in a smaller one.
skips platform-specific mobile application builds, but it
does not omit the browser client or create an API-only bundle. Meteor still
builds the client target used for hot code push.
references/docker.md--server-onlyweb.cordova有关可用的多阶段Dockerfile,请查看。在一个阶段中构建包,在另一个更小的阶段中安装服务器依赖并运行。会跳过特定平台的移动应用构建,但不会省略浏览器客户端或创建仅API的包。Meteor仍会构建用于热代码推送的客户端目标。
references/docker.md--server-onlyweb.cordovaHot code push
热代码推送
autoupdateautoupdate.meteor/packageshot-module-replacementMeteor.disableClientResourceFetchautoupdate.meteor/packagesautoupdatehot-module-replacementMeteor.disableClientResourceFetchAnti-patterns
反模式
- Commit with production secrets. Use a CI secret store or env vars; load with
settings.jsonat startup.METEOR_SETTINGS=$(cat ...) - Set to the internal Kubernetes service URL. Use the external HTTPS URL or OAuth redirects and
ROOT_URLbreak.Meteor.absoluteUrl - Run a Node version that does not match the bundled Meteor Node. Always
check .
meteor node -v - Build on the wrong architecture. M-series Mac developers building for
x86_64 Linux must pass .
--architecture os.linux.x86_64 - Commit Galaxy settings with credentials or expect Repository Mode to read a
CLI file. Keep secrets in Galaxy Mode or a secret store.
--settings - Hardcode Galaxy's port, load-balancer IP, or regional DNS target. Read
and copy current network values from the app dashboard.
$PORT - Bundle the source tree into the Docker image alongside the built
bundle. Use multi-stage; the runtime image holds only .
bundle/
- 将包含生产密钥的提交到仓库。应使用CI密钥存储或环境变量;在启动时通过
settings.json加载。METEOR_SETTINGS=$(cat ...) - 将设置为Kubernetes内部服务URL。请使用外部HTTPS URL,否则OAuth重定向和
ROOT_URL会失效。Meteor.absoluteUrl - 使用与Meteor打包时不匹配的Node版本。务必检查的输出。
meteor node -v - 在错误的架构上构建。使用M系列Mac的开发者若要为x86_64 Linux构建,必须传入。
--architecture os.linux.x86_64 - 提交包含凭据的Galaxy设置,或认为仓库模式会读取CLI的文件。请将密钥保存在Galaxy模式或密钥存储中。
--settings - 硬编码Galaxy的端口、负载均衡器IP或区域DNS目标。请读取并从应用控制台复制当前网络值。
$PORT - 将源码树与构建后的包一起打包到Docker镜像中。请使用多阶段构建;运行时镜像仅需包含。
bundle/
See also
另请参阅
references/settings-and-env.mdreferences/galaxy.mdreferences/docker.mdreferences/eval-cases.md
references/settings-and-env.mdreferences/galaxy.mdreferences/docker.mdreferences/eval-cases.md