diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d3b9475..2f17c95 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -395,6 +395,10 @@ build:api-check: 'import("@anthropic-ai/claude-agent-sdk").then(()=>{console.error("AI runtime present in the published image -- the last Dockerfile stage is no longer the runtime-free one");process.exit(1)},()=>process.exit(0))' ! docker run --rm opengym-api:published codex --version 2>/dev/null ! docker run --rm opengym-api:published bwrap --version 2>/dev/null + # npm is stripped from the published image (see api/Dockerfile) — its bundled tree was + # the only source of scanner findings, and nothing at runtime needs it. + ! docker run --rm opengym-api:published npm --version 2>/dev/null + ! docker run --rm opengym-api:published test -d /usr/local/lib/node_modules/npm docker run --rm opengym-api:published node --input-type=module -e ' const { adapterFor } = await import("./coach/adapters/index.js"); for (const id of ["anthropic", "openai", "gemini", "compatible"]) { @@ -556,11 +560,11 @@ build:apk: set -eu cd "$CI_PROJECT_DIR" . ./apk.env + # Sideloading means nobody's app store checked this file for you, so publish the + # digest next to it rather than leaving people to trust the download. Written for + # every build (branch artifacts too), uploaded only from a release tag. + for apk in openGym-*.apk; do sha256sum "$apk" > "$apk.sha256"; cat "$apk.sha256"; done if [ -n "${CI_COMMIT_TAG:-}" ] && [ -f "openGym-$APK_VERSION.apk" ]; then - # Sideloading means nobody's app store checked this file for you, so publish the - # digest next to it rather than leaving people to trust the download. - sha256sum "openGym-$APK_VERSION.apk" > "openGym-$APK_VERSION.apk.sha256" - cat "openGym-$APK_VERSION.apk.sha256" echo "APK_SHA256=$(cut -d' ' -f1 "openGym-$APK_VERSION.apk.sha256")" >> apk.env for f in "openGym-$APK_VERSION.apk" "openGym-$APK_VERSION.apk.sha256"; do curl --fail --silent --show-error \ diff --git a/api/Dockerfile b/api/Dockerfile index 92f187f..90a1199 100644 --- a/api/Dockerfile +++ b/api/Dockerfile @@ -31,6 +31,11 @@ LABEL maintainer="Duarte Santos https://gitlab.com/DuarteSantos8" \ WORKDIR /app +# The base image is rebuilt on node's schedule, not alpine's: between two node releases the +# alpine packages it ships (openssl above all) fall behind their fixes. Taking the upgrades at +# build time keeps the published image at alpine's current state without waiting for node. +RUN apk upgrade --no-cache + # The unprivileged user Coach jobs drop to. Its uid cannot read /data, which is the control that # keeps a provider runtime away from users, passkeys and the session secret. # @@ -82,3 +87,8 @@ VOLUME ["/coach-auth"] # --------------------------------------------------------------------------------------------- # Last, so that a plain `docker build ./api` keeps producing the runtime-free image. FROM base AS default +# npm itself is only a build-time tool here: the server is started with `node server.js` and +# nothing in it spawns npm. Its bundled dependency tree (tar, brace-expansion, ...) is where +# every vulnerability the image scan ever reported lived — none of them was in a package the +# app uses. Gone from the published image; the coach target keeps npm for the Codex CLI. +RUN rm -rf /usr/local/lib/node_modules/npm /usr/local/bin/npm /usr/local/bin/npx diff --git a/web/Dockerfile b/web/Dockerfile index 1e2f8eb..20978ff 100644 --- a/web/Dockerfile +++ b/web/Dockerfile @@ -23,6 +23,8 @@ COPY frontend/ ./ RUN npm run build FROM nginx:alpine +# Same reason as in api/Dockerfile: alpine fixes land faster than the nginx image is rebuilt. +RUN apk upgrade --no-cache ARG VERSION=dev ARG VCS_REF=dev ARG BUILD_DATE=unknown