Skip to content

Latest commit

 

History

History
68 lines (47 loc) · 2.64 KB

PATCHES.md

File metadata and controls

68 lines (47 loc) · 2.64 KB

Patches

A patch raises a dependency of OpenCode with a known vulnerability in the image, before OpenCode releases an update.

Rules

  • Alpine and its packages need no patch. Bump their pins in src/Dockerfile and release a patch version of the image
  • Bun needs no patch either, OpenCode names the version it is built with and the image follows it
  • Patch a dependency of OpenCode only for a known vulnerability, once the version that fixes it is released
  • A patch raises a dependency within its major version, the copies of another major in bun.lock stay as they are
  • Drop a dependency from the patch once an OpenCode release requires the fixed version
  • Never patch the code of OpenCode, its fixes come with its releases

Package managers

Every package manager runs in the image of its ARG in src/Dockerfile, nothing is installed locally. pnpm and Yarn run in the version that packageManager in package.json names.

Lockfile Package manager ARG in src/Dockerfile
go.mod Go GO_IMAGE
Cargo.lock Cargo RUST_IMAGE
composer.lock Composer COMPOSER_IMAGE
package-lock.json npm NODE_IMAGE
pnpm-lock.yaml pnpm 10 or later NODE_IMAGE
yarn.lock Yarn NODE_IMAGE
bun.lock Bun BUN_IMAGE
aube-lock.yaml aube AUBE_IMAGE

Add a patch

  1. Raise the dependency to the version that fixes it, several at once if needed:

    scripts/patch-dependencies.sh hono@4.12.9
  2. Build the image and test it:

    scripts/build.sh && scripts/test.sh peakimages/opencode:local
  3. Commit src/patches/dependencies.patch and release a patch version of the image

Update OpenCode with a patch

The build workflow runs scripts/patch-dependencies.sh --check before it builds. It fails when the pinned OpenCode requires a raised dependency itself, or when the patch no longer applies. On the branch of the pull request that bumps OpenCode, manually write the patch again for the new release. It drops every dependency the release raises itself, and the whole file once none is left:

scripts/patch-dependencies.sh

Important

A patch that no longer applies stops the build.

Remove a patch

Drop one dependency:

scripts/patch-dependencies.sh --remove hono

Drop all of them:

scripts/patch-dependencies.sh --remove