Meteor.js Application Example
This example shows how to deploy a Meteor.js application with MongoDB integration, media storage, and Cloudflare security.
Configuration
- Type: ECS cloud-compose deployment
- Size: 1024 CPU, 2048MB memory
- Framework: Meteor.js application
- Database: MongoDB with URI references
- Storage: Media storage integration
- Security: Cloudflare-only ingress protection
Key Features
- Meteor.js Deployment: Complete Meteor application configuration
- Multi-Resource Usage: MongoDB + S3 media storage
- Security: Cloudflare-only ingress protection
- Environment-Specific Secrets: Different Meteor settings per environment
- Resource References:
${resource:mongodb.uri}pattern - Root Domain Production: Production uses root domain
Environments
- Staging:
staging.example.com - Production:
example.com(root domain)
Meteor Configuration
- ROOT_URL: Environment-specific root URL
- PORT: 3000 (standard Meteor port)
- NODE_ENV: production (for both environments)
- METEOR_SETTINGS: Environment-specific JSON configuration
- MAIL_URL: SMTP configuration for Meteor email
Security Configuration
This ensures only Cloudflare can access the application directly.
Usage
- Ensure your parent stack provides MongoDB and media storage resources
- Configure Meteor settings JSON for each environment
- Set up SMTP mail URL for email functionality
- Deploy to staging for testing
- Promote to production (root domain)
Parent Stack Requirements
This example requires a parent stack that provides:
mongodbresource with URI accessmedia-storageresource (S3 bucket)- ECS deployment capabilities
- Domain management for root domain
- Cloudflare integration for security
Dockerfile
Copy this into a Dockerfile next to your Meteor app. The base image is
digest-pinned for reproducibility — bump the digest when you intentionally
move to a newer Node 22 patch release.
# Multi-stage build for Meteor.js application
FROM node:22-alpine@sha256:c610fcdfb1d5b4740dd70c284ed3cb16bb857e0f7166196e36a5501df7a3aa32 AS builder
# Install Meteor CLI at a pinned version. Bump as needed for your app;
# do not leave unpinned.
ARG METEOR_VERSION=3.2.2
RUN npm install -g meteor@${METEOR_VERSION}
# Set working directory
WORKDIR /app
# Copy package files. For reproducible builds commit a package-lock.json
# alongside your Meteor app; the install step below will pick it up.
COPY package*.json ./
COPY .meteor ./.meteor
# Copy source code
COPY . .
# Install dependencies. Uses `meteor npm ci` (reproducible from
# package-lock.json) when a lockfile is present, else falls back to
# `meteor npm install` so this example builds without one. Production
# apps should commit a lockfile to take the ci path.
RUN if [ -f package-lock.json ]; then meteor npm ci; else meteor npm install; fi
# Build the application
RUN meteor build --directory /app/build --architecture os.linux.x86_64
# Production stage
FROM node:22-alpine@sha256:c610fcdfb1d5b4740dd70c284ed3cb16bb857e0f7166196e36a5501df7a3aa32
# Install dumb-init for proper signal handling
RUN apk add --no-cache dumb-init
# Create app user
RUN addgroup -g 1001 -S meteor && \
adduser -S meteor -u 1001
# Set working directory
WORKDIR /app
# Copy built application
COPY --from=builder --chown=meteor:meteor /app/build/bundle .
# Install production dependencies. `meteor build` may or may not emit a
# package-lock.json into programs/server depending on the Meteor version
# and project layout; use the lockfile-aware install pattern.
RUN cd programs/server && if [ -f package-lock.json ]; then npm ci --omit=dev; else npm install --omit=dev; fi
# Switch to non-root user
USER meteor
# Expose port
EXPOSE 3000
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
CMD node -e "require('http').get('http://localhost:3000/', (res) => { process.exit(res.statusCode === 200 ? 0 : 1) })"
# Start the application
ENTRYPOINT ["dumb-init", "--"]
CMD ["node", "main.js"]