Skip to content

Commit b23d8ad

Browse files
committed
Introduce tagging per major, minor, patch version. Add OCI labels.
1 parent fd6e47d commit b23d8ad

File tree

3 files changed

+73
-14
lines changed

3 files changed

+73
-14
lines changed

.github/workflows/build.yaml

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,11 @@ jobs:
2828

2929
- name: Build image
3030
run: |-
31-
docker build -t $IMAGE_NAME:$IMAGE_TAG .
31+
docker build \
32+
--build-arg BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ') \
33+
--build-arg VCS_REF=${{ github.sha }} \
34+
--build-arg VERSION=${{ github.ref_name }} \
35+
-t $IMAGE_NAME:$IMAGE_TAG .
3236
3337
- name: Smoke test image
3438
run: |-
@@ -63,19 +67,41 @@ jobs:
6367
--cache-from=$IMAGE_NAME:latest \
6468
--push \
6569
-t $IMAGE_NAME:latest \
66-
--platform linux/amd64,linux/arm64,linux/arm/v7 \
70+
--platform linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6 \
71+
--build-arg BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ') \
72+
--build-arg VCS_REF=${{ github.sha }} \
73+
--build-arg VERSION=latest \
6774
.
6875
69-
- name: Set tag in environment
76+
- name: Parse version components
7077
if: contains(github.ref, 'refs/tags/')
71-
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
78+
id: parse_version
79+
run: |
80+
VERSION=${GITHUB_REF#refs/tags/}
81+
echo "FULL_VERSION=$VERSION" >> $GITHUB_ENV
7282
73-
- name: Build multi-arch image and push release tag
83+
# Extract base version without revision for parsing (e.g., 6.8.1 from 6.8.1-1)
84+
BASE=$(echo $VERSION | cut -d- -f1)
85+
86+
# Extract major version (e.g., 6 from 6.8.1)
87+
MAJOR=$(echo $BASE | cut -d. -f1)
88+
echo "MAJOR_VERSION=$MAJOR" >> $GITHUB_ENV
89+
90+
# Extract minor version (e.g., 6.8 from 6.8.1)
91+
MINOR=$(echo $BASE | cut -d. -f1,2)
92+
echo "MINOR_VERSION=$MINOR" >> $GITHUB_ENV
93+
94+
- name: Build multi-arch image and push release tags
7495
if: contains(github.ref, 'refs/tags/')
7596
run: |-
7697
docker buildx build \
7798
--cache-from=$IMAGE_NAME:latest \
7899
--push \
79-
-t $IMAGE_NAME:$RELEASE_VERSION \
80-
--platform linux/amd64,linux/arm64,linux/arm/v7 \
100+
-t $IMAGE_NAME:$FULL_VERSION \
101+
-t $IMAGE_NAME:$MINOR_VERSION \
102+
-t $IMAGE_NAME:$MAJOR_VERSION \
103+
--platform linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6 \
104+
--build-arg BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ') \
105+
--build-arg VCS_REF=${{ github.sha }} \
106+
--build-arg VERSION=$FULL_VERSION \
81107
.

Dockerfile

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,21 @@
11
FROM alpine:3.23
2-
LABEL Maintainer="Tim de Pater <[email protected]>" \
3-
Description="Lightweight WordPress container with Nginx 1.26 & PHP-FPM 8.4 based on Alpine Linux."
2+
3+
# Build arguments for OCI annotations
4+
ARG BUILD_DATE
5+
ARG VERSION
6+
ARG VCS_REF
7+
8+
# OCI annotations
9+
LABEL org.opencontainers.image.created="${BUILD_DATE}"
10+
LABEL org.opencontainers.image.authors="Tim de Pater <[email protected]>"
11+
LABEL org.opencontainers.image.url="https://github.com/TrafeX/docker-wordpress"
12+
LABEL org.opencontainers.image.documentation="https://github.com/TrafeX/docker-wordpress"
13+
LABEL org.opencontainers.image.source="https://github.com/TrafeX/docker-wordpress"
14+
LABEL org.opencontainers.image.version="${VERSION}"
15+
LABEL org.opencontainers.image.revision="${VCS_REF}"
16+
LABEL org.opencontainers.image.vendor="TrafeX"
17+
LABEL org.opencontainers.image.title="WordPress with Nginx 1.28 & PHP-FPM 8.4"
18+
LABEL org.opencontainers.image.description="Lightweight WordPress container with Nginx 1.28 & PHP-FPM 8.4 based on Alpine Linux."
419

520
# Install packages
621
RUN apk --no-cache add \
@@ -52,8 +67,8 @@ WORKDIR /var/www/wp-content
5267
RUN chown -R nobody:nobody /var/www
5368

5469
# WordPress
55-
ENV WORDPRESS_VERSION 6.9
56-
ENV WORDPRESS_SHA1 256dda5bb6a43aecd806b7a62528f442c06e6c25
70+
ENV WORDPRESS_VERSION=6.9
71+
ENV WORDPRESS_SHA1=256dda5bb6a43aecd806b7a62528f442c06e6c25
5772

5873
RUN mkdir -p /usr/src
5974

@@ -65,7 +80,7 @@ RUN curl -o wordpress.tar.gz -SL https://wordpress.org/wordpress-${WORDPRESS_VER
6580
&& chown -R nobody:nobody /usr/src/wordpress
6681

6782
# Add WP CLI
68-
ENV WP_CLI_CONFIG_PATH /usr/src/wordpress/wp-cli.yml
83+
ENV WP_CLI_CONFIG_PATH=/usr/src/wordpress/wp-cli.yml
6984
RUN curl -o /usr/local/bin/wp https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar \
7085
&& chmod +x /usr/local/bin/wp
7186
COPY --chown=nobody:nobody wp-cli.yml /usr/src/wordpress/

README.md

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
# WordPress Docker Container
33

4-
Lightweight WordPress container with Nginx 1.26 & PHP-FPM 8.4 based on Alpine Linux.
4+
Lightweight WordPress container with Nginx 1.28 & PHP-FPM 8.4 based on Alpine Linux.
55

66
_WordPress version currently installed:_ **6.9**
77

@@ -17,14 +17,32 @@ _WordPress version currently installed:_ **6.9**
1717
* Fully configurable because wp-config.php uses the environment variables you can pass as an argument to the container
1818

1919
[![Docker Pulls](https://img.shields.io/docker/pulls/trafex/wordpress.svg)](https://hub.docker.com/r/trafex/wordpress/)
20-
![nginx 1.26](https://img.shields.io/badge/nginx-1.26-brightgreen.svg)
20+
![nginx 1.28](https://img.shields.io/badge/nginx-1.28-brightgreen.svg)
2121
![php 8.4](https://img.shields.io/badge/php-8.4-brightgreen.svg)
2222
![License MIT](https://img.shields.io/badge/license-MIT-blue.svg)
2323

2424
## [![Trafex Consultancy](https://timdepater.com/logo/mini-logo.png)](https://timdepater.com?mtm_campaign=github)
2525
I can help you with [Containerization, Kubernetes, Monitoring, Infrastructure as Code and other DevOps challenges](https://timdepater.com/?mtm_campaign=github).
2626

2727
## Usage
28+
29+
### Versioning
30+
31+
This image follows the **Debian versioning convention** for tagging: `<wordpress-version>-<container-revision>`
32+
33+
**Available tags:**
34+
* `latest` - Latest stable release
35+
* `<major>.<minor>.<patch>-<revision>` - Full version (e.g., `6.8.1-1`, `6.8.1-2`)
36+
* The first part (`6.8.1`) tracks the WordPress version included
37+
* The revision number (`-1`, `-2`) indicates container updates (security patches, dependency updates, configuration changes)
38+
* `<major>.<minor>.<patch>` - Latest container revision for a WordPress version (e.g., `6.8.1``6.8.1-2`)
39+
* `<major>.<minor>` - Latest patch and revision (e.g., `6.8``6.8.1-2`)
40+
* `<major>` - Latest minor, patch and revision (e.g., `6``6.8.1-2`)
41+
42+
**For production use**, pin to a specific full version tag (e.g., `trafex/wordpress:6.8.1-1`) to ensure reproducible deployments and controlled updates.
43+
44+
### Running the Container
45+
2846
See [docker-compose.yml](https://github.com/TrafeX/docker-wordpress/blob/master/docker-compose.yml) how to use it in your own environment.
2947

3048
docker-compose up

0 commit comments

Comments
 (0)