mirror of
https://github.com/tiennm99/ccs.git
synced 2026-07-16 12:15:57 +00:00
fix(docker): pin runtime deps to committed bun lockfile (#1358)
This commit is contained in:
+8
-15
@@ -1,4 +1,4 @@
|
|||||||
# syntax=docker/dockerfile:1
|
# syntax=docker/dockerfile:1.7
|
||||||
|
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
# Build stage: compile TypeScript and build UI
|
# Build stage: compile TypeScript and build UI
|
||||||
@@ -36,13 +36,10 @@ RUN bun run build:all
|
|||||||
# Validate build artifacts exist
|
# Validate build artifacts exist
|
||||||
RUN test -d dist && test -d lib && echo "[OK] Build artifacts validated"
|
RUN test -d dist && test -d lib && echo "[OK] Build artifacts validated"
|
||||||
|
|
||||||
# Generate a fresh npm lockfile from package.json immediately after build.
|
# Build runtime deps from the committed bun.lock to keep Docker installs pinned.
|
||||||
# This lockfile is ephemeral — never committed; bun.lock remains the dev lockfile.
|
# --ignore-scripts avoids user-home side effects from postinstall during image build.
|
||||||
# --ignore-scripts: only lockfile generation, no install side-effects needed here.
|
RUN --mount=type=cache,target=/root/.bun \
|
||||||
# postinstall (scripts/postinstall.js) is a user-facing setup script; it must NOT
|
bun install --frozen-lockfile --production --ignore-scripts
|
||||||
# run during the Docker build (it writes to ~/.ccs/ which does not exist here).
|
|
||||||
RUN --mount=type=cache,target=/root/.npm \
|
|
||||||
npm install --package-lock-only --ignore-scripts
|
|
||||||
|
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
# Runtime stage: Node-only, no Bun
|
# Runtime stage: Node-only, no Bun
|
||||||
@@ -60,13 +57,9 @@ RUN apt-get update \
|
|||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# Copy the ephemeral lockfile generated in the build stage (never committed).
|
# Copy pinned production dependencies resolved from the committed bun.lock.
|
||||||
# --ignore-scripts: postinstall writes ~/.ccs/ config which is not needed inside
|
COPY --from=build /app/package.json ./
|
||||||
# the Docker image; runtime deps (bcrypt v6+, express, etc.) have no native
|
COPY --from=build /app/node_modules ./node_modules
|
||||||
# compilation steps requiring postinstall.
|
|
||||||
COPY --from=build /app/package.json /app/package-lock.json ./
|
|
||||||
RUN --mount=type=cache,target=/root/.npm \
|
|
||||||
npm ci --omit=dev --ignore-scripts
|
|
||||||
|
|
||||||
COPY docker/entrypoint.sh /usr/local/bin/ccs-entrypoint
|
COPY docker/entrypoint.sh /usr/local/bin/ccs-entrypoint
|
||||||
RUN chmod +x /usr/local/bin/ccs-entrypoint
|
RUN chmod +x /usr/local/bin/ccs-entrypoint
|
||||||
|
|||||||
Reference in New Issue
Block a user