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
44 changes: 29 additions & 15 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ name: CI/CD

on:
push:
branches:
- master
pull_request:
workflow_dispatch:
schedule:
- cron: '0 0 * * 0'
Expand All @@ -10,7 +13,7 @@ jobs:
build:
strategy:
matrix:
version: [22, 24, 24-nginx, 26]
version: [22, 24, 26]
runs-on: [ubuntu-24.04, ubuntu-24.04-arm]
runs-on: ${{ matrix.runs-on }}

Expand All @@ -21,6 +24,11 @@ jobs:
- 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"
Expand All @@ -29,8 +37,8 @@ jobs:
uses: actions/cache@v5
with:
path: /tmp/.buildx-cache
key: docker-buildx-${{ matrix.version }}-${{ steps.cachekey.outputs.week }}-${{ github.sha }}
restore-keys: docker-buildx-${{ matrix.version }}-${{ steps.cachekey.outputs.week }}-
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
run: |
Expand All @@ -39,33 +47,39 @@ jobs:
--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) \
--tag "kooldev/node:${{ matrix.version }}-$(arch)" \
${{ matrix.version }}

- name: Tests
run: |
docker run kooldev/node:${{ matrix.version }}-$(arch) node -v;
docker run kooldev/node:${{ matrix.version }}-$(arch) npm -v;
docker run kooldev/node:${{ matrix.version }}-$(arch) yarn -v;
run: sh tests/image.sh "kooldev/node:${{ matrix.version }}-$(arch)"

docker run -e ASUSER=1000 kooldev/node:${{ matrix.version }}-$(arch) node -v;
docker run -e ASUSER=1000 kooldev/node:${{ matrix.version }}-$(arch) npm -v;
docker run -e ASUSER=1000 kooldev/node:${{ matrix.version }}-$(arch) yarn -v;
# 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
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
if: github.ref == 'refs/heads/master' && github.repository == 'kool-dev/docker-node'
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/master' && github.repository == 'kool-dev/docker-node'
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

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

