FROM node:16-slim WORKDIR /app # Install dependencies and build tools will be handled via npm ci # Copy package manifests first for efficient caching COPY package.json package-lock.json ./ RUN npm ci # Copy the rest of the repository COPY . . # Build the project from source (generate lib/jsonlint.js and web/jsonlint.js) RUN make build # Expose no ports; this container is primarily a CLI tool # Use the jsonlint CLI by default ENTRYPOINT ["node", "lib/cli.js"]
node_modules .git .tmp .DS_Store *.log
- Exact error message and exit code ERROR: failed to build: failed to solve: process "/bin/sh -c npm ci" did not complete successfully: exit code: 1 - Failing command/step [4/6] RUN npm ci (Dockerfile:9) - Missing packages or files mentioned (from lock file) - @gerhobbelt/nomnom@1.8.4-31 - @gerhobbelt/linewrap@0.2.2-3 - chalk@4.1.0 - exit@0.1.2 - ansi-styles@4.3.0 - supports-color@7.2.0 - has-flag@4.0.0 - color-convert@2.0.1 - color-name@1.1.4 - Version mismatch info - New major version of npm available! 8.19.4 -> 11.12.0 - Run "npm install -g npm@11.12.0" to update! - npm ERR! code EUSAGE - npm ERR! `npm ci` can only install packages when your package.json and package-lock.json or npm-shrinkwrap.json are in sync. Please update your lock file with `npm install` before continuing.
FROM node:16-slim WORKDIR /app # Install dependencies (including devDependencies) to be able to build from source COPY package.json package-lock.json ./ RUN npm install # Copy the rest of the repository COPY . . # Build the project from source (generate lib/jsonlint.js and web/jsonlint.js) RUN make build # Use the jsonlint CLI by default ENTRYPOINT ["node", "lib/cli.js"]
Concerns: Build environment is incomplete: the image installs dependencies and runs 'make build' but does not install build tools (e.g., apt-get update and build-essential). Without make/gcc, the build will fail., Unclear whether lib/cli.js is produced by the build step; relying on a pre-existing lib/cli.js or generating it only via build may cause runtime issues if the output is not produced as expected.
all: build test site build: ./node_modules/jison/lib/cli.js src/jsonlint.y src/jsonlint.l mv jsonlint.js lib/jsonlint.js node scripts/bundle.js | ./node_modules/uglify-js/bin/uglifyjs > web/jsonlint.js site: cp web/jsonlint.js ../jsonlint-pages/jsonlint.js deploy: site cd ../jsonlint-pages && git commit -a -m 'deploy site updates' && git push origin gh-pages test: lib/jsonlint.js test/all-tests.js node test/all-tests.js
package.json
{
"author": "Zach Carter <zach@carter.name> (http://zaa.ch)",
"name": "jsonlint",
"description": "Validate JSON",
"keywords": [
"json",
"validation",
"lint",
"jsonlint"
],
"version": "1.6.3",
"license": "MIT",
"preferGlobal": true,
"repository": {
"type": "git",
"url": "git://github.com/zaach/jsonlint.git"
},
"bugs": {
"url": "http://github.com/zaach/jsonlint/issues"
},
"main": "lib/jsonlint.js",
"bin": {
"jsonlint": "lib/cli.js"
},
"engines": {
"node": ">= 0.6"
},
"dependencies": {
"@gerhobbelt/nomnom": "^1.8.4-27",
"JSV": "^4.0.x"
},
"devDependencies": {
"test": "*",
"jison": "*",
"uglify-js": "*"
},
"scripts": {
"test": "node test/all-tests.js"
},
"homepage": "http://zaach.github.com/jsonlint/",
"optionalDependencies": {}
}
FROM node:16-slim
# Install build tools required for building from source
RUN apt-get update && \
apt-get install -y --no-install-recommends build-essential && \
rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Copy manifest files first for efficient caching
COPY package.json package-lock.json ./
RUN npm install
# Copy rest of the repository
COPY . .
# Build the project from source (generate lib/jsonlint.js and web/jsonlint.js)
RUN make build
# Default to running the jsonlint CLI
ENTRYPOINT ["node", "lib/cli.js"]
- Failing step - [2/7] RUN apt-get update && apt-get install -y --no-install-recommends build-essential && rm -rf /var/lib/apt/lists/* - Exact error message and exit code - ERROR: failed to build: failed to solve: process "/bin/sh -c apt-get update && apt-get install -y --no-install-recommends build-essential && rm -rf /var/lib/apt/lists/*" did not complete successfully: exit code: 100 - E: The repository 'http://deb.debian.org/debian buster Release' does not have a Release file. - E: The repository 'http://deb.debian.org/debian-security buster/updates Release' does not have a Release file. - E: The repository 'http://deb.debian.org/debian buster-updates Release' does not have a Release file. - Missing packages or files mentioned - Release files for Debian sources are missing (Debian buster repositories no longer provide Release files), causing apt-get update to fail before install of build-essential. - Version mismatch / root cause - The base image is using Debian buster (Debian 10) repositories, which are end-of-life and no longer provide Release files. This prevents apt-get from updating/installing. Recommend using a newer Debian base (e.g., bullseye/bookworm) or updating the base image variant (node:16-slim with a current Debian) or adjusting apt sources.
FROM node:16-bullseye-slim
# Install build tools required for building from source
RUN apt-get update && \
apt-get install -y --no-install-recommends build-essential python3 && \
rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Copy manifest files first for efficient caching
COPY package.json package-lock.json ./
RUN npm install
# Copy rest of the repository
COPY . .
# Build the project from source (generate lib/jsonlint.js and web/jsonlint.js)
RUN make build
# Default to running the jsonlint CLI
ENTRYPOINT ["node", "lib/cli.js"]
Smoke [PASS]: test -f /app/lib/cli.js Smoke [PASS]: node /app/lib/cli.js --help Smoke [PASS]: test -f /app/lib/jsonlint.js && test -f /app/web/jsonlint.js