Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
165 changes: 90 additions & 75 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
@@ -1,100 +1,115 @@
name: CI/CD

on:
push:
branches:
- master
branches: [master]
pull_request:
workflow_dispatch:
schedule:
- cron: '0 0 * * 0'

permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
checks:
runs-on: ubuntu-24.04
outputs:
tags: ${{ steps.tags.outputs.tags }}
steps:
- uses: actions/checkout@v7
- name: Check generated contexts and architecture selection
run: |
docker run --rm -v "$PWD:/app" fireworkweb/fwd:v1.0 fwd template
git diff --exit-code
bash tests/architecture.sh
- id: tags
run: echo "tags=$(jq -c '[.builds[].name] + [\"24-nginx\"]' fwd-template.json)" >> "$GITHUB_OUTPUT"
build:
needs: checks
runs-on: ${{ matrix.platform.runner }}
strategy:
fail-fast: false
matrix:
version: [22, 24, 26]
runs-on: [ubuntu-24.04, ubuntu-24.04-arm]
runs-on: ${{ matrix.runs-on }}

version: ["22", "24", "26"]
platform:
- {arch: amd64, runner: ubuntu-24.04}
- {arch: arm64, runner: ubuntu-24.04-arm}
steps:
- name: Checkout code
uses: actions/checkout@v6

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Check generated contexts and architecture selection
run: |
python3 tests/generated.py
sh tests/architecture.sh

- name: Compute cache week
id: cachekey
run: echo "week=$(date -u +%Y-%V)" >> "$GITHUB_OUTPUT"

- name: Cache Docker layers
uses: actions/cache@v5
- uses: actions/checkout@v7
- uses: kool-dev/action/image-build@6a6d04e8d1e1c66afc178e32c7d77d76169c7717
with:
arch: ${{ matrix.platform.arch }}
- name: Build fresh base
id: base
uses: docker/build-push-action@v7
with:
path: /tmp/.buildx-cache
key: docker-buildx-${{ matrix.runs-on }}-${{ matrix.version }}-${{ steps.cachekey.outputs.week }}-${{ github.sha }}
restore-keys: docker-buildx-${{ matrix.runs-on }}-${{ matrix.version }}-${{ steps.cachekey.outputs.week }}-

- name: Build
context: ${{ matrix.version }}
platforms: linux/${{ matrix.platform.arch }}
pull: true
load: true
provenance: false
tags: kooldev/node:${{ matrix.version }}
- name: Test base
env:
IMAGE: ${{ steps.base.outputs.imageid }}
run: bash tests/image.sh "$IMAGE"
- name: Build nginx from this job's Node 24
if: matrix.version == '24'
id: nginx
uses: docker/build-push-action@v7
with:
context: 24-nginx
build-args: NODE_IMAGE=kooldev/node:24
platforms: linux/${{ matrix.platform.arch }}
load: true
provenance: false
tags: kooldev/node:24-nginx
- uses: kool-dev/action/image-parent@6a6d04e8d1e1c66afc178e32c7d77d76169c7717
if: matrix.version == '24'
with:
base-ref: kooldev/node:24
base-id: ${{ steps.base.outputs.imageid }}
image-id: ${{ steps.nginx.outputs.imageid }}
- name: Test nginx
if: matrix.version == '24'
env:
IMAGE: ${{ steps.nginx.outputs.imageid }}
run: |
docker buildx build \
--pull \
--cache-from type=local,src=/tmp/.buildx-cache/${{ matrix.version }} \
--cache-to type=local,dest=/tmp/.buildx-cache/${{ matrix.version }} \
--output type=docker \
--tag "kooldev/node:${{ matrix.version }}-$(arch)" \
${{ matrix.version }}

- name: Tests
run: sh tests/image.sh "kooldev/node:${{ matrix.version }}-$(arch)"

