Skip to content

Commit d003a9e

Browse files
committed
feat: multi-arch builds with cosign provenance and image signature
1 parent ffaae89 commit d003a9e

File tree

3 files changed

+152
-114
lines changed

3 files changed

+152
-114
lines changed
Lines changed: 54 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,86 @@
1-
name: Docker Cloud Build
1+
name: Docker Provenance Multi-Arch Build
22

33
on:
44
release:
55
types:
66
- published
77

8+
permissions:
9+
contents: write
10+
id-token: write
11+
812
jobs:
9-
docker:
10-
runs-on: ubuntu-latest
13+
build:
14+
strategy:
15+
matrix:
16+
arch: [amd64, arm64]
17+
include:
18+
- arch: amd64
19+
runner: ubuntu-24.04
20+
- arch: arm64
21+
runner: ubuntu-24.04-arm64
22+
23+
runs-on: ${{ matrix.runner }}
24+
outputs:
25+
version: ${{ steps.version.outputs.tag }}
1126
steps:
1227
- name: Checkout
1328
uses: actions/checkout@v4
1429

30+
- name: Extract release version
31+
id: version
32+
run: echo "tag=${GITHUB_REF#refs/tags/}" >> "$GITHUB_OUTPUT"
33+
1534
- name: Log in to Docker Hub
1635
uses: docker/login-action@v3
1736
with:
1837
username: ${{ secrets.DOCKERHUB_USERNAME }}
1938
password: ${{ secrets.DOCKERHUB_TOKEN }}
2039

21-
- name: Set up Docker Buildx (cloud driver)
40+
- name: Set up Docker Buildx
2241
uses: docker/setup-buildx-action@v3
2342
with:
24-
version: lab:latest
25-
driver: cloud
26-
endpoint: fontebasso/multiarch-builder
43+
install: true
2744

28-
- name: Extract release version
29-
id: version
30-
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
31-
32-
- name: Build for amd64
45+
- name: Build and push image with provenance for ${{ matrix.arch }}
3346
uses: docker/build-push-action@v6
3447
with:
3548
context: .
36-
tags: |
37-
fontebasso/php-nginx:${{ env.RELEASE_VERSION }}-amd64
38-
platforms: linux/amd64
49+
platforms: linux/${{ matrix.arch }}
50+
tags: fontebasso/php-nginx:${{ steps.version.outputs.tag }}-${{ matrix.arch }}
3951
push: true
40-
attestations: |
41-
type=provenance,mode=max
52+
provenance: true
4253

43-
- name: Build for arm64
44-
uses: docker/build-push-action@v6
54+
merge:
55+
needs: build
56+
runs-on: ubuntu-latest
57+
steps:
58+
- name: Extract release version
59+
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
60+
61+
- name: Log in to Docker Hub
62+
uses: docker/login-action@v3
4563
with:
46-
context: .
47-
tags: |
48-
fontebasso/php-nginx:${{ env.RELEASE_VERSION }}-arm64
49-
platforms: linux/arm64
50-
push: true
51-
attestations: |
52-
type=provenance,mode=max
64+
username: ${{ secrets.DOCKERHUB_USERNAME }}
65+
password: ${{ secrets.DOCKERHUB_TOKEN }}
5366

54-
- name: Merge and push multi-arch
67+
- name: Merge multi-arch image
5568
run: |
5669
docker buildx imagetools create \
57-
--tag fontebasso/php-nginx:${{ env.RELEASE_VERSION }} \
70+
--tag fontebasso/php-nginx:${RELEASE_VERSION} \
5871
--tag fontebasso/php-nginx:latest \
59-
fontebasso/php-nginx:${{ env.RELEASE_VERSION }}-amd64 \
60-
fontebasso/php-nginx:${{ env.RELEASE_VERSION }}-arm64
72+
fontebasso/php-nginx:${RELEASE_VERSION}-amd64 \
73+
fontebasso/php-nginx:${RELEASE_VERSION}-arm64
74+
75+
- name: Install Cosign
76+
uses: sigstore/[email protected]
77+
78+
- name: Sign image using GitHub OIDC
79+
run: cosign sign --yes --key github docker.io/fontebasso/php-nginx:${RELEASE_VERSION}
6180

