Getting Started

Building locally

Build all images or a single one from the repository, and check the pins against the Alpine repositories.

Clone the repository and build from the alpine directory.

git clone https://github.com/AdamRollinson/docker.git
cd docker/alpine
./build.sh

This builds all sixteen images in order: base, then php, php-nginx and php-nginx-dev for each of the five PHP minors in php-versions.txt. Images are tagged locally with both the minor and the exact release, exactly as CI publishes them.

Build a single image

Two build arguments drive the PHP images: PHP_VERSION is the minor without the dot (used in Alpine package names) and PHP_PATCH_VERSION is the exact release to pin. Leave PHP_PATCH_VERSION out to install whatever Alpine currently has.

# Base
docker build -t adamrollogi/base:latest ./alpine/base

# PHP 8.4
docker build \
  --build-arg PHP_VERSION=84 \
  --build-arg PHP_PATCH_VERSION=8.4.26 \
  -t adamrollogi/php:8.4 \
  ./alpine/php

# PHP-Nginx 8.4 (php-fpm is pinned to the release baked into the php image)
docker build \
  --build-arg PHP_IMAGE_TAG=8.4 \
  --build-arg PHP_VERSION=84 \
  -t adamrollogi/php-nginx:8.4 \
  ./alpine/php-nginx

# PHP-Nginx-Dev 8.4
docker build \
  --build-arg PHP_IMAGE_TAG=8.4 \
  --build-arg PHP_VERSION=84 \
  -t adamrollogi/php-nginx-dev:8.4 \
  ./alpine/php-nginx-dev

Multi-architecture builds

CI builds linux/amd64 and linux/arm64 with buildx and QEMU. To do the same locally:

docker buildx create --name multi --driver docker-container --use
docker buildx build --platform linux/amd64,linux/arm64 \
  --build-arg PHP_VERSION=84 --build-arg PHP_PATCH_VERSION=8.4.26 \
  -t adamrollogi/php:8.4 ./alpine/php

Checking the pins

alpine/check-php-versions.sh            # report pinned vs Alpine vs php.net
alpine/check-php-versions.sh --update   # rewrite php-versions.txt with what edge has
CHECK_UPSTREAM=false alpine/check-php-versions.sh   # skip the php.net lookup

This is the same script the scheduled bump job runs. See Automatic updates.

Requirements

  • Docker with BuildKit (any current Docker Desktop or Engine).
  • Network access to dl-cdn.alpinelinux.org, getcomposer.org and Docker Hub.
  • A wrong PHP_PATCH_VERSION fails fast at apk add with a message naming the constraint, which is intentional.