# Use the Docker engine's loaded, freshly tested parent, not yesterday's Hub tag.
- name: Build and test nginx from this run's Node 24
if: matrix.version == 24
bash tests/image.sh "$IMAGE"
docker run --rm "$IMAGE" nginx -t
- name: Collect tested IDs
id: images
env:
VERSION: ${{ matrix.version }}
BASE_ID: ${{ steps.base.outputs.imageid }}
NGINX_ID: ${{ steps.nginx.outputs.imageid }}
run: |
docker build --builder default --pull=false \
--build-arg "NODE_IMAGE=kooldev/node:24-$(arch)" \
--tag "kooldev/node:24-nginx-$(arch)" 24-nginx
sh tests/image.sh "kooldev/node:24-nginx-$(arch)"
docker run --rm "kooldev/node:24-nginx-$(arch)" nginx -t

- name: Login to DockerHub
uses: docker/login-action@v3
images=$(jq -cn --arg version "$VERSION" --arg bid "$BASE_ID" --arg nid "$NGINX_ID" \
'[{tag:$version,id:$bid}] + if $nid == "" then [] else [{tag:"24-nginx",id:$nid}] end')
echo "images=$images" >> "$GITHUB_OUTPUT"
- uses: kool-dev/action/image-stage@6a6d04e8d1e1c66afc178e32c7d77d76169c7717
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/master' && github.repository == 'kool-dev/docker-node'
with:
canonical-repository: kool-dev/docker-node
default-branch: master
repository: kooldev/node
arch: ${{ matrix.platform.arch }}
group: ${{ matrix.version }}
images: ${{ steps.images.outputs.images }}
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Push to DockerHub
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/master' && github.repository == 'kool-dev/docker-node'
run: |
docker push "kooldev/node:${{ matrix.version }}-$(arch)"
if [ "${{ matrix.version }}" = "24" ]; then
docker push "kooldev/node:24-nginx-$(arch)"
fi

amend:
publish:
needs: [checks, build]
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/master' && github.repository == 'kool-dev/docker-node'
needs: build
runs-on: ubuntu-24.04
strategy:
matrix:
version: [22, 24, 24-nginx, 26]

steps:
- uses: docker/login-action@v3
- uses: kool-dev/action/image-publish@6a6d04e8d1e1c66afc178e32c7d77d76169c7717
with:
canonical-repository: kool-dev/docker-node
default-branch: master
repository: kooldev/node
tags: ${{ needs.checks.outputs.tags }}
architecture-aliases: true
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- run: |
docker manifest create kooldev/node:${{ matrix.version }} \
--amend kooldev/node:${{ matrix.version }}-x86_64 \
--amend kooldev/node:${{ matrix.version }}-aarch64

docker manifest push kooldev/node:${{ matrix.version }}
21 changes: 19 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,28 @@ pnpm-only or removed `scripts-prepend-node-path` options in `.npmrc`.
With current pnpm, hoisting policy belongs in the project's
`pnpm-workspace.yaml`; set `shamefullyHoist: true` there if required.

Run `python3 tests/generated.py` and `sh tests/architecture.sh` to check
generated contexts and download selection. After building an image, run
Run `docker run --rm -v "$PWD:/app" fireworkweb/fwd:v1.0 fwd template`,
`git diff --exit-code`, and `bash tests/architecture.sh` to check
generated contexts and download selection with the real template engine. After building an image, run
`sh tests/image.sh IMAGE` to exercise dockerize, npm, yarn, pnpm, config
resolution and ownership as root and two remapped user IDs.

### Shared native publication

CI uses [shared Bash/`jq` actions](https://github.com/kool-dev/action/blob/master/image-ci.md),
pinned in the workflow. Native amd64/arm64 jobs build/test once. Node 24
NGINX inherits this job's tested Node parent, verified by ID and layer ancestry.
The old per-run local Buildx cache export is replaced by the common Docker
driver so derived images resolve fresh local parents consistently.

Only trusted `master` releases stage tested IDs under run/attempt-scoped tags.
One publisher validates all four stable tags × both architectures before stable
updates. Historical `-x86_64`/`-aarch64` tags remain compatibility aliases, but
are updated only after the full native matrix succeeds. PRs/forks/feature branches
cannot log in or publish. Release runs serialize; only PR runs are canceled.
On failure, rerun **all jobs**: no previous-attempt metadata is reused and there
is no resume workflow. Stable updates are not atomic across tags.

### Updating images and building locally

> You must have [`kool`](https://github.com/kool-dev/kool) installed.
Expand Down
21 changes: 0 additions & 21 deletions tests/generated.py

This file was deleted.