62-
- name: Clean up intermediate tags
81+
- name: Generate and attach SLSA Provenance
6382
run: |
64-
docker logout
65-
echo "${{ secrets.DOCKERHUB_TOKEN }}" | docker login -u "${{ secrets.DOCKERHUB_USERNAME }}" --password-stdin
66-
docker rmi fontebasso/php-nginx:${{ env.RELEASE_VERSION }}-amd64 || true
67-
docker rmi fontebasso/php-nginx:${{ env.RELEASE_VERSION }}-arm64 || true
83+
cosign attest --yes \
84+
--key github \
85+
--type=provenance \
86+
docker.io/fontebasso/php-nginx:${RELEASE_VERSION}

Dockerfile

Lines changed: 65 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -7,90 +7,89 @@ ARG VERSION_OS='3.20'
77
ARG VERSION_PHP='8.3'
88

99
LABEL \
10-
ALPINE="$VERSION_OS" \
11-
PHP_VERSION="$VERSION_PHP" \
12-
MAINTAINER='Samuel Fontebasso <[email protected]>'
10+
maintainer="Samuel Fontebasso <[email protected]>" \
11+
alpine="${VERSION_OS}" \
12+
php_version="${VERSION_PHP}"
13+
14+
ENV APP_DIR="/app"
1315

1416
RUN set -eux; \
1517
apk update; \
16-
apk add --no-cache --upgrade \
17-
bzip2-dev \
18-
ca-certificates \
19-
curl \
20-
curl-dev \
21-
freetype-dev \
22-
ghostscript \
23-
git \
24-
icu-dev \
25-
imagemagick \
26-
imagemagick-dev \
27-
imagemagick-libs \
28-
jpeg-dev \
29-
libjpeg-turbo-dev \
30-
libmcrypt-dev \
31-
libpng-dev \
32-
libxml2-dev \
33-
libzip-dev \
34-
ncurses \
35-
nginx \
36-
nginx-mod-http-headers-more \
37-
oniguruma-dev \
38-
openssl \
39-
runit \
40-
sqlite; \
18+
apk add --no-cache \
19+
ca-certificates \
20+
curl \
21+
git \
22+
icu-dev \
23+
imagemagick \
24+
jpeg-dev \
25+
freetype-dev \
26+
libpng-dev \
27+
libxml2-dev \
28+
libzip-dev \
29+
oniguruma-dev \
30+
sqlite \
31+
nginx \
32+
nginx-mod-http-headers-more \
33+
runit \
34+
openssl \
35+
libjpeg-turbo-dev \
36+
ncurses; \
4137
apk add --no-cache --virtual .build-deps \
42-
build-base \
43-
gcc \
44-
wget \
45-
autoconf \
46-
linux-headers; \
47-
docker-php-ext-configure gd \
48-
--with-freetype \
49-
--with-jpeg; \
50-
docker-php-ext-configure pcntl \
51-
--enable-pcntl; \
52-
docker-php-ext-install \
53-
bcmath \
54-
bz2 \
55-
calendar \
56-
exif \
57-
gd \
58-
opcache \
59-
pcntl \
60-
pdo_mysql \
61-
shmop \
62-
sockets \
63-
sysvmsg \
64-
sysvsem \
65-
sysvshm \
66-
zip; \
67-
pecl install grpc; \
68-
git clone https://github.com/Imagick/imagick.git --depth 1 /tmp/imagick; \
38+
build-base \
39+
autoconf \
40+
linux-headers \
41+
bzip2-dev \
42+
curl-dev \
43+
libmcrypt-dev \
44+
imagemagick-dev \
45+
wget \
46+
gcc; \
47+
docker-php-ext-configure gd --with-freetype --with-jpeg; \
48+
docker-php-ext-configure pcntl --enable-pcntl; \
49+
docker-php-ext-install -j$(nproc) \
50+
bcmath \
51+
bz2 \
52+
calendar \
53+
exif \
54+
gd \
55+
opcache \
56+
pcntl \
57+
pdo_mysql \
58+
shmop \
59+
sockets \
60+
sysvmsg \
61+
sysvsem \
62+
sysvshm \
63+
zip; \
64+
git clone --depth=1 https://github.com/Imagick/imagick.git /tmp/imagick; \
6965
cd /tmp/imagick; \
7066
phpize; \
7167
./configure; \
7268
make -j$(nproc); \
7369
make install; \
7470
docker-php-ext-enable --ini-name docker-php-ext-x-01-imagick.ini imagick; \
71+
rm -rf /tmp/imagick; \
72+
pecl install grpc; \
7573
docker-php-ext-enable --ini-name docker-php-ext-x-02-grpc.ini grpc; \
7674
apk del .build-deps; \
77-
rm -rf /var/cache/apk/* /tmp/imagick; \
78-
ln -sf /dev/stdout /var/log/nginx/access.log; \
75+
rm -rf /var/cache/apk/*; \
76+
rm -rf /tmp/*; \
77+
rm -f /var/log/nginx/access.log; \
78+
ln -sf /dev/null /var/log/nginx/access.log; \
7979
ln -sf /dev/stderr /var/log/nginx/error.log; \
80-
mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini";
80+
mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini"
8181

8282
COPY ./src /
83-
COPY ./custom_params.ini /usr/local/etc/php/conf.d/docker-php-ext-x-02-custom-params.ini
83+
COPY ./custom_params.ini /usr/local/etc/php/conf.d/docker-php-ext-x-03-custom-params.ini
8484

8585
RUN set -eux; \
8686
touch /env; \
87-
chown -R www-data:www-data /env /app /var/log/nginx /etc/service /var/run /var/lib/nginx /run/nginx;
88-
89-
RUN chmod +x \
90-
/sbin/runit-wrapper \
91-
/sbin/runsvdir-start \
92-
/etc/service/nginx/run \
93-
/etc/service/php-fpm/run
87+
chown -R www-data:www-data /env /app /var/log/nginx /etc/service /var/run /var/lib/nginx /run/nginx; \
88+
chmod +x \
89+
/sbin/runit-wrapper \
90+
/sbin/runsvdir-start \
91+
/etc/service/nginx/run \
92+
/etc/service/php-fpm/run
9493

9594
USER www-data
9695
WORKDIR /app

README.md

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,37 @@
44
[![Docker Pulls](https://img.shields.io/docker/pulls/fontebasso/php-nginx)](https://hub.docker.com/r/fontebasso/php-nginx)
55
[![GitHub Repo](https://img.shields.io/badge/github-repo-yellowgreen)](https://github.com/fontebasso/docker-php-nginx)
66
[![GitHub License](https://img.shields.io/github/license/fontebasso/docker-php-nginx)](https://github.com/fontebasso/docker-php-nginx/blob/main/LICENSE)
7+
[![Signed with Sigstore](https://img.shields.io/badge/sigstore-signed-blue?logo=sigstore)](https://www.sigstore.dev)
78

89
This repository contains a Docker image for running high-performance PHP web applications. It is optimized for speed, efficiency, and includes a comprehensive set of tools and libraries commonly used in web development.
910

10-
> This image is ready to run in production, suggestions for improvements and corrections are very welcome, see [how to contribute](CONTRIBUTING.md).
11+
> This image is **signed and attested using [Sigstore](https://www.sigstore.dev/)**. You can publicly verify its provenance using cosign.
1112
12-
> If you identify a security breach, please report it as soon as possible under guidelines outlined in our [security policy](SECURITY.md).
13+
> If you identify a security breach, please report it as soon as possible under the guidelines outlined in our [security policy](SECURITY.md).
14+
15+
16+
## Security & Provenance
17+
18+
This image is cryptographically signed using GitHub OIDC and cosign, and its build provenance is verifiable through the Rekor transparency log.
19+
20+
To verify the image and its provenance:
21+
22+
```bash
23+
cosign verify docker.io/fontebasso/php-nginx:latest
24+
cosign verify-attestation --type=provenance docker.io/fontebasso/php-nginx:latest
25+
```
26+
27+
No manual setup or keys required — Cosign uses GitHub Actions identity.
1328

1429
## Features
1530

16-
- **PHP 8.2**: The image uses PHP 8.2, which is optimized for performance and includes numerous features and improvements.
17-
- **Alpine Linux 3.16**: A minimal Docker image based on Alpine Linux for security and reduced image size.
18-
- **Nginx**: Fast and reliable web server.
19-
- **Essential PHP Extensions**: Including `bcmath`, `bz2`, `calendar`, `exif`, `gd`, `opcache`, `pdo_mysql`, `shmop`, `sockets`, `sysvmsg`, `sysvsem`, `sysvshm`, `pcntl`, `zip`, and `imagick`.
20-
- **Pre-installed Libraries**: `git`, `bzip2-dev`, `freetype-dev`, `icu-dev`, `imagemagick`, `jpeg-dev`, `libpng-dev`, `libressl-dev`, `libxml2-dev`, `libzip-dev`, `oniguruma-dev` and more.
21-
- **Runit**: Lightweight and easy-to-use init system.
31+
- **PHP 8.3:** Modern version with performance improvements and long-term support.
32+
- **Alpine Linux 3.20:** Minimal base for better security and smaller footprint.
33+
- **Nginx:** Fast and reliable web server.
34+
- **Essential PHP Extensions:** Includes `bcmath`, `bz2`, `calendar`, `exif`, `gd`, `opcache`, `pcntl`, `pdo_mysql`, `shmop`, `sockets`, `sysvmsg`, `sysvsem`, `sysvshm`, `zip`, `imagick`, `grpc`.
35+
- **Pre-installed Libraries:** `git`, `icu-dev`, `imagemagick`, `freetype`, `jpeg`, `libpng`, `libxml2`, `libzip`, `oniguruma`, `curl`, `nginx-mod-http-headers-more`.
36+
- **Runit:** Lightweight init system for process supervision.
37+
- **Multi-arch builds:** Supports linux/amd64 and linux/arm64.
2238

2339
## Getting Started
2440

@@ -42,22 +58,22 @@ To run a container using this image, execute:
4258
docker run -d -p 8080:80 fontebasso/php-nginx:latest
4359
```
4460

45-
This command will start a container and map port 8080 on your local machine to port 80 on the container.
61+
This will expose Nginx on port 8080 of your local machine.
4662

4763
### Custom Configuration
4864

4965
You can customize the PHP configuration by editing the custom_params.ini file and copying it to the appropriate directory:
5066

5167
```dockerfile
52-
COPY ./custom_params.ini /usr/local/etc/php/conf.d/docker-php-ext-x-02-custom-params.ini
68+
COPY ./custom_params.ini /usr/local/etc/php/conf.d/docker-php-ext-x-03-custom-params.ini
5369
```
5470

5571
### Directory Structure
5672

5773
- `/app`: The application code.
5874
- `/env`: Environment variables directory.
5975
- `/var/log/nginx`: Nginx logs.
60-
- `/etc/service`: Service definitions for `runit`.
76+
- `/etc/service`: Runit service definitions.
6177

6278
## Development
6379

@@ -71,14 +87,18 @@ docker build -t fontebasso/php-nginx:latest .
7187

7288
### Building for Multiple Architectures
7389

74-
This repository is configured to build for multiple architectures using GitHub Actions. Supported architectures:
90+
This repository is configured to build for:
7591

7692
- `linux/amd64`
7793
- `linux/arm64`
7894

95+
Via GitHub Actions with provenance and public signing.
96+
7997
### Contributing
8098

81-
Contributions are welcome! Please fork this repository and submit a pull request with your changes.
99+
Pull requests are welcome! Please fork the repository and submit your improvements.
100+
101+
We follow standard open-source contribution guidelines, and are happy to receive help improving this project.
82102

83103
## Maintainers
84104

0 commit comments

Comments
 (0)