Files
upstream-rocketchat/ee/apps/Dockerfile
upstream-mirror 30810eecd7
Some checks failed
Create issues from TODOs / todos (push) Failing after 3s
Close inactive issues / close-issues (push) Has been cancelled
Deploy GitHub Pages / deploy-preview (push) Has been cancelled
CI / ⚙️ Variables Setup (push) Has been cancelled
CI / ⚙️ Test Guard (push) Has been cancelled
CI / 🚀 Notify external services - draft (push) Has been cancelled
CI / 📦 Build Packages (push) Has been cancelled
CI / 📦 Meteor Build (coverage) (push) Has been cancelled
CI / 📦 Meteor Build (production) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [account-service presence-service omnichannel-transcript-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [account-service presence-service omnichannel-transcript-service], fips) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [authorization-service queue-worker-service ddp-streamer-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [authorization-service queue-worker-service ddp-streamer-service], fips) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], coverage) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], fips) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [account-service presence-service omnichannel-transcript-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [authorization-service queue-worker-service ddp-streamer-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [rocketchat], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [rocketchat], coverage) (push) Has been cancelled
CI / 🚢 Publish Docker Images (ghcr.io) (push) Has been cancelled
CI / 📦 Track Image Sizes (push) Has been cancelled
CI / 🔎 Code Check - Action Lint (push) Has been cancelled
CI / 🔎 Code Check (push) Has been cancelled
CI / 🔨 Test Storybook (push) Has been cancelled
CI / 🔨 Test Unit (push) Has been cancelled
CI / 🔨 Test API (CE) (push) Has been cancelled
CI / 🔨 Test API Livechat (CE) (push) Has been cancelled
CI / 🔨 Test UI (CE) (push) Has been cancelled
CI / 🔨 Test API (EE) (push) Has been cancelled
CI / 🔨 Test API Livechat (EE) (push) Has been cancelled
CI / 🔨 Test API Apps (deno-runtime - EE) (push) Has been cancelled
CI / 🔨 Test UI (EE) (push) Has been cancelled
CI / 🔨 Test API (FIPS) (push) Has been cancelled
CI / 🔨 Test API Livechat (FIPS) (push) Has been cancelled
CI / 🔨 Test UI (FIPS) (push) Has been cancelled
CI / 🔨 Test Federation Matrix (push) Has been cancelled
CI / 📊 Report Coverage (push) Has been cancelled
CI / ✅ Tests Done (push) Has been cancelled
CI / 🚀 Publish build assets (push) Has been cancelled
CI / 🚀 Publish Docker Images (DockerHub) (push) Has been cancelled
CI / 🚀 Notify external services (push) Has been cancelled
CI / Update Version Durability (push) Has been cancelled
Release / Release (push) Has been cancelled
Auto-close duplicate issues / auto-close-duplicates (push) Failing after 1s
Code scanning - action / CodeQL-Build (push) Failing after 2s
snapshot of https://github.com/RocketChat/Rocket.Chat.git (develop, 2026-09-16; blobs > 131072B omitted)
2026-09-16 01:21:02 +05:00

92 lines
3.6 KiB
Docker

FROM node:24.15.0-alpine3.23 AS builder
ARG SERVICE
RUN apk update && \
apk --no-cache add g++ python3 make py3-setuptools
WORKDIR /app
# The build context is the pruned, self-contained subset produced by
# `turbo prune <service> --use-gitignore=false` (then node_modules/.turbo stripped).
# It already contains exactly this service's dependency closure: every in-scope
# workspace's package.json + built dist (+ generated files like apps-engine/definition),
# a pruned yarn.lock, and the workspace plumbing (.yarnrc.yml, .yarn/*).
COPY . .
ENV NODE_ENV=production
# The service's own compiled output is emitted monorepo-mirrored inside its dist
# (e.g. dist/ee/apps/<service>/src/service.js, dist/apps/meteor/... for cross-imports).
# Overlay it onto /app so the compiled entrypoint lands at its real path, matching
# `CMD node src/service.js` from the service workdir. Library packages keep their own
# (flat) packages/*/dist, resolved via each package.json "main".
RUN cp -a ee/apps/${SERVICE}/dist/. ./ && rm -rf ee/apps/${SERVICE}/dist
WORKDIR /app/ee/apps/${SERVICE}
RUN yarn workspaces focus --production
# `turbo prune` derives the closure from the *whole* workspace graph (incl. devDependencies)
# and copies each in-scope package's full tree (TS sources, sourcemaps, type decls). None of
# that is needed at runtime. Trim the build context to the production payload before it is
# baked into the final image: drop staged workspace packages the production install did not
# link (dev-only internal deps), library TS sources, sourcemaps, and type declarations.
RUN set -eu; cd /app; \
# Packages the production install linked (node-modules linker symlinks them under
# node_modules/@rocket.chat). This is the source of truth for "needed at runtime".
keep="$(find node_modules/@rocket.chat -maxdepth 1 -type l -exec readlink -f {} \; | sed 's#^/app/##')"; \
# Guard: never proceed with an empty keep-set (e.g. a PnP linker with no symlinks),
# which would otherwise delete every workspace package below.
[ -n "$keep" ] || { echo 'trim: no linked workspace packages found — aborting'; exit 1; }; \
for d in packages/* ee/packages/*; do \
if printf '%s\n' "$keep" | grep -qxF "$d"; then \
# Kept package: drop its TS sources only when it ships a dist/ (its runtime entry).
# Packages whose entry point lives in src/ (no dist) keep their sources.
[ -d "$d/dist" ] && rm -rf "$d/src" || true; \
else \
rm -rf "$d"; \
fi; \
done; \
find packages ee/packages ee/apps \( -name '*.js.map' -o -name '*.d.ts' \) -delete
FROM node:24.15.0-alpine3.23 AS release-standard
ARG SERVICE
ENV NODE_ENV=production \
PORT=3000
RUN apk update && \
apk --no-cache --virtual deps add shadow && \
# Update OpenSSL
# CVE -> https://scout.docker.com/vulnerabilities/id/CVE-2025-9230?s=alpine&n=openssl&ns=alpine&t=apk&osn=alpine&osv=3.22
apk upgrade --no-cache openssl && \
rm -rf /var/cache/apk/* && \
groupmod -n rocketchat nogroup && \
useradd -u 65533 -r -g rocketchat rocketchat && \
apk del deps
COPY --chown=rocketchat:rocketchat --from=builder /app /app
WORKDIR /app/ee/apps/${SERVICE}
USER rocketchat
EXPOSE 3000 9458
CMD ["node", "src/service.js"]
FROM rocketchat/dhi-node:24.15.0-alpine3.23-fips AS release-fips
ARG SERVICE
ENV NODE_ENV=production \
PORT=3000
# the hardened image has no /etc/alpine-release, so node-gyp-build would detect
# glibc and load the wrong prebuild for native modules
ENV LIBC=musl
COPY --chown=node:node --from=builder /app /app
WORKDIR /app/ee/apps/${SERVICE}
USER node
EXPOSE 3000 9458
CMD ["node", "--force-fips", "--require", "./src/fips.js", "src/service.js"]