FROM node:18-alpine AS builder
WORKDIR /workspace
# Install dependencies and build the project from source
COPY package.json ./
RUN npm install
COPY . .
RUN npm run build
FROM node:18-alpine AS runtime
WORKDIR /workspace
# Copy built artifacts and node_modules from builder
COPY --from=builder /workspace/dist ./dist
COPY --from=builder /workspace/node_modules ./node_modules
COPY --from=builder /workspace/package.json ./package.json
ENV NODE_ENV=production
# A lightweight entrypoint to verify the container is functional
CMD ["node","-e","console.log('redlock container ready')"]
node_modules .git dist coverage *.log .DS_Store .vscode .idea *.tsbuildinfo
Failure summary - Failing step: [builder 4/6] RUN npm install - Exact error messages and exit code: - "error Command failed with exit code 1." - "npm error code 1" - "npm error path /workspace" - "npm error command failed" - "npm error command sh -c yarn build" - "A complete log of this run can be found in: /root/.npm/_logs/2026-04-12T23_58_19_012Z-debug-0.log" - Missing packages or files: None explicitly mentioned - What happened: The npm install step invokes yarn build and fails with exit code 1 during that build. - Version and environment details: - Base image: node:18-alpine - Build step shows: [builder 4/6] RUN npm install - Yarn version: 1.22.22 - TypeScript compiler version shown: 4.6.4 (The TypeScript Compiler - Version 4.6.4) - npm notice: New major version of npm available! 10.8.2 -> 11.12.1 - NPM log path for the run: /root/.npm/_logs/2026-04-12T23_58_19_012Z-debug-0.log - Notable context in log (warnings not detailed here): Deprecation warnings during npm install are present but not enumerated in this summary.
FROM node:18-alpine AS builder
WORKDIR /workspace
COPY package.json ./
RUN npm install --ignore-scripts
COPY . .
RUN npm run build
FROM node:18-alpine AS runtime
WORKDIR /workspace
# Copy built artifacts and node_modules from builder
COPY --from=builder /workspace/dist ./dist
COPY --from=builder /workspace/node_modules ./node_modules
COPY --from=builder /workspace/package.json ./package.json
ENV NODE_ENV=production
# Lightweight runtime check that loads the built code
CMD ["node", "-e", "import('./dist/esm/index.js').then(() => { console.log('ready') }).catch((e) => { console.error('load error', e); process.exit(1); })"]
Concerns: The CMD assumes dist/esm/index.js exists for the load test; if the build output path differs (e.g., dist/index.js or dist/**/*.js), container load may fail., Dev dependencies are included in the runtime image because node_modules is copied from the builder; consider pruning to production dependencies to reduce image size.
Smoke [FAIL]: node -e \"import('./dist/esm/index.js').then(() => { console.log('ready') }).catch((e) => { console.error('load error', e); process.exit(1); })\
Output: sh: syntax error: unexpected "("
Smoke [FAIL]: test -f dist/esm/index.js && echo 'dist/esm/index.js exists' || echo 'dist/esm/index.js missing
Output: sh: syntax error: unterminated quoted string
Smoke [FAIL]: test -f dist/index.js && echo 'dist/index.js exists' || echo 'dist/index.js missing
Output: sh: syntax error: unterminated quoted stringFROM node:18 AS builder
WORKDIR /workspace
# Install dependencies and build the project from source
COPY package.json ./
RUN npm install
COPY . .
RUN npm run build
FROM node:18-alpine AS runtime
WORKDIR /workspace
# Copy built artifacts and node_modules from builder
COPY --from=builder /workspace/dist ./dist
COPY --from=builder /workspace/node_modules ./node_modules
COPY --from=builder /workspace/package.json ./package.json
ENV NODE_ENV=production
# Lightweight runtime check that prints a simple message
CMD ["node", "-e", "console.log('redlock container ready')"]
Summary of Docker build error - Failing step - [builder 4/6] RUN npm install - Exact error message and exit code (preserved) - error Command failed with exit code 1. - npm error code 1 - npm error path /workspace - npm error command failed - npm error command sh -c yarn build - Docker build exit context: ERROR: failed to build: failed to solve: process "/bin/sh -c npm install" did not complete successfully: exit code: 1 - Failing command/command sequence - The Dockerfile runs npm install, which during its lifecycle executes yarn build (as shown by: "command sh -c yarn build"), and that overall step exits with code 1. - Missing packages or files mentioned - No explicit missing package/file errors are shown. The log mostly contains deprecation warnings and then the yarn build script failing. No file-not-found or package-not-found lines are present. - Version mismatch / environment information - New major version of npm available! 10.8.2 -> 11.12.1 - Yarn version shown: v1.22.22 - TypeScript compiler version printed during build: 4.6.4 - Node image in use appears to be Node 18 (various node:18(-alpine) image references)
Summary of Docker build error - Exact error message and exit code - ERROR: failed to solve: process "/bin/sh -c npm install" did not complete successfully: exit code: 1 - error Command failed with exit code 1. - Exit code: 1 - Failing command/step - Builder step 4/6: RUN npm install - Missing packages or files mentioned - No missing packages or files explicitly mentioned in the log. (Reference to npm log at /root/.npm/_logs/2026-04-13T00_05_00_078Z-debug-0.log) - Version mismatch / environment info - TypeScript compiler version: 4.6.4 (tsc: The TypeScript Compiler - Version 4.6.4) - Base images: node:18-alpine and node:18 - npm update notice: New major version available: 10.8.2 -> 11.12.1
FROM node:18 AS builder
WORKDIR /workspace
# Install dependencies and build the project from source
COPY package.json ./
RUN yarn install
COPY . .
RUN yarn build
FROM node:18 AS runtime
WORKDIR /workspace
# Copy built artifacts and node_modules from builder
COPY --from=builder /workspace/dist ./dist
COPY --from=builder /workspace/node_modules ./node_modules
COPY --from=builder /workspace/package.json ./package.json
ENV NODE_ENV=production
# Lightweight runtime check that prints a simple message
CMD ["node", "-e", "console.log('redlock container ready')"]
Summary of Docker build error - Exact error messages and exit code - error Command failed with exit code 1. - error Command failed with exit code 1. - Failing command/step - [builder 4/6] RUN yarn install - Dockerfile:6 (shows RUN yarn install) - Missing packages or files mentioned - No lockfile found. (info from yarn install) - Version/mismatch information - Base image: node:18 (resolved as docker.io/library/node:18@sha256:c6ae79e38498325db67193d391e6ec1d224d96c693a8a4d943498556716d3783) - Yarn: yarn install v1.22.22 - TypeScript compiler: Version 4.6.4 (tsc) - Warnings about old dependencies (e.g., eslint@8.57.1: This version is no longer supported) - Other notable warnings in the log indicate outdated packages (rimraf, glob inflight, etc.), but the build failure stems from yarn install exit code 1.
FROM node:18 AS builder
WORKDIR /workspace
# Use npm to install dependencies to avoid yarn errors in this environment
COPY package.json ./
COPY package-lock.json* ./
RUN npm install --legacy-peer-deps
COPY . .
RUN npm run build
FROM node:18-alpine AS runtime
WORKDIR /workspace
COPY --from=builder /workspace/dist ./dist
COPY --from=builder /workspace/node_modules ./node_modules
COPY --from=builder /workspace/package.json ./package.json
ENV NODE_ENV=production
CMD ["node", "-e", "console.log('redlock container ready')"]
- Exact error message and exit code: - process "/bin/sh -c npm install --legacy-peer-deps" did not complete successfully: exit code: 1 - error Command failed with exit code 1. - npm error code 1 - Failing command/step: - [builder 5/7] RUN npm install --legacy-peer-deps - Missing packages or files mentioned: - No explicit missing packages/files are mentioned. The failure occurs inside npm install which triggers yarn build during the redlock prepare step. - Version mismatch / version info: - New major version of npm available! 10.8.2 -> 11.12.1 - TypeScript Compiler - Version 4.6.4 (as part of the yarn build output) - Other version notes present (e.g., yarn v1.22.22) are shown but the key mismatch is the npm major upgrade notice.
FROM node:18 AS builder
WORKDIR /workspace
# Install dependencies without running prepare scripts
COPY package.json ./
RUN npm install --ignore-scripts --silent
# Copy the project files and build from source
COPY . .
RUN npm run build
FROM node:18 AS runtime
WORKDIR /workspace
# Copy built artifacts and dependencies from builder
COPY --from=builder /workspace/dist ./dist
COPY --from=builder /workspace/node_modules ./node_modules
COPY --from=builder /workspace/package.json ./package.json
ENV NODE_ENV=production
CMD ["node", "-e", "console.log('redlock container ready')"]
Smoke [PASS]: test -d /workspace/dist
Smoke [PASS]: test -d /workspace/node_modules
Smoke [FAIL]: node -e "try { require('./dist'); console.log('dist-load-ok'); } catch (e) { console.error('dist-load-failed', e && e.message ? e.message : 'unknown'); process.exit(1); }
Output: sh: 1: Syntax error: Unterminated quoted stringFROM node:18 AS builder
WORKDIR /workspace
COPY package.json ./
RUN npm install --ignore-scripts --silent
COPY . .
RUN npm run build
FROM node:18-alpine AS runtime
WORKDIR /workspace
COPY --from=builder /workspace/dist ./dist
COPY --from=builder /workspace/node_modules ./node_modules
COPY --from=builder /workspace/package.json ./package.json
ENV NODE_ENV=production
RUN node -e "console.log('ready')" || true
Concerns: No CMD or ENTRYPOINT defined in the final stage, so the image cannot be run as a service without specifying how to start the app., Copying node_modules from the build stage may include devDependencies; consider using npm ci --production or pruning devDependencies to keep the runtime image lean., No EXPOSE directive or explicit startup guidance; if this is intended to run a server, port exposure and a startup command should be provided.
FROM node:18 AS builder
WORKDIR /workspace
COPY package.json ./
RUN npm install --ignore-scripts --silent
COPY . .
RUN npm run build
FROM node:18-alpine AS runtime
WORKDIR /workspace
# Copy built artifacts and dependencies from builder
COPY --from=builder /workspace/dist ./dist
COPY --from=builder /workspace/node_modules ./node_modules
COPY --from=builder /workspace/package.json ./package.json
ENV NODE_ENV=production
# Start the built library with a small test harness to ensure it's loadable
CMD ["node", "-e", "import('./dist/esm/index.js').then(() => console.log('ready')).catch(e => { console.error(e); process.exit(1); })"]
Concerns: Copying node_modules from the builder stage into an alpine runtime can lead to binary compatibility issues (glibc vs musl). If native modules are present, they may not work correctly in the final runtime image., The CMD test harness assumes dist/esm/index.js exists and is an ES module; if the build outputs a different structure or CJS module, the load test may fail.
Smoke [FAIL]: node -e \"import('./dist/esm/index.js').then(() => console.log('ready')).catch(e => { console.error(e); process.exit(1); })\
Output: sh: syntax error: unexpected "("
Smoke [PASS]: test -f dist/esm/index.js
Smoke [PASS]: node -vFROM node:18 AS builder WORKDIR /workspace COPY package.json ./ RUN npm install --legacy-peer-deps COPY . . RUN npm run build FROM node:18-alpine AS runtime WORKDIR /workspace COPY --from=builder /workspace/dist ./dist COPY --from=builder /workspace/node_modules ./node_modules COPY --from=builder /workspace/package.json ./package.json ENV NODE_ENV=production CMD ["node", "dist/esm/index.js"]
- Exact error message and exit code - 13.16 error Command failed with exit code 1. - 13.19 npm error code 1 - 13.19 npm error path /workspace - 13.19 npm error command failed - 13.19 npm error command sh -c yarn build - A complete log of this run can be found in: /root/.npm/_logs/2026-04-13T00_15_48_065Z-debug-0.log - Failing command/step - [builder 4/6] RUN npm install --legacy-peer-deps - Underlying cause: npm install runs the prepare script of redlock@v5.0.0-beta.2, which executes yarn build, and that build step exits with code 1. - Missing packages or files mentioned - No explicit missing package/file is mentioned in the error output. The failure occurs during the prepare script for redlock (redlock@v5.0.0-beta.2) invoking yarn build. - Version mismatch / environment info - Base images shown: node:18-alpine (runtime) and node:18 (builder) - Yarn version used: 1.22.22 - TypeScript compiler version shown: 4.6.4 - npm notice about upgrade: New major version of npm available! 10.8.2 -> 11.12.1
FROM node:18 AS builder WORKDIR /workspace # Install dependencies without running prepare scripts to avoid yarn build during npm install COPY package.json ./ RUN npm install --ignore-scripts --silent # Copy the project files and build from source COPY . . RUN npm run build FROM node:18 AS runtime WORKDIR /workspace # Copy built artifacts and dependencies from builder COPY --from=builder /workspace/dist ./dist COPY --from=builder /workspace/node_modules ./node_modules COPY --from=builder /workspace/package.json ./package.json ENV NODE_ENV=production # Start the built library (or a simple loader) to verify container works CMD ["node", "dist/esm/index.js"]
Concerns: Potentially copying node_modules from the builder to the runtime image may bloat the image and potentially include devDependencies; consider pruning production dependencies (e.g., npm prune --production) in the builder before copying, or install only production modules in the runtime stage., No healthcheck defined. Adding a HEALTHCHECK could help verify the container remains responsive over time., The build phase copies the entire context (COPY . .) after installing dependencies; this can reintroduce files that should be ignored (e.g., node_modules, local artifacts) unless a proper .dockerignore is used. Smoke [PASS]: test -s dist/esm/index.js Smoke [PASS]: node dist/esm/index.js