meteor-deployment

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Meteor deployment

Meteor 部署

meteor build
produces a self-contained Node bundle that runs anywhere the matching Node.js version runs. Galaxy is the first-party host; Docker / Kubernetes / SSH-to-a-Node-host all work too.
Match the Node version to the bundled Meteor Node:
MeteorNode major
3.020
3.1 through 3.422
3.5+24
Mismatch causes runtime errors. Run
meteor node -v
to confirm.
meteor build
会生成一个独立的Node包,可在任何匹配对应Node.js版本的环境中运行。Galaxy是官方托管平台;Docker / Kubernetes / 通过SSH连接到Node主机的方式也都适用。
请确保Node版本与Meteor打包时使用的Node版本匹配:
MeteorNode major
3.020
3.1 至 3.422
3.5+24
版本不匹配会导致运行时错误。运行
meteor node -v
来确认版本。

Decision flow

决策流程

  1. 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
    .
  2. Docker / Kubernetes?
    meteor build --directory ./build --server-only
    skips platform-specific mobile artifacts. Use
    --architecture os.linux.x86_64
    for a cross-build.
  3. SSH to a Node host? Same
    meteor build
    , scp the bundle, install prod deps under
    bundle/programs/server
    , run
    node main.js
    .
  4. Vercel / Netlify / serverless? Not supported. Meteor needs a long-lived Node process with a WebSocket.
  1. 使用Galaxy?选择Git Push to Deploy或Meteor CLI。从
    references/galaxy.md
    中配置Galaxy的设置源、构建钩子、健康检查和域名。
  2. 使用Docker / Kubernetes?执行
    meteor build --directory ./build --server-only
    可跳过特定平台的移动端产物。使用
    --architecture os.linux.x86_64
    进行跨架构构建。
  3. 通过SSH连接到Node主机?执行相同的
    meteor build
    命令,将包通过scp传输,在
    bundle/programs/server
    下安装生产依赖,然后运行
    node main.js
    。
  4. 使用Vercel / Netlify / Serverless?不支持。Meteor需要一个长期运行的Node进程并支持WebSocket。

Required environment

必需环境变量

VarPurpose
ROOT_URL
Absolute external URL (e.g.
https://app.example.com
).
MONGO_URL
mongodb://...
connection string.
MONGO_OPLOG_URL
Optional Mongo replica oplog URL.
PORT
Listen port. Default 3000.
BIND_IP
Network interface. Default 0.0.0.0.
METEOR_SETTINGS
JSON; populates
Meteor.settings
.
MAIL_URL
SMTP for
Email.send
and account emails.
ROOT_URL
is the external URL the browser sees, not the cluster-internal service URL. OAuth redirects,
Meteor.absoluteUrl
, and CSP all rely on it.
On Meteor 3.0 through 3.4, configure
MONGO_OPLOG_URL
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.
变量名用途
ROOT_URL
外部绝对URL(例如
https://app.example.com
)。
MONGO_URL
mongodb://...
格式的连接字符串。
MONGO_OPLOG_URL
可选的Mongo副本集oplog URL。
PORT
监听端口,默认值为3000。
BIND_IP
网络接口,默认值为0.0.0.0。
METEOR_SETTINGS
JSON格式数据,会填充到
Meteor.settings
中。
MAIL_URL
用于
Email.send
和账户邮件的SMTP地址。
ROOT_URL
是浏览器访问的外部URL,而非集群内部的服务URL。OAuth重定向、
Meteor.absoluteUrl
和CSP都依赖于它。
在Meteor 3.0至3.4版本中,需配置
MONGO_OPLOG_URL
以实现基于oplog的响应式;若未配置,Meteor会采用轮询方式。Meteor 3.5+版本无需该变量即可使用核心变更流,并在需要时回退到oplog或轮询方式。仅使用Atlas托管不会为旧版Meteor应用添加核心变更流支持。

settings.json

settings.json

json
{
  "public": { "appName": "My App", "stripePublishableKey": "pk_live_..." },
  "stripeSecretKey": "sk_live_...",
  "oauthSecretKey": "16-byte-base64==",
  "mailgun": { "apiKey": "..." }
}
Top-level keys: server only.
public
subtree: shipped to the client.
Load:
bash
undefined
json
{
  "public": { "appName": "My App", "stripePublishableKey": "pk_live_..." },
  "stripeSecretKey": "sk_live_...",
  "oauthSecretKey": "16-byte-base64==",
  "mailgun": { "apiKey": "..." }
}
顶层键:仅服务器端可用。
public
子树:会发送到客户端。
加载方式:
bash
undefined

dev

开发环境

meteor run --settings settings.json
meteor run --settings settings.json

production

生产环境

METEOR_SETTINGS=$(cat settings.json) node bundle/main.js
undefined
METEOR_SETTINGS=$(cat settings.json) node bundle/main.js
undefined

Galaxy

Galaxy

