FROM node:22.22.3-alpine3.23
# Create app directory
WORKDIR /app
# Install dependencies first (copy package manifests)
COPY package*.json ./
# Install dependencies (production and dev, CI will install as needed)
RUN npm ci
# Copy source code
COPY . .
# Build the project if a build script is defined
RUN npm run build --if-present
# Set environment to production for runtime
ENV NODE_ENV=production
# Provide a simple, non-daemon command to indicate container is ready
CMD ["node", "-e", "console.log('passport-jwt container ready')"]
node_modules .git .gitignore docs test coverage npm-debug.log .DS_Store
Concerns: npm ci requires a package-lock.json; ensure a lockfile is committed to the repo to avoid npm ci failures during build., No explicit healthcheck or server startup logic beyond a console message; consider adding a real healthcheck for container reliability.
Smoke [FAIL]: node -e "const jwtlib=require('./'); const {Strategy, ExtractJwt}=jwtlib; const strat=new Strategy({ jwtFromRequest: ExtractJwt.fromAuthHeaderAsBearerToken(), secretOrKey: 'secret' }, (payload, done)=>{ done(null, false); }); console.log('STRATEGY_CREATED');
Output: sh: syntax error: unterminated quoted string
Smoke [FAIL]: node -e "const jwtlib=require('./'); const { ExtractJwt }=jwtlib; console.log(typeof ExtractJwt.fromAuthHeaderAsBearerToken() === 'function' ? 'EXTRACT_OK' : 'EXTRACT_FAIL');
Output: sh: syntax error: unterminated quoted stringFROM node:22-bullseye-slim
# Create app directory
WORKDIR /app
# Install dependencies first (copy package manifests)
COPY package*.json ./
# Install dependencies (production and dev, CI will install as needed)
RUN npm ci
# Copy source code
COPY . .
# Build the project if a build script is defined
RUN npm run build --if-present
# Set environment to production for runtime
ENV NODE_ENV=production
# Provide a simple, non-daemon command to indicate container is ready
CMD ["node","-e","console.log('passport-jwt container ready')"]
Smoke [FAIL]: docker run --rm --entrypoint "" <image> sh -c "node -e \"try { const {Strategy, ExtractJwt} = require('passport-jwt'); const ok = typeof Strategy === 'function' && typeof ExtractJwt !== 'undefined'; console.log(ok ? 'ok' : 'not_ok'); } catch(e) { console.error(e); process.exit(1); }\" | grep -q ok && echo PASS
Output: sh: 1: Syntax error: Unterminated quoted string
Smoke [FAIL]: docker run --rm --entrypoint "" <image> sh -c "node -e \"try { const {Strategy, ExtractJwt} = require('passport-jwt'); const opts = { jwtFromRequest: ExtractJwt.fromAuthHeaderAsBearerToken(), secretOrKey: 'secret' }; const strat = new Strategy(opts, function(){ }); console.log('strategy_created'); } catch(e) { console.error(e); process.exit(1); }\" | grep -q strategy_created && echo PASS
Output: sh: 1: Syntax error: Unterminated quoted stringnode_modules .git .gitignore docs test coverage npm-debug.log .DS_Store
Concerns: The image does not start a long-running service; the CMD simply prints a ready message. For a library, this may be fine, but consider including a healthcheck or a minimal test to validate runtime integrity., If the project has no build script, the 'npm run build --if-present' will be a no-op. The image relies on the presence of a build script to actually compile from source., npm ci installs devDependencies by default unless NODE_ENV or npm_config_production is set; in a production image you might want to omit devDependencies to reduce size.
Smoke [FAIL]: docker run --rm --entrypoint "" <image> sh -c "node -e \"const {Strategy}=require('passport-jwt'); console.assert(typeof Strategy==='function'); console.log('ok')\
Output: sh: 1: Syntax error: Unterminated quoted string
Smoke [FAIL]: docker run --rm --entrypoint "" <image> sh -c "node -e \"const {ExtractJwt}=require('passport-jwt'); console.assert(typeof ExtractJwt.fromAuthHeaderAsBearerToken==='function'); console.log('ok')\
Output: sh: 1: Syntax error: Unterminated quoted stringFROM node:22.22.3-alpine3.23
WORKDIR /app
# Install build dependencies for npm install/build steps
COPY package*.json ./
RUN apk add --no-cache --virtual .build-deps python3 g++ make \
&& npm ci \
&& npm run build --if-present \
&& npm prune --production \
&& apk del .build-deps
# Copy the rest of the source
COPY . .
ENV NODE_ENV=production
# Start a minimal long-running process to keep the container alive and expose a basic health check
# This loads the library to ensure dependencies are present and does not start a real service.
CMD ["node","-e","require('./lib'); console.log('passport-jwt loaded'); setInterval(()=>{}, 1000000)"]
# Docker build context ignore .git .gitignore node_modules test docs .github coverage *.log *.tmp .env .env.*
Concerns: The CMD assumes a library entry point at ./lib (require('./lib')). If the package.json 'main' points to a different path (e.g., lib/index.js vs. lib.js, or src/index.js), the container startup could fail. Consider aligning CMD with the actual main entry or using package.json main to determine the correct path., No explicit tests validate core runtime behavior beyond loading the module. It would be helpful to add a lightweight smoke script or a small test that exercises a concrete exported API to ensure runtime integrity after npm prune.
Smoke [FAIL]: docker run --rm --entrypoint "" <image> sh -c "node -e \"try { const lib = require('./lib'); if (lib == null) { process.exit(1); } console.log('ok'); } catch (e) { process.exit(1); }\
Output: sh: syntax error: unterminated quoted string
Smoke [FAIL]: docker run --rm --entrypoint "" <image> sh -c "node -e \"try { const lib = require('./lib'); if (typeof lib === 'function') { lib({}); } console.log('ok'); } catch (e) { process.exit(1); }\
Output: sh: syntax error: unterminated quoted stringFROM node:22.22.3-alpine3.23
WORKDIR /app
# Copy package manifests first for efficient docker cache usage
COPY package*.json ./
# Install dependencies and build if needed
RUN apk add --no-cache --virtual .build-deps python3 g++ make \
&& npm ci \
&& npm run build --if-present \
&& npm prune --production \
&& apk del .build-deps
# Copy the rest of the source code
COPY . .
ENV NODE_ENV=production
# Ensure a minimal long-running process can be started to satisfy health checks
# The VerifyBuild smoke test loads the local lib to verify runtime availability
CMD ["node","-e","require('./lib'); console.log(\"passport-jwt loaded\"); setInterval(() => {}, 1000000)"]
Concerns: npm ci requires a package-lock.json; if it is missing, the build will fail, The runtime test assumes require('./lib') resolves to a valid entry point (lib/index.js). If the project layout differs, runtime may fail, FROM image tag should be kept up-to-date and security-scanned
Smoke [FAIL]: docker run --rm --entrypoint \"\" <image> sh -c \"node -e 'require(\"./lib\"); console.log(\"passport-jwt loaded\");'\
Output: sh: can't open image: no such fileFROM node:22.22.3-alpine3.23
WORKDIR /app
# Copy package manifests first for efficient docker cache usage
COPY package*.json ./
# Install dependencies (use npm ci if a lockfile is present, otherwise npm install)
RUN apk add --no-cache --virtual .build-deps python3 g++ make \
&& if [ -f package-lock.json ]; then npm ci; else npm install; fi \
&& npm run build --if-present \
&& npm prune --production \
&& apk del .build-deps
# Copy the rest of the source code
COPY . .
ENV NODE_ENV=production
# Smoke test startup: load the library to ensure runtime integrity
RUN echo 'console.log("passport-jwt image building");' > /tmp/healthcheck.js
RUN bash -lc 'node -e "require(\"./lib\");" >/dev/null 2>&1 || true'
# Create a tiny startup script that validates the library can be required
RUN echo 'require("./lib"); console.log("passport-jwt loaded");' > /app/smoke.js
CMD ["node","/app/smoke.js"]
Concerns: The build step runs npm run build before COPY . ., so when building, the source code isn't yet in the image; this likely causes build to fail or skip and means the image may not actually build from source., There is a build-time require check (node -e "require('./lib');") before the source is present, which will be a no-op or skipped and doesn't validate runtime integrity of the actual code., The use of npm prune --production after building will remove devDependencies; if tests or build steps relying on devDependencies were intended to run at runtime, they will fail., The healthcheck.js created at build time is not used and appears to be unused clutter in the final image.FROM node:22.22.3-alpine3.23
WORKDIR /
# Copy package manifests first for efficient docker cache usage
COPY package*.json ./
# Install dependencies and build if present
RUN apk add --no-cache --virtual .build-deps python3 g++ make \
&& npm ci \
&& npm run build --if-present \
&& npm prune --production \
&& apk del .build-deps
# Copy the rest of the source code
COPY . .
ENV NODE_ENV=production
# Minimal startup: this image is a library; smoke tests override entrypoint
CMD ["node","-e","console.log('passport-jwt image ready')"]
Concerns: WORKDIR is set to / (root) which is unusual; consider using /app or /workspace to avoid potential path confusion., COPY . . happens after npm ci/build: ensure a lockfile exists (package-lock.json) to support npm ci; otherwise the build may fail in CI environments without a lock., FROM image tag is highly specific; ensure CI systems can pull that exact tag or consider a slightly more flexible tag.
Smoke [FAIL]: node -e \"const pj=require('passport-jwt'); const ok=(typeof pj.Strategy==='function'); if(!ok){ console.error('missing Strategy'); process.exit(2);} console.log('ok')\
Output: sh: syntax error: unexpected "("
Smoke [FAIL]: node -e \"const {Strategy, ExtractJwt} = require('passport-jwt'); const ok=(typeof Strategy==='function' && typeof ExtractJwt==='object'); console.log(ok?'ok':'notok')\
Output: sh: syntax error: unexpected "("FROM node:22.22.3-alpine3.23
WORKDIR /app
# Copy package manifests first for efficient docker cache usage
COPY package*.json ./
# Install dependencies and build if present
RUN apk add --no-cache --virtual .build-deps python3 g++ make \
&& if [ -f package-lock.json ]; then npm ci; else npm install; fi \
&& npm run build --if-present \
&& npm prune --production \
&& apk del .build-deps
# Copy the rest of the source code
COPY . .
ENV NODE_ENV=production
# Healthcheck to validate the library can be required
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 CMD node -e "try { require('./lib'); console.log('health ok'); } catch(e) { process.exit(1); }"
# Simple startup message
CMD ["node","-e","console.log('passport-jwt image ready')"]
Smoke [FAIL]: node -e "try { const lib = require('./lib'); const ok = lib && ((typeof lib.Strategy === 'function') || (typeof lib === 'function') || (typeof lib.ExtractJwt !== 'undefined')); if(!ok){ process.exit(1); } console.log('ok'); } catch(e) { process.exit(1); }
Output: sh: syntax error: unterminated quoted string
Smoke [FAIL]: node -e "try { const lib = require('./lib'); const hasExport = lib && ((typeof lib.Strategy === 'function') || (typeof lib.ExtractJwt !== 'undefined') || (typeof lib === 'function')); if(!hasExport){ process.exit(1); } console.log('ok'); } catch(e) { process.exit(1); }
Output: sh: syntax error: unterminated quoted stringFROM node:22.22.3-alpine3.23
WORKDIR /app
# Copy manifests and install dependencies first for better cache
COPY package.json package-lock.json ./
RUN apk add --no-cache --virtual .build-deps python3 g++ make \
&& npm ci \
&& npm run build --if-present \
&& npm prune --production \
&& apk del .build-deps
# Copy the rest of the source code
COPY . .
ENV NODE_ENV=production
# Healthcheck to validate the library can be required at runtime
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 CMD node -e "try { require('./lib'); console.log('health ok'); } catch(e) { process.exit(1); }"
# Simple startup message; this image is a library
CMD ["node","-e","console.log('passport-jwt image ready')"]
Concerns: COPY . . after npm build could overwrite the built lib/ directory if the repo includes a prebuilt lib, or it may override node_modules if not excluded by a .dockerignore., Healthcheck assumes the library builds to ./lib; if the project outputs to a different path (e.g., ./dist), healthcheck may fail., Pruning development dependencies before running tests (npm prune --production) may cause the project’s test scripts or optional build steps to fail if they rely on devDependencies.
Smoke [FAIL]: node -e "const lib = require('./lib'); const { Strategy, ExtractJwt } = lib; if (!ExtractJwt || typeof ExtractJwt.fromAuthHeaderAsBearerToken !== 'function') { console.error('missing ExtractJwt'); process.exit(2); } const opts = { jwtFromRequest: ExtractJwt.fromAuthHeaderAsBearerToken() }; const strat = new Strategy(opts, function(payload, done){ done(null, payload); }); console.log(typeof strat === 'object' ? 'ok' : 'fail');
Output: sh: syntax error: unterminated quoted string
Smoke [FAIL]: node -e "const lib = require('./lib'); const { ExtractJwt } = lib; const f = ExtractJwt && ExtractJwt.fromAuthHeaderAsBearerToken ? ExtractJwt.fromAuthHeaderAsBearerToken() : null; if (typeof f === 'function') { console.log('ok'); } else { console.error('missing function'); process.exit(1); }
Output: sh: syntax error: unterminated quoted stringFROM node:22.22.3-alpine3.23
WORKDIR /app
# Copy manifests and install dependencies first for efficient Docker layer caching
COPY package.json package-lock.json ./
RUN apk add --no-cache --virtual .build-deps python3 g++ make \
&& npm ci \
&& npm run build --if-present \
&& npm prune --production \
&& apk del .build-deps
# Copy the rest of the source code
COPY . .
ENV NODE_ENV=production
# Healthcheck to verify the library can be required at runtime
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 CMD ["node","-e","try{require('./lib'); console.log('health ok');}catch(e){process.exit(1)}"]
# Simple startup message; this image is a library
CMD ["node","-e","console.log('passport-jwt image ready')"]
Concerns: The Dockerfile runs npm ci and npm run build before copying the rest of the source code, so the build step likely cannot succeed since the source files are not present yet., If the build step relies on source files (typical for a library), the resulting /app/lib (or other build output) may be missing in the final image, causing the healthcheck and runtime require('./lib') to fail., COPY . . should occur before npm ci/build (or a multi-stage approach should copy code first) to ensure the build has access to the source., The healthcheck assumes a built lib exists; without a successful build, the container may fail health checks. Consider a clearer build/test flow or a multi-stage build that ensures artifacts exist before the final image., The CMD prints a startup message but does not verify runtime behavior beyond the healthcheck, which is acceptable but could be improved with a more functional smoke test.FROM node:22.22.3-alpine3.23 AS builder
WORKDIR /app
# Install build deps and install dependencies
COPY package.json package-lock.json ./
RUN apk add --no-cache --virtual .build-deps python3 g++ make \
&& npm ci \
&& npm run build --if-present \
&& npm prune --production \
&& apk del .build-deps
# Copy the rest of the source code
COPY . .
# Final runtime image
FROM node:22.22.3-alpine3.23
WORKDIR /app
# Copy built artifacts from builder
COPY --from=builder /app /app
ENV NODE_ENV=production
# Healthcheck to verify runtime integrity by requiring the library
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 CMD node -e "try { require('./lib'); console.log('health ok'); } catch(e) { process.exit(1); }"
# Basic startup message (this is a library package, no long-running service is required)
CMD ["node","-e","console.log('passport-jwt image ready')"]
Concerns: COPY . . after npm prune may overwrite built artifacts or node_modules, risking missing production dependencies in the final image., Healthcheck assumes the library's runtime entry point is available at ./lib; if the build outputs to a different path, healthcheck may fail., Final image does not run npm install; if the project relies on postinstall steps or native binaries, they may not be prepared for runtime unless the build stage handles them correctly.
Smoke [FAIL]: docker run --rm --entrypoint "" <image> sh -c "node -e 'const lib = require(\"./lib\"); const ok = (typeof lib === \"function\" || (typeof lib === \"object\" && (typeof lib.Strategy === \"function\" || typeof lib.ExtractJwt === \"object\" || typeof lib.verify === \"function\"))); if (!ok) { process.exit(1); } console.log(\"ok\");
Output: sh: syntax error: unterminated quoted string
Smoke [FAIL]: docker run --rm --entrypoint "" <image> sh -c "node -e 'try { const lib = require(\"./lib\"); const keys = Object.keys(lib as any || {}); const ok = keys.length > 0 || typeof lib === \"function\"; if (!ok) { process.exit(1); } console.log(\"ok\"); } catch(e) { process.exit(1); }
Output: sh: syntax error: unterminated quoted stringFROM node:22.22.3-alpine3.23 AS builder
WORKDIR /app
# Install dependencies and install production-ready node_modules
COPY package.json package-lock.json ./
RUN apk add --no-cache --virtual .build-deps python3 g++ make \
&& npm ci \
&& apk del .build-deps
# Copy the rest of the source code and build
COPY . .
RUN npm run build --if-present
RUN npm prune --production
# Final runtime image
FROM node:22.22.3-alpine3.23
WORKDIR /app
# Copy built artifacts from builder
COPY --from=builder /app /app
ENV NODE_ENV=production
# Healthcheck to verify library can be required at runtime
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 CMD node -e "try { require('./lib'); console.log('health ok'); } catch(e) { process.exit(1); }"
# No persistent service required for a library; emit a simple ready message
CMD ["node","-e","console.log('passport-jwt image ready')"]
Smoke [FAIL]: node -e "try { const lib = require('./lib'); if (typeof lib === 'function') { lib({ smoke: true }); console.log('ok'); } else if (lib && typeof lib.init === 'function') { lib.init({ smoke: true }); console.log('ok'); } else { console.log('ok'); } } catch (e) { process.exit(1); }
Output: sh: syntax error: unterminated quoted string
Smoke [FAIL]: cd /app && if npm run | grep -q 'test'; then npm test --silent; else echo 'no tests'; fi
Output: npm error A complete log of this run can be found in: /root/.npm/_logs/2026-05-16T09_39_04_728Z-debug-0.log
sh: ./node_modules/.bin/mocha: not foundFROM node:22.22.3-alpine3.23 AS builder
WORKDIR /app
# Copy manifests and install dependencies in builder stage
COPY package.json package-lock.json ./
RUN apk add --no-cache --virtual .build-deps python3 g++ make \
&& npm ci \
&& npm run build --if-present \
&& npm prune --production \
&& apk del .build-deps
# Copy the rest of the source code
COPY . .
# Final runtime image
FROM node:22.22.3-alpine3.23
WORKDIR /app
# Copy built artifacts from builder
COPY --from=builder /app /app
ENV NODE_ENV=production
# Healthcheck to verify the library can be required at runtime
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 CMD node -e 'try { require("./lib"); console.log("health ok"); } catch(e) { process.exit(1); }'
# Simple startup message; this image is a library
CMD ["node","-e","console.log('passport-jwt image ready')"]
Concerns: No obvious issues; the Dockerfile uses a multi-stage build, builds dependencies, prunes dev deps, and provides a healthcheck that validates requiring the library at runtime.
Smoke [FAIL]: docker run --rm --entrypoint "" <image> sh -c "node -e 'try { require(\"./lib\"); console.log(\"health ok\"); } catch(e) { process.exit(1); }
Output: sh: syntax error: unterminated quoted string
Smoke [FAIL]: docker run --rm --entrypoint "" <image> sh -c "node -e 'const lib=require(\"./lib\"); if (!lib) { process.exit(1); } console.log(\"ok\");
Output: sh: syntax error: unterminated quoted string
Smoke [FAIL]: docker run --rm --entrypoint "" <image> sh -c "node -e 'const lib=require(\"./lib\"); const ok = (typeof lib === \"object\" && lib.Strategy) || typeof lib === \"function\"; if (!ok) { process.exit(1); } console.log(\"ok\");
Output: sh: syntax error: unterminated quoted stringFROM node:22.22.3-alpine3.23
WORKDIR /app
# Copy manifests and install dependencies first (for caching)
COPY package.json package-lock.json ./
RUN apk add --no-cache --virtual .build-deps python3 g++ make \
&& npm ci \
&& npm run build --if-present \
&& npm prune --production \
&& apk del .build-deps
# Copy the rest of the source code
COPY . .
ENV NODE_ENV=production
# Basic script to verify runtime can require the library
CMD ["node","-e","console.log('passport-jwt image ready')"]
Concerns: The final CMD only prints a readiness message and does not perform a runtime verification of the library's functionality., If passport-jwt has no native modules, build dependencies may be unnecessary; consider slimming the image if possible., FROM node:22.x-alpine may have compatibility considerations; verify that this Node version is still supported for your target deployments.
Smoke [FAIL]: node -e \"const passportJWT = require('passport-jwt'); const {Strategy, ExtractJwt} = passportJWT; const opts = { jwtFromRequest: ExtractJwt.fromAuthHeaderAsBearerToken(), secretOrKey: 'secret' }; const strat = new Strategy(opts, (payload, done) => done(null, payload)); console.log('ok')\
Output: sh: syntax error: unexpected "("FROM node:22.22.3-alpine3.23 AS builder
WORKDIR /app
# Install dependencies and build in builder stage
COPY package.json package-lock.json ./
RUN apk add --no-cache --virtual .build-deps python3 g++ make \
&& npm ci \
&& npm run build --if-present \
&& npm prune --production \
&& apk del .build-deps
# Copy the rest of the source code
COPY . .
# Final runtime image
FROM node:22.22.3-alpine3.23
WORKDIR /app
# Copy built artifacts from builder
COPY --from=builder /app /app
ENV NODE_ENV=production
# Healthcheck script to verify runtime can require the library
RUN /bin/sh -c 'cat > /healthcheck.js << "JS"\ntry { require("./lib"); console.log("health ok"); } catch(e) { process.exit(1); }\nJS'
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 CMD ["node","/healthcheck.js"]
# Basic startup message; this image is a library
CMD ["node","-e","setInterval(()=>{},60000);"]
- Failing step (command): [stage-1 4/4] RUN /bin/sh -c 'cat > /healthcheck.js << "JS"\ntry { require("./lib"); console.log("health ok"); } catch(e) { process.exit(1); }\nJS'
- Exact error message and exit code:
- /bin/sh: syntax error: unexpected "("
- The final failure line: ERROR: failed to build: failed to solve: process "/bin/sh -c /bin/sh -c 'cat > /healthcheck.js << \"JS\"\\ntry { require(\"./lib\"); console.log(\"health ok\"); } catch(e) { process.exit(1); }\\nJS'" did not complete successfully: exit code: 2
- Missing packages or files mentioned: None explicitly; error is a shell syntax error during here-doc creation of /healthcheck.js, not a missing dependency/file.
- Version/mismatch info:
- Base image used: node:22.22.3-alpine3.23 (sha256:968df39aedcea65eeb078fb336ed7191baf48f972b4479711397108be0966920)
- No explicit version mismatch noted beyond the image tag/sha.# Multi-stage Dockerfile to build passport-jwt from source and run a lightweight container
# Builder stage: install dependencies, build the project, prune dev dependencies
FROM node:22.22.3-alpine3.23 as builder
WORKDIR /app
# Install build tools (only used for native modules or building if present)
RUN apk add --no-cache --virtual .build-deps python3 make g++
# Copy package manifests first to leverage Docker cache
COPY package.json package-lock.json ./
# Install dependencies (use npm ci when lockfile is present)
RUN npm ci --lean || npm install
# Copy the rest of the source code
COPY . .
# Build from source if a build script is present
RUN npm run build --if-present
# Prune production dependencies to minimize image size
RUN npm prune --production
# Remove build dependencies
RUN apk del .build-deps
# Final stage
FROM node:22.22.3-alpine3.23
WORKDIR /app
# Copy the built artifacts and production dependencies from builder
COPY --from=builder /app /app
# Healthcheck to ensure the built library is usable
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s CMD node -e "try { require('./lib/index.js'); console.log('passport-jwt healthy'); } catch (e) { console.error(e); process.exit(1); }"
# Default command: keep the container alive and echo a startup message.
# This container is a library; we provide a minimal, non-intrusive entrypoint
# so that a consumer can run the library or simply verify it loads.
CMD ["node","-e","console.log('passport-jwt container started'); setInterval(()=>{}, 1000);"]
node_modules build coverage dist .dockerignore Dockerfile .package-lock.json
Smoke [FAIL]: docker run --rm --entrypoint "" <image> sh -c "node -e \"const assert=require('assert'); const { Strategy, ExtractJwt } = require('passport-jwt'); const s = new Strategy({ jwtFromRequest: ExtractJwt.fromAuthHeaderAsBearerToken(), secretOrKey: 'test' }, (payload, done) => { done(null, payload); }); assert(!!s); console.log('ok')\
Output: sh: syntax error: unterminated quoted string
Smoke [FAIL]: docker run --rm --entrypoint "" <image> sh -c "node -e \"const assert=require('assert'); const { ExtractJwt } = require('passport-jwt'); const extractor = ExtractJwt.fromAuthHeaderAsBearerToken(); assert(typeof extractor === 'function'); console.log('ok')\
Output: sh: syntax error: unterminated quoted string# Multi-stage Dockerfile to build passport-jwt from source and run a lightweight container
FROM node:22.22.3-alpine3.23 as builder
WORKDIR /app
# Install build tools (needed for native modules or optional build steps)
RUN apk add --no-cache --virtual .build-deps python3 make g++
# Copy package manifests first to leverage Docker layer caching
COPY package.json package-lock.json ./
# Install dependencies; prefer npm ci when lockfile is present
RUN npm ci --silent || npm install --silent
# Copy the rest of the source code
COPY . .
# Build from source if a build script is present
RUN npm run build --if-present
# Prune production dependencies to minimize image size
RUN npm prune --production
# Remove build tools
RUN apk del .build-deps
# Final stage: runtime image
FROM node:22.22.3-alpine3.23
WORKDIR /app
# Copy built artifacts and production dependencies from builder
COPY --from=builder /app /app
# Healthcheck to ensure the built library is usable
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s CMD node -e 'try { require("./lib/index.js"); console.log("passport-jwt healthy"); } catch (e) { console.error(e); process.exit(1); }'
# Default command: provide a harmless startup message; the consumer can override as needed
CMD ["node","-e","console.log('passport-jwt container started'); setInterval(()=>{}, 1000);"]
Concerns: Healthcheck assumes the built artifact provides lib/index.js at runtime (requires('./lib/index.js')). If the library's main entry differs, the healthcheck may fail., Final image copies /app from builder; if build outputs are placed under a different path (e.g., lib/index.js not generated), healthcheck and runtime require may fail.
Smoke [FAIL]: node -e \"const m=require('./lib/index.js'); const ok = (typeof m.Strategy === 'function') || (typeof m.JwtStrategy === 'function'); if(!ok){ console.error('missing Strategy export'); process.exit(1);} console.log('ok')\
Output: sh: syntax error: unexpected "("
Smoke [FAIL]: node -e \"const lib=require('./lib/index.js'); const Strategy = lib.Strategy || lib.JwtStrategy; if(typeof Strategy !== 'function'){ console.error('missing Strategy'); process.exit(1);} const strat = new Strategy({secretOrKey:'secret'}, function(payload, done){ done(null, true); }); console.log('strategy constructed')\
Output: sh: syntax error: unexpected "("# Multi-stage Dockerfile to build passport-jwt from source and run a lightweight container
# Builder stage: install dependencies, build the project, prune dev dependencies
FROM node:22.22.3-alpine3.23 as builder
WORKDIR /app
# Install build tools (needed for native modules or optional build steps)
RUN apk add --no-cache --virtual .build-deps python3 make g++
# Copy package manifests first to leverage Docker layer caching
COPY package.json package-lock.json ./
# Install dependencies; prefer npm ci when lockfile is present
RUN npm ci --silent || npm install --silent
# Copy the rest of the source code
COPY . .
# Build from source if a build script is present
RUN npm run build --if-present
# Prune production dependencies to minimize image size
RUN npm prune --production
# Remove build tools
RUN apk del .build-deps
# Final stage: runtime image (Debian-based for compatibility with smoke tests)
FROM node:22-slim
WORKDIR /app
# Copy built artifacts and production dependencies from builder
COPY --from=builder /app /app
# Healthcheck to ensure the built library is usable
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s CMD node -e 'try { require("./lib/index.js"); console.log("passport-jwt healthy"); } catch (e) { console.error(e); process.exit(1); }'
# Default command: provide a harmless startup message; the consumer can override as needed
CMD ["node","-e","console.log('passport-jwt container started'); setInterval(()=>{}, 1000);"]
Concerns: Healthcheck path assumes built artifacts exist at ./lib/index.js; if the build output changes (e.g., different entry point), the healthcheck may fail, The final image uses node:22-slim; ensure this aligns with CI smoke environment and any native modules compiled during build
Smoke [FAIL]: node -e \"try { const { ExtractJwt } = require('./lib/index.js'); const extractor = ExtractJwt.fromAuthHeaderAsBearerToken(); if (typeof extractor === 'function') { const token = extractor({ headers: { authorization: 'Bearer mytoken' }}); console.log(token === 'mytoken' ? 'ok' : 'unexpected'); process.exit(token === 'mytoken' ? 0 : 1); } else { console.error('Extractor is not a function'); process.exit(1); } } catch (e) { console.error(e); process.exit(1); }\
Output: sh: 1: Syntax error: "(" unexpected
Smoke [FAIL]: node -e \"try { const { ExtractJwt } = require('./lib/index.js'); const extractor = ExtractJwt.fromAuthHeaderAsBearerToken(); const token = extractor({ headers: {} }); console.log(token === undefined ? 'ok' : 'unexpected'); process.exit(token === undefined ? 0 : 1); } catch (e) { console.error(e); process.exit(1); }\
Output: sh: 1: Syntax error: "(" unexpected# Simple single-stage Dockerfile for passport-jwt
FROM node:22.22.3-alpine3.23
WORKDIR /app
# Install runtime dependencies (production only)
COPY package.json package-lock.json ./
RUN npm ci --production
# Copy the source
COPY . .
# Basic healthcheck to ensure the package exports correctly
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s CMD node -e "try { require('./lib/index.js'); console.log('passport-jwt healthy'); } catch (e) { console.error(e); process.exit(1); }"
# Default command is a harmless placeholder; the smoke tests override entrypoint anyway
CMD ["node","-e","console.log('passport-jwt container started'); setInterval(()=>{}, 1000);"]
Smoke [FAIL]: docker run --rm --entrypoint "" <image> sh -c "node -e \"try { const m = require('./lib/index.js'); const ok = (typeof m === 'function') || (m && typeof m.Strategy === 'function'); if(!ok){ console.error('export test failed'); process.exit(1);} console.log('ok'); } catch (e) { console.error(e); process.exit(1); }\
Output: sh: syntax error: unterminated quoted string
Smoke [FAIL]: docker run --rm --entrypoint "" <image> sh -c "node -e \"try { const jwt = require('jsonwebtoken'); const t = jwt.sign({sub: 'smoketest'}, 'secret'); if (typeof t !== 'string' || t.length < 10) { console.error('token gen failed'); process.exit(1);} console.log('ok'); } catch (e) { console.error(e); process.exit(1);} \
Output: sh: syntax error: unterminated quoted stringtry {
require('./lib/index.js');
console.log('healthy');
} catch (e) {
console.error(e);
process.exit(1);
}
# Simple single-stage Dockerfile for passport-jwt
FROM node:22.22.3-alpine3.23
WORKDIR /app
# Install runtime dependencies (production only)
COPY package.json package-lock.json ./
RUN npm ci --production
# Copy the source
COPY . .
# A lightweight healthcheck script executed via node to verify exports
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s CMD node healthcheck.js
# Default command is a harmless placeholder; the smoke tests override entrypoint anyway
CMD ["node","-e","console.log('passport-jwt container started'); setInterval(()=>{}, 1000);"]
Concerns: No explicit build step present: the image only runs npm ci --production and copies source, which does not perform a build/bundle of the source code. The requirement asks to build the application from source (beyond installing runtime dependencies)., Healthcheck relies on a file healthcheck.js; if that file is not present in the repo, the healthcheck will fail at runtime. There is no guarantee from the Dockerfile alone that a build or test step is executed., Using production-only npm ci may omit dev/test dependencies that could be needed during a build or smoke test.
# Multi-stage Dockerfile to build passport-jwt from source and run a lightweight container
# Builder stage: install dependencies, build the project, prune dev dependencies
FROM node:22.22.3-alpine3.23 as builder
WORKDIR /app
# Install build tools (needed for native modules or optional build steps)
RUN apk add --no-cache --virtual .build-deps python3 make g++
# Copy package manifests first to leverage Docker layer caching
COPY package.json package-lock.json ./
# Install dependencies; use npm ci if lockfile is present
RUN npm ci
# Copy the rest of the source code
COPY . .
# Build from source if a build script is present
RUN npm run build --if-present
# Prune production dependencies to minimize image size
RUN npm prune --production
# Remove build tools
RUN apk del .build-deps
# Final stage: runtime image (Alpine-based Node.js)
FROM node:22.22.3-alpine3.23
WORKDIR /app
# Copy built artifacts and production dependencies from builder
COPY --from=builder /app /app
# Healthcheck to ensure the built library is usable
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s CMD node -e 'try { require("./lib/index.js"); console.log("passport-jwt healthy"); } catch (e) { console.error(e); process.exit(1); }'
# Default command is a harmless placeholder; the smoke tests override entrypoint when needed
CMD ["node","-e","console.log('passport-jwt container started'); setInterval(()=>{}, 1000);"]
Concerns: Healthcheck path depends on lib/index.js existing; if the build outputs to dist or a different path, healthcheck may fail., If the repository changes how artifacts are built (e.g., lib/index.js moved), the healthcheck may need adjustment.
Smoke [FAIL]: node -e 'try { const m = require("\./lib/index.js"); if (m) { console.log("SMOKE_OK"); process.exit(0); } else { console.error("no export"); process.exit(1); } } catch (e) { console.error(e); process.exit(1); }
Output: sh: syntax error: unterminated quoted string
Smoke [FAIL]: node -e 'try { const lib = require("\./lib/index.js"); if (lib && typeof lib === "object") { console.log("HEALTH_OK"); } else { console.error("EXPORT_NOT_OBJECT"); process.exit(1); } } catch (e) { console.error(e); process.exit(1); }
Output: sh: syntax error: unterminated quoted string# Multi-stage build using a Debian-based node image for compatibility
FROM node:22-bullseye-slim AS builder
WORKDIR /app
# Install build tools if native modules are present
RUN apt-get update \
&& apt-get install -y --no-install-recommends python3 make g++ \
&& rm -rf /var/lib/apt/lists/*
COPY package.json package-lock.json ./
# Install dependencies; prefer npm ci when lockfile is present
RUN if [ -f package-lock.json ]; then npm ci --silent; else npm install --silent; fi
# Copy the rest of the source
COPY . .
# Build from source if a build script is present
RUN npm run build --if-present
# Prune devDependencies to production only
RUN npm prune --production
# Final runtime stage
FROM node:22-bullseye-slim
WORKDIR /app
COPY --from=builder /app /app
# Healthcheck to verify build artifacts are loadable
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s CMD node healthcheck.js
# Default command (smoke tests override entrypoint)
CMD ["node","-e","console.log('passport-jwt container started'); setInterval(()=>{}, 1000);"]
Smoke [FAIL]: node -e 'const {Strategy, ExtractJwt} = require("passport-jwt"); console.assert(typeof Strategy === "function"); console.assert(typeof ExtractJwt.fromAuthHeaderAsBearerToken() === "function"); console.log("ok");
Output: sh: 1: Syntax error: Unterminated quoted string
Smoke [FAIL]: node -e 'const p=require("passport-jwt/package.json"); console.assert(!!p.version && p.version.length>0); console.log("ok");
Output: sh: 1: Syntax error: Unterminated quoted string# Multi-stage build to compile passport-jwt from source and package the result
FROM node:22.22.3-alpine3.23 as builder
WORKDIR /app
# Install build tools for native modules if needed
RUN apk add --no-cache --virtual .build-deps python3 make g++
# Install dependencies first to leverage caching
COPY package.json package-lock.json ./
RUN npm ci
# Copy the rest of the source and build if needed
COPY . .
RUN npm run build --if-present
# Prune dev dependencies for the final image
RUN npm prune --production
# Remove build tools to minimize image size
RUN apk del .build-deps
# Final runtime image
FROM node:22.22.3-alpine3.23
WORKDIR /app
# Copy built artifacts and prod deps from builder
COPY --from=builder /app /app
# Healthcheck using a small script that validates the library exports
COPY healthcheck.js ./healthcheck.js
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s CMD node healthcheck.js
# Default command (smoke tests override entrypoint)
CMD ["node","-e","console.log('passport-jwt container started'); setInterval(()=>{}, 1000);"]
Smoke [FAIL]: docker run --rm --entrypoint '' <image> sh -lc "node -e 'try { const m = require(\\"passport-jwt\\"); const ok = m && ((typeof m.Strategy === \\\"function\\\") || (m.ExtractJwt && typeof m.ExtractJwt.fromAuthHeaderAsBearerToken === \\\"function\\\")); console.log(ok ? \\\"ok\\\" : \\\"not_ok\\\"); process.exit(ok?0:1); } catch (e) { console.error(e); process.exit(1); }
Output: sh: syntax error: unterminated quoted string
Smoke [FAIL]: docker run --rm --entrypoint '' <image> sh -lc "node healthcheck.js >/tmp/health.log 2>&1; if [ $? -eq 0 ]; then echo health_ok; else echo health_fail; fi
Output: sh: syntax error: unterminated quoted string