Files
pnpm/docker/install-pnpm.sh
Zoltan Kochan 9d3b6c58ae feat(docker): publish an Alpine variant of the pnpm image (#17069)
Adds `<version>-alpine`, `<major>-alpine`, and `alpine` tags built from
docker/Dockerfile.alpine with the musl release tarball. Alpine users can
use the image as a base or copy /opt/pnpm into `node:*-alpine` without
fetching the installer from get.pnpm.io, which was returning 403 to
bursts of concurrent CI jobs.

The download, checksum, and version check move into
docker/install-pnpm.sh, shared by both Dockerfiles. The Alpine image
also installs libstdc++ and libgcc, which the musl Node.js builds
installed by `pnpm runtime` need. The Alpine build runs only for
releases that ship musl tarballs for both x64 and arm64, so v11 and
v10 releases skip it.

Every release used to publish the `latest` and `<major>` tags, so a v11
maintenance release moved `latest` back to v11. The builds now push only
the exact version tags. A final step lists the stable releases and, with
`docker buildx imagetools create`, points `<major>` at the highest
version in that major and `latest` at the highest version overall. The
Alpine tags follow the same rule. Deciding after the builds sees every
release of a burst, since lines are published seconds apart. A
concurrency group was rejected because GitHub cancels a pending run when
a third one queues. The selection lives in
.github/scripts/docker-image-tags.sh with a test run by CI, and fails on
an empty release list.

The v12 CI docs now run the Bitbucket Pipelines and GitLab CI examples
in `ghcr.io/pnpm/pnpm:12` instead of downloading the installer, and
recommend the image for CI that runs jobs in containers. CircleCI keeps
the installer because its checkout step needs git and ssh.

The CI examples that still use the standalone script fall back to the
latest pnpm/get.pnpm.io installer release when get.pnpm.io fails. They
run the script only after a download succeeds.

Related to pnpm/pnpm#16973.
2026-10-18 01:22:12 +02:00

38 lines
1.4 KiB
Bash

#!/bin/sh
# Installs the pnpm release tarball into /opt/pnpm and links it onto PATH.
#
# Environment:
# PNPM_VERSION pnpm version to install, without a leading "v"
# PNPM_ASSET_SUFFIX release asset suffix after the architecture: "" or "-musl"
# PNPM_SHA256_AMD64 sha256 of the amd64 tarball
# PNPM_SHA256_ARM64 sha256 of the arm64 tarball
# TARGETARCH set by BuildKit
set -eu
test -n "$PNPM_VERSION"
case "$TARGETARCH" in
amd64) arch=x64; expected_sha="$PNPM_SHA256_AMD64" ;;
arm64) arch=arm64; expected_sha="$PNPM_SHA256_ARM64" ;;
*) echo "unsupported architecture: $TARGETARCH" >&2; exit 1 ;;
esac
test -n "$expected_sha" || { echo "missing PNPM_SHA256_* build-arg for $TARGETARCH" >&2; exit 1; }
asset="pnpm-linux-${arch}${PNPM_ASSET_SUFFIX}.tar.gz"
mkdir -p /opt/pnpm "$PNPM_HOME/bin"
chmod -R a+rwX "$PNPM_HOME"
curl -fsSL --retry 3 --retry-delay 2 -o /tmp/pnpm.tgz \
"https://github.com/pnpm/pnpm/releases/download/v${PNPM_VERSION}/${asset}"
actual_sha="$(sha256sum /tmp/pnpm.tgz | awk '{print $1}')"
test "$actual_sha" = "$expected_sha" || {
echo "sha256 mismatch for ${asset}: expected $expected_sha, got $actual_sha" >&2
exit 1
}
tar -xzf /tmp/pnpm.tgz -C /opt/pnpm
rm /tmp/pnpm.tgz
ln -s /opt/pnpm/pnpm /usr/local/bin/pnpm
installed="$(pnpm --version)"
test "$installed" = "$PNPM_VERSION" || {
echo "pnpm version mismatch: expected $PNPM_VERSION, got $installed" >&2
exit 1
}