Choose one deployment path:
PathUse whenTrigger
Push to DeployGalaxy should build a connected GitHub or Bitbucket branch.Every push to the selected branch.
Meteor CLIA person or CI pipeline controls each upload.
meteor deploy <app-name>
.
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.json
Galaxy assigns a
myapp.sandbox.galaxycloud.app
hostname on Free or a regional
myapp.<region>.galaxycloud.app
hostname on paid plans. Add custom domains in the dashboard. The active primary domain controls
ROOT_URL
.
Galaxy injects
PORT
,
ROOT_URL
, and
METEOR_SETTINGS
. Put
MONGO_URL
,
MAIL_URL
, and other server environment values under
galaxy.meteor.com.env
in the Galaxy settings JSON. Do not assume a CLI
--settings
file overrides Repository Mode.
See
references/galaxy.md
for settings modes, Push to Deploy builds, zero-downtime rollout and rollback, proxies, Mongo TLS, memory, and custom base images.
选择以下一种部署路径:
路径适用场景触发条件
Push to DeployGalaxy需构建关联的GitHub或Bitbucket分支时。每次推送到选定分支时触发。
Meteor CLI由人员或CI管道控制每次上传时。执行
meteor deploy <app-name>
时触发。
对于免费应用,只需传入简单的应用名称,无需自定义域名:
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.json
Galaxy会为免费应用分配
myapp.sandbox.galaxycloud.app
域名,为付费应用分配区域化的
myapp.<region>.galaxycloud.app
域名。可在控制台中添加自定义域名。当前的主域名会控制
ROOT_URL
。
Galaxy会自动注入
PORT
、
ROOT_URL
和
METEOR_SETTINGS
。将
MONGO_URL
、
MAIL_URL
和其他服务器环境变量配置在Galaxy设置JSON的
galaxy.meteor.com.env
下。不要假设CLI的
--settings
文件会覆盖仓库模式的设置。
有关设置模式、Push to Deploy构建、零停机发布与回滚、代理、Mongo TLS、内存和自定义基础镜像的内容,请查看
references/galaxy.md
。

Docker

Docker

See
references/docker.md
for a working multi-stage Dockerfile. Build the bundle in one stage, install server deps and run in a smaller one.
--server-only
skips platform-specific mobile application builds, but it does not omit the browser client or create an API-only bundle. Meteor still builds the
web.cordova
client target used for hot code push.
有关可用的多阶段Dockerfile,请查看
references/docker.md
。在一个阶段中构建包,在另一个更小的阶段中安装服务器依赖并运行。
--server-only
会跳过特定平台的移动应用构建,但不会省略浏览器客户端或创建仅API的包。Meteor仍会构建用于热代码推送的
web.cordova
客户端目标。

Hot code push

热代码推送

autoupdate
provides production hot code push. It detects a new client version over DDP, applies stylesheet-only changes without reloading when possible, and otherwise performs a full browser reload. Remove
autoupdate
from
.meteor/packages
to disable HCP.
hot-module-replacement
is different. It replaces accepted JavaScript modules during development and falls back to HCP when a module cannot accept the update. HMR is disabled in production and on unsupported web architectures. There is no
Meteor.disableClientResourceFetch
switch in the current public API.
autoupdate
提供生产环境的热代码推送功能。它会通过DDP检测客户端新版本,尽可能在不刷新页面的情况下应用仅样式表的变更,否则会执行完整的浏览器刷新。从
.meteor/packages
中移除
autoupdate
即可禁用热代码推送(HCP)。
hot-module-replacement
有所不同。它会在开发期间替换可接受的JavaScript模块,当模块无法接受更新时回退到热代码推送。HMR在生产环境和不支持的Web架构中会被禁用。当前公开API中没有
Meteor.disableClientResourceFetch
开关。

Anti-patterns

反模式

  • Commit
    settings.json
    with production secrets. Use a CI secret store or env vars; load with
    METEOR_SETTINGS=$(cat ...)
    at startup.
  • Set
    ROOT_URL
    to the internal Kubernetes service URL. Use the external HTTPS URL or OAuth redirects and
    Meteor.absoluteUrl
    break.
  • 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
    --settings
    file. Keep secrets in Galaxy Mode or a secret store.
  • Hardcode Galaxy's port, load-balancer IP, or regional DNS target. Read
    $PORT
    and copy current network values from the app dashboard.
  • Bundle the source tree into the Docker image alongside the built bundle. Use multi-stage; the runtime image holds only
    bundle/
    .
  • 将包含生产密钥的
    settings.json
    提交到仓库。应使用CI密钥存储或环境变量;在启动时通过
    METEOR_SETTINGS=$(cat ...)
    加载。
  • 将
    ROOT_URL
    设置为Kubernetes内部服务URL。请使用外部HTTPS URL,否则OAuth重定向和
    Meteor.absoluteUrl
    会失效。
  • 使用与Meteor打包时不匹配的Node版本。务必检查
    meteor node -v
    的输出。
  • 在错误的架构上构建。使用M系列Mac的开发者若要为x86_64 Linux构建,必须传入
    --architecture os.linux.x86_64
    。
  • 提交包含凭据的Galaxy设置,或认为仓库模式会读取CLI的
    --settings
    文件。请将密钥保存在Galaxy模式或密钥存储中。
  • 硬编码Galaxy的端口、负载均衡器IP或区域DNS目标。请读取
    $PORT
    并从应用控制台复制当前网络值。
  • 将源码树与构建后的包一起打包到Docker镜像中。请使用多阶段构建;运行时镜像仅需包含
    bundle/
    。

See also

另请参阅

  • references/settings-and-env.md
  • references/galaxy.md
  • references/docker.md
  • references/eval-cases.md
  • references/settings-and-env.md
  • references/galaxy.md
  • references/docker.md
  • references/eval-cases.md