amend:
if: github.ref == 'refs/heads/master' && github.repository == 'kool-dev/docker-node'
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:
Expand Down
12 changes: 6 additions & 6 deletions 22/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ RUN adduser -D -u 1337 kool && deluser --remove-home node \
&& npm install -g pnpm \
# node 26+ images no longer ship yarn
&& (command -v yarn >/dev/null || npm install -g yarn) \
&& rm -rf rm -rf /root/.npm/* \
# dockerize
&& curl -L https://github.com/jwilder/dockerize/releases/download/v0.6.1/dockerize-alpine-linux-amd64-v0.6.1.tar.gz | tar xz \
&& mv dockerize /usr/local/bin/dockerize
&& rm -rf /root/.npm/*

COPY root-npmrc /root/.npmrc
COPY --chown=kool:kool kool-npmrc /home/kool/.npmrc
COPY install-dockerize /tmp/install-dockerize
RUN sh /tmp/install-dockerize && rm /tmp/install-dockerize

COPY root-pnpm-config /root/.config/pnpm/config.yaml
COPY --chown=kool:kool kool-pnpm-config /home/kool/.config/pnpm/config.yaml
COPY entrypoint /entrypoint

RUN chmod +x /entrypoint
Expand Down
30 changes: 30 additions & 0 deletions 22/install-dockerize
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/sh
set -eu

version=v0.16.0
# Alpine names come from the target image, not the build host.
arch=${2:-$(apk --print-arch)}
case "$arch" in
x86_64)
target=amd64
checksum=1075de8f235bb755b43f54c3e5489de48de61fdf782f6eb150c76eb049b52743
;;
aarch64)
target=arm64
checksum=13e0b7fc2a14614c206e37c8717526e590d0a98cac0d4224335f13c8fb538267
;;
*) echo "Unsupported dockerize architecture: $arch" >&2; exit 1 ;;
esac
asset="dockerize-alpine-linux-$target-$version.tar.gz"
if [ "${1:-}" = "--artifact" ]; then
printf '%s %s\n' "$checksum" "$asset"
exit 0
fi

tmp=$(mktemp -d)
trap 'rm -rf "$tmp"' EXIT
curl --fail --location --retry 3 \
"https://github.com/jwilder/dockerize/releases/download/$version/$asset" \
--output "$tmp/$asset"
echo "$checksum $tmp/$asset" | sha256sum -c -
tar -xzf "$tmp/$asset" -C /usr/local/bin dockerize
4 changes: 0 additions & 4 deletions 22/kool-npmrc

This file was deleted.

2 changes: 2 additions & 0 deletions 22/kool-pnpm-config
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
storeDir: /home/kool/.pnpm-store
packageImportMethod: copy
4 changes: 0 additions & 4 deletions 22/root-npmrc

This file was deleted.

2 changes: 2 additions & 0 deletions 22/root-pnpm-config
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
storeDir: /root/.pnpm-store
packageImportMethod: copy
4 changes: 3 additions & 1 deletion 24-nginx/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Use the base image
FROM kooldev/node:24
ARG NODE_IMAGE=kooldev/node:24
FROM ${NODE_IMAGE}

RUN apk add --no-cache nginx

Expand All @@ -11,3 +12,4 @@ RUN mkdir -p /etc/nginx/conf.d \
&& rm -f h5bp.tgz \
&& mv server-configs-nginx-*/h5bp/* . \
&& mv server-configs-nginx-*/nginx.conf /etc/nginx/nginx.conf \
&& sed -i 's/^user www-data;/user nginx;/' /etc/nginx/nginx.conf
12 changes: 6 additions & 6 deletions 24/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ RUN adduser -D -u 1337 kool && deluser --remove-home node \
&& npm install -g pnpm \
# node 26+ images no longer ship yarn
&& (command -v yarn >/dev/null || npm install -g yarn) \
&& rm -rf rm -rf /root/.npm/* \
# dockerize
&& curl -L https://github.com/jwilder/dockerize/releases/download/v0.6.1/dockerize-alpine-linux-amd64-v0.6.1.tar.gz | tar xz \
&& mv dockerize /usr/local/bin/dockerize
&& rm -rf /root/.npm/*

COPY root-npmrc /root/.npmrc
COPY --chown=kool:kool kool-npmrc /home/kool/.npmrc
COPY install-dockerize /tmp/install-dockerize
RUN sh /tmp/install-dockerize && rm /tmp/install-dockerize

COPY root-pnpm-config /root/.config/pnpm/config.yaml
COPY --chown=kool:kool kool-pnpm-config /home/kool/.config/pnpm/config.yaml
COPY entrypoint /entrypoint

RUN chmod +x /entrypoint
Expand Down
30 changes: 30 additions & 0 deletions 24/install-dockerize
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/sh
set -eu

version=v0.16.0
# Alpine names come from the target image, not the build host.
arch=${2:-$(apk --print-arch)}
case "$arch" in
x86_64)
target=amd64
checksum=1075de8f235bb755b43f54c3e5489de48de61fdf782f6eb150c76eb049b52743
;;
aarch64)
target=arm64
checksum=13e0b7fc2a14614c206e37c8717526e590d0a98cac0d4224335f13c8fb538267
;;
*) echo "Unsupported dockerize architecture: $arch" >&2; exit 1 ;;
esac
asset="dockerize-alpine-linux-$target-$version.tar.gz"
if [ "${1:-}" = "--artifact" ]; then
printf '%s %s\n' "$checksum" "$asset"
exit 0
fi

tmp=$(mktemp -d)
trap 'rm -rf "$tmp"' EXIT
curl --fail --location --retry 3 \
"https://github.com/jwilder/dockerize/releases/download/$version/$asset" \
--output "$tmp/$asset"
echo "$checksum $tmp/$asset" | sha256sum -c -
tar -xzf "$tmp/$asset" -C /usr/local/bin dockerize
4 changes: 0 additions & 4 deletions 24/kool-npmrc

This file was deleted.

2 changes: 2 additions & 0 deletions 24/kool-pnpm-config
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
storeDir: /home/kool/.pnpm-store
packageImportMethod: copy
4 changes: 0 additions & 4 deletions 24/root-npmrc

This file was deleted.

2 changes: 2 additions & 0 deletions 24/root-pnpm-config
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
storeDir: /root/.pnpm-store
packageImportMethod: copy
12 changes: 6 additions & 6 deletions 26/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ RUN adduser -D -u 1337 kool && deluser --remove-home node \
&& npm install -g pnpm \
# node 26+ images no longer ship yarn
&& (command -v yarn >/dev/null || npm install -g yarn) \
&& rm -rf rm -rf /root/.npm/* \
# dockerize
&& curl -L https://github.com/jwilder/dockerize/releases/download/v0.6.1/dockerize-alpine-linux-amd64-v0.6.1.tar.gz | tar xz \
&& mv dockerize /usr/local/bin/dockerize
&& rm -rf /root/.npm/*

COPY root-npmrc /root/.npmrc
COPY --chown=kool:kool kool-npmrc /home/kool/.npmrc
COPY install-dockerize /tmp/install-dockerize
RUN sh /tmp/install-dockerize && rm /tmp/install-dockerize

COPY root-pnpm-config /root/.config/pnpm/config.yaml
COPY --chown=kool:kool kool-pnpm-config /home/kool/.config/pnpm/config.yaml
COPY entrypoint /entrypoint

RUN chmod +x /entrypoint
Expand Down
30 changes: 30 additions & 0 deletions 26/install-dockerize
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/sh
set -eu

version=v0.16.0
# Alpine names come from the target image, not the build host.
arch=${2:-$(apk --print-arch)}
case "$arch" in
x86_64)
target=amd64
checksum=1075de8f235bb755b43f54c3e5489de48de61fdf782f6eb150c76eb049b52743
;;
aarch64)
target=arm64
checksum=13e0b7fc2a14614c206e37c8717526e590d0a98cac0d4224335f13c8fb538267
;;
*) echo "Unsupported dockerize architecture: $arch" >&2; exit 1 ;;
esac
asset="dockerize-alpine-linux-$target-$version.tar.gz"
if [ "${1:-}" = "--artifact" ]; then
printf '%s %s\n' "$checksum" "$asset"
exit 0
fi

tmp=$(mktemp -d)
trap 'rm -rf "$tmp"' EXIT
curl --fail --location --retry 3 \
"https://github.com/jwilder/dockerize/releases/download/$version/$asset" \
--output "$tmp/$asset"
echo "$checksum $tmp/$asset" | sha256sum -c -
tar -xzf "$tmp/$asset" -C /usr/local/bin dockerize
4 changes: 0 additions & 4 deletions 26/kool-npmrc

This file was deleted.

2 changes: 2 additions & 0 deletions 26/kool-pnpm-config
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
storeDir: /home/kool/.pnpm-store
packageImportMethod: copy
4 changes: 0 additions & 4 deletions 26/root-npmrc

This file was deleted.

2 changes: 2 additions & 0 deletions 26/root-pnpm-config
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
storeDir: /root/.pnpm-store
packageImportMethod: copy
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,19 @@ app:

## Contributing

### Package manager defaults

pnpm's per-user `~/.config/pnpm/config.yaml` sets `storeDir` to
`~/.pnpm-store` and `packageImportMethod` to `copy`. npm no longer receives
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
`sh tests/image.sh IMAGE` to exercise dockerize, npm, yarn, pnpm, config
resolution and ownership as root and two remapped user IDs.

### Updating images and building locally

> You must have [`kool`](https://github.com/kool-dev/kool) installed.
Expand Down
36 changes: 24 additions & 12 deletions fwd-template.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,16 @@
"path": "template/entrypoint"
},
{
"name": "kool-npmrc",
"path": "template/kool-npmrc"
"name": "kool-pnpm-config",
"path": "template/kool-pnpm-config"
},
{
"name": "root-npmrc",
"path": "template/root-npmrc"
"name": "root-pnpm-config",
"path": "template/root-pnpm-config"
},
{
"name": "install-dockerize",
"path": "template/install-dockerize"
}
]
},
Expand All @@ -42,12 +46,16 @@
"path": "template/entrypoint"
},
{
"name": "kool-npmrc",
"path": "template/kool-npmrc"
"name": "kool-pnpm-config",
"path": "template/kool-pnpm-config"
},
{
"name": "root-pnpm-config",
"path": "template/root-pnpm-config"
},
{
"name": "root-npmrc",
"path": "template/root-npmrc"
"name": "install-dockerize",
"path": "template/install-dockerize"
}
]
},
Expand All @@ -67,12 +75,16 @@
"path": "template/entrypoint"
},
{
"name": "kool-npmrc",
"path": "template/kool-npmrc"
"name": "kool-pnpm-config",
"path": "template/kool-pnpm-config"
},
{
"name": "root-pnpm-config",
"path": "template/root-pnpm-config"
},
{
"name": "root-npmrc",
"path": "template/root-npmrc"
"name": "install-dockerize",
"path": "template/install-dockerize"
}
]
}
Expand Down
Loading
Loading