Skip to content

Commit 2c38589

Browse files
committed
Introduce tagging per major, minor, patch version. Add OCI labels.
1 parent faed4f8 commit 2c38589

File tree

3 files changed

+48
-6
lines changed

3 files changed

+48
-6
lines changed

.github/workflows/build.yaml

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,18 +67,39 @@ jobs:
6767
--push \
6868
-t $IMAGE_NAME:latest \
6969
--platform linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6 \
70+
--build-arg BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ') \
71+
--build-arg VCS_REF=${{ github.sha }} \
72+
--build-arg VERSION=latest \
7073
.
7174
7275
- name: Set tag in environment
7376
if: contains(github.ref, 'refs/tags/')
7477
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
7578

76-
- name: Build multi-arch image and push release tag
79+
- name: Parse version components
80+
if: contains(github.ref, 'refs/tags/')
81+
id: parse_version
82+
run: |
83+
VERSION=${GITHUB_REF#refs/tags/}
84+
echo "FULL_VERSION=$VERSION" >> $GITHUB_ENV
85+
# Extract major version (e.g., 3 from 3.9.1)
86+
MAJOR=$(echo $VERSION | cut -d. -f1)
87+
echo "MAJOR_VERSION=$MAJOR" >> $GITHUB_ENV
88+
# Extract minor version (e.g., 3.9 from 3.9.1)
89+
MINOR=$(echo $VERSION | cut -d. -f1,2)
90+
echo "MINOR_VERSION=$MINOR" >> $GITHUB_ENV
91+
92+
- name: Build multi-arch image and push release tags
7793
if: contains(github.ref, 'refs/tags/')
7894
run: |-
7995
docker buildx build \
8096
--cache-from=$IMAGE_NAME:latest \
8197
--push \
82-
-t $IMAGE_NAME:$RELEASE_VERSION \
98+
-t $IMAGE_NAME:$FULL_VERSION \
99+
-t $IMAGE_NAME:$MINOR_VERSION \
100+
-t $IMAGE_NAME:$MAJOR_VERSION \
83101
--platform linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6 \
102+
--build-arg BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ') \
103+
--build-arg VCS_REF=${{ github.sha }} \
104+
--build-arg VERSION=$FULL_VERSION \
84105
.

Dockerfile

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,23 @@
11
ARG ALPINE_VERSION=3.23
22
FROM alpine:${ALPINE_VERSION}
3-
LABEL Maintainer="Tim de Pater <[email protected]>"
4-
LABEL Description="Lightweight container with Nginx 1.28 & PHP 8.4 based on Alpine Linux."
3+
4+
# Build metadata arguments
5+
ARG BUILD_DATE
6+
ARG VCS_REF
7+
ARG VERSION
8+
9+
# OCI annotations for supply chain security
10+
LABEL org.opencontainers.image.created="${BUILD_DATE}"
11+
LABEL org.opencontainers.image.authors="Tim de Pater <[email protected]>"
12+
LABEL org.opencontainers.image.url="https://github.com/TrafeX/docker-php-nginx"
13+
LABEL org.opencontainers.image.documentation="https://github.com/TrafeX/docker-php-nginx"
14+
LABEL org.opencontainers.image.source="https://github.com/TrafeX/docker-php-nginx"
15+
LABEL org.opencontainers.image.version="${VERSION}"
16+
LABEL org.opencontainers.image.revision="${VCS_REF}"
17+
LABEL org.opencontainers.image.vendor="TrafeX"
18+
LABEL org.opencontainers.image.title="PHP-FPM 8.4 & Nginx on Alpine Linux"
19+
LABEL org.opencontainers.image.description="Lightweight container with Nginx 1.28 & PHP 8.4 based on Alpine Linux."
20+
521
# Setup document root
622
WORKDIR /var/www/html
723

README.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,13 @@ Or mount your own code to be served by PHP-FPM & Nginx
4040
docker run -p 80:8080 -v ~/my-codebase:/var/www/html trafex/php-nginx
4141

4242
## Versioning
43-
Major or minor changes are always published as a [release](https://github.com/TrafeX/docker-php-nginx/releases) with correspondending changelogs.
44-
The `latest` tag is automatically updated weekly to include the latests patches from Alpine Linux.
43+
44+
This image follows semantic versioning;
45+
46+
- `latest` - Automatically updated weekly with the latest patches from Alpine Linux
47+
- `3` - Latest major version 3.x (follows minor and patch updates)
48+
- `3.9` - Latest version 3.9.x (follows patch updates only)
49+
- `3.9.1` - Specific patch version (immutable)
4550

4651
## Configuration
4752
In [config/](config/) you'll find the default configuration files for Nginx, PHP and PHP-FPM.

0 commit comments

Comments
 (0)