Skip to content

Commit 4e11a26

Browse files
committed
ci: Fix tagging issues
Signed-off-by: Evan Wies <evan@neomantra.net>
1 parent d34bc94 commit 4e11a26

3 files changed

Lines changed: 126 additions & 69 deletions

File tree

.github/workflows/docker-publish.yml

Lines changed: 86 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,7 @@ jobs:
270270
tags: |
271271
type=raw,value=${{ matrix.flavor }}-${{ matrix.arch }},enable=${{ github.ref == 'refs/heads/master' }}
272272
type=ref,event=tag,suffix=-${{ matrix.flavor }}-${{ matrix.arch }}
273+
type=match,pattern=^(.*)-[0-9]$,group=1,suffix=-${{ matrix.flavor }}-${{ matrix.arch }}
273274
274275
- name: Build and push
275276
uses: docker/build-push-action@v5
@@ -328,58 +329,71 @@ jobs:
328329
fi
329330
330331
# Construct source tags
331-
SOURCES=""
332-
MIRROR_SOURCES=""
332+
# We need to handle potential aliases (e.g. 1.2.3-1 -> 1.2.3)
333+
# The build job produces both tags for the images if the pattern matches.
333334
334-
TAG_PREFIX=""
335+
declare -a PREFIXES=()
335336
if [[ "${{ github.ref_type }}" == "tag" ]]; then
336-
TAG_PREFIX="${{ github.ref_name }}-"
337+
PREFIXES+=("${{ github.ref_name }}-")
338+
# Alias logic: Matches tags ending in single digit revision (e.g. -1)
339+
TAG_BASE=$(echo "${{ github.ref_name }}" | sed 's/-[0-9]$//')
340+
if [[ "$TAG_BASE" != "${{ github.ref_name }}" ]]; then
341+
PREFIXES+=("$TAG_BASE-")
342+
fi
343+
else
344+
# For master branch or other non-tags
345+
PREFIXES+=("")
337346
fi
338347
339-
for ARCH in $ARCHS; do
340-
SOURCES="$SOURCES ${{ env.GHCR_IMAGE }}:${TAG_PREFIX}${{ matrix.flavor }}-$ARCH"
348+
for TAG_PREFIX in "${PREFIXES[@]}"; do
349+
SOURCES=""
350+
MIRROR_SOURCES=""
351+
352+
for ARCH in $ARCHS; do
353+
SOURCES="$SOURCES ${{ env.GHCR_IMAGE }}:${TAG_PREFIX}${{ matrix.flavor }}-$ARCH"
354+
if [[ "${{ vars.ENABLE_DOCKERHUB_MIRROR }}" == "true" ]]; then
355+
MIRROR_SOURCES="$MIRROR_SOURCES ${{ env.DOCKERHUB_IMAGE }}:${TAG_PREFIX}${{ matrix.flavor }}-$ARCH"
356+
fi
357+
done
358+
359+
# Target Manifest Tag
360+
TARGET_TAG="${TAG_PREFIX}${{ matrix.flavor }}"
361+
362+
echo "Creating manifest $TARGET_TAG from $SOURCES"
363+
docker buildx imagetools create -t "${{ env.GHCR_IMAGE }}:$TARGET_TAG" $SOURCES
364+
341365
if [[ "${{ vars.ENABLE_DOCKERHUB_MIRROR }}" == "true" ]]; then
342-
MIRROR_SOURCES="$MIRROR_SOURCES ${{ env.DOCKERHUB_IMAGE }}:${TAG_PREFIX}${{ matrix.flavor }}-$ARCH"
366+
echo "Creating mirror manifest $TARGET_TAG"
367+
docker buildx imagetools create -t "${{ env.DOCKERHUB_IMAGE }}:$TARGET_TAG" $MIRROR_SOURCES
368+
fi
369+
370+
# Handle "latest" tag for bookworm on master
371+
if [[ "${{ matrix.flavor }}" == "bookworm" && "${{ github.ref }}" == "refs/heads/master" && "$TAG_PREFIX" == "" ]]; then
372+
echo "Tagging bookworm as latest"
373+
docker buildx imagetools create -t "${{ env.GHCR_IMAGE }}:latest" "${{ env.GHCR_IMAGE }}:bookworm"
374+
if [[ "${{ vars.ENABLE_DOCKERHUB_MIRROR }}" == "true" ]]; then
375+
docker buildx imagetools create -t "${{ env.DOCKERHUB_IMAGE }}:latest" "${{ env.DOCKERHUB_IMAGE }}:bookworm"
376+
fi
377+
fi
378+
379+
# Create tag aliases (centos-rpm -> centos, fedora-rpm -> fedora)
380+
if [[ "${{ matrix.flavor }}" == "centos" ]]; then
381+
echo "Creating centos-rpm alias"
382+
docker buildx imagetools create -t "${{ env.GHCR_IMAGE }}:${TAG_PREFIX}centos-rpm" "${{ env.GHCR_IMAGE }}:$TARGET_TAG"
383+
if [[ "${{ vars.ENABLE_DOCKERHUB_MIRROR }}" == "true" ]]; then
384+
docker buildx imagetools create -t "${{ env.DOCKERHUB_IMAGE }}:${TAG_PREFIX}centos-rpm" "${{ env.DOCKERHUB_IMAGE }}:$TARGET_TAG"
385+
fi
386+
fi
387+
388+
if [[ "${{ matrix.flavor }}" == "fedora" ]]; then
389+
echo "Creating fedora-rpm alias"
390+
docker buildx imagetools create -t "${{ env.GHCR_IMAGE }}:${TAG_PREFIX}fedora-rpm" "${{ env.GHCR_IMAGE }}:$TARGET_TAG"
391+
if [[ "${{ vars.ENABLE_DOCKERHUB_MIRROR }}" == "true" ]]; then
392+
docker buildx imagetools create -t "${{ env.DOCKERHUB_IMAGE }}:${TAG_PREFIX}fedora-rpm" "${{ env.DOCKERHUB_IMAGE }}:$TARGET_TAG"
393+
fi
343394
fi
344395
done
345396

346-
# Target Manifest Tag
347-
TARGET_TAG="${TAG_PREFIX}${{ matrix.flavor }}"
348-
349-
echo "Creating manifest $TARGET_TAG from $SOURCES"
350-
docker buildx imagetools create -t "${{ env.GHCR_IMAGE }}:$TARGET_TAG" $SOURCES
351-
352-
if [[ "${{ vars.ENABLE_DOCKERHUB_MIRROR }}" == "true" ]]; then
353-
echo "Creating mirror manifest $TARGET_TAG"
354-
docker buildx imagetools create -t "${{ env.DOCKERHUB_IMAGE }}:$TARGET_TAG" $MIRROR_SOURCES
355-
fi
356-
357-
# Handle "latest" tag for bookworm on master
358-
if [[ "${{ matrix.flavor }}" == "bookworm" && "${{ github.ref }}" == "refs/heads/master" ]]; then
359-
echo "Tagging bookworm as latest"
360-
docker buildx imagetools create -t "${{ env.GHCR_IMAGE }}:latest" "${{ env.GHCR_IMAGE }}:bookworm"
361-
if [[ "${{ vars.ENABLE_DOCKERHUB_MIRROR }}" == "true" ]]; then
362-
docker buildx imagetools create -t "${{ env.DOCKERHUB_IMAGE }}:latest" "${{ env.DOCKERHUB_IMAGE }}:bookworm"
363-
fi
364-
fi
365-
366-
# Create tag aliases (centos-rpm -> centos, fedora-rpm -> fedora)
367-
if [[ "${{ matrix.flavor }}" == "centos" ]]; then
368-
echo "Creating centos-rpm alias"
369-
docker buildx imagetools create -t "${{ env.GHCR_IMAGE }}:${TAG_PREFIX}centos-rpm" "${{ env.GHCR_IMAGE }}:$TARGET_TAG"
370-
if [[ "${{ vars.ENABLE_DOCKERHUB_MIRROR }}" == "true" ]]; then
371-
docker buildx imagetools create -t "${{ env.DOCKERHUB_IMAGE }}:${TAG_PREFIX}centos-rpm" "${{ env.DOCKERHUB_IMAGE }}:$TARGET_TAG"
372-
fi
373-
fi
374-
375-
if [[ "${{ matrix.flavor }}" == "fedora" ]]; then
376-
echo "Creating fedora-rpm alias"
377-
docker buildx imagetools create -t "${{ env.GHCR_IMAGE }}:${TAG_PREFIX}fedora-rpm" "${{ env.GHCR_IMAGE }}:$TARGET_TAG"
378-
if [[ "${{ vars.ENABLE_DOCKERHUB_MIRROR }}" == "true" ]]; then
379-
docker buildx imagetools create -t "${{ env.DOCKERHUB_IMAGE }}:${TAG_PREFIX}fedora-rpm" "${{ env.DOCKERHUB_IMAGE }}:$TARGET_TAG"
380-
fi
381-
fi
382-
383397
build-fat:
384398
needs: manifest
385399
runs-on: ubuntu-latest
@@ -465,6 +479,7 @@ jobs:
465479
tags: |
466480
type=raw,value=${{ matrix.flavor }}-${{ matrix.arch }},enable=${{ github.ref == 'refs/heads/master' }}
467481
type=ref,event=tag,suffix=-${{ matrix.flavor }}-${{ matrix.arch }}
482+
type=match,pattern=^(.*)-[0-9]$,group=1,suffix=-${{ matrix.flavor }}-${{ matrix.arch }}
468483
469484
- name: Build and push
470485
uses: docker/build-push-action@v5
@@ -513,26 +528,36 @@ jobs:
513528
run: |
514529
ARCHS="amd64 arm64"
515530
516-
TAG_PREFIX=""
531+
declare -a PREFIXES=()
517532
if [[ "${{ github.ref_type }}" == "tag" ]]; then
518-
TAG_PREFIX="${{ github.ref_name }}-"
533+
PREFIXES+=("${{ github.ref_name }}-")
534+
# Alias logic: Matches tags ending in single digit revision (e.g. -1)
535+
TAG_BASE=$(echo "${{ github.ref_name }}" | sed 's/-[0-9]$//')
536+
if [[ "$TAG_BASE" != "${{ github.ref_name }}" ]]; then
537+
PREFIXES+=("$TAG_BASE-")
538+
fi
539+
else
540+
# For master branch or other non-tags
541+
PREFIXES+=("")
519542
fi
520543
521-
SOURCES=""
522-
MIRROR_SOURCES=""
523-
for ARCH in $ARCHS; do
524-
SOURCES="$SOURCES ${{ env.GHCR_IMAGE }}:${TAG_PREFIX}${{ matrix.flavor }}-$ARCH"
544+
for TAG_PREFIX in "${PREFIXES[@]}"; do
545+
SOURCES=""
546+
MIRROR_SOURCES=""
547+
for ARCH in $ARCHS; do
548+
SOURCES="$SOURCES ${{ env.GHCR_IMAGE }}:${TAG_PREFIX}${{ matrix.flavor }}-$ARCH"
549+
if [[ "${{ vars.ENABLE_DOCKERHUB_MIRROR }}" == "true" ]]; then
550+
MIRROR_SOURCES="$MIRROR_SOURCES ${{ env.DOCKERHUB_IMAGE }}:${TAG_PREFIX}${{ matrix.flavor }}-$ARCH"
551+
fi
552+
done
553+
554+
TARGET_TAG="${TAG_PREFIX}${{ matrix.flavor }}"
555+
556+
echo "Creating manifest $TARGET_TAG from $SOURCES"
557+
docker buildx imagetools create -t "${{ env.GHCR_IMAGE }}:$TARGET_TAG" $SOURCES
558+
525559
if [[ "${{ vars.ENABLE_DOCKERHUB_MIRROR }}" == "true" ]]; then
526-
MIRROR_SOURCES="$MIRROR_SOURCES ${{ env.DOCKERHUB_IMAGE }}:${TAG_PREFIX}${{ matrix.flavor }}-$ARCH"
560+
echo "Creating mirror manifest $TARGET_TAG"
561+
docker buildx imagetools create -t "${{ env.DOCKERHUB_IMAGE }}:$TARGET_TAG" $MIRROR_SOURCES
527562
fi
528563
done
529-
530-
TARGET_TAG="${TAG_PREFIX}${{ matrix.flavor }}"
531-
532-
echo "Creating manifest $TARGET_TAG from $SOURCES"
533-
docker buildx imagetools create -t "${{ env.GHCR_IMAGE }}:$TARGET_TAG" $SOURCES
534-
535-
if [[ "${{ vars.ENABLE_DOCKERHUB_MIRROR }}" == "true" ]]; then
536-
echo "Creating mirror manifest $TARGET_TAG"
537-
docker buildx imagetools create -t "${{ env.DOCKERHUB_IMAGE }}:$TARGET_TAG" $MIRROR_SOURCES
538-
fi

AGENTS.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# AGENTS.md
2+
3+
## Repository Overview
4+
This repository contains the Docker tooling and Dockerfiles for OpenResty. It supports multiple Linux distributions (Alpine, Ubuntu, Debian, CentOS, Fedora, etc.) and architectures (amd64, arm64, s390x).
5+
6+
## CI/CD Architecture
7+
The project has migrated from Travis CI to **GitHub Actions**.
8+
9+
### Workflow
10+
The primary workflow is defined in `.github/workflows/docker-publish.yml`.
11+
- **Primary Registry**: GitHub Container Registry (GHCR). All images are built and pushed here first.
12+
- **Mirror Registry**: Docker Hub (`openresty/openresty`). This is configured as a mirror. Pushing to Docker Hub is optional and controlled by the `ENABLE_DOCKERHUB_MIRROR` variable/secret.
13+
- **Fat Images**: "Fat" images (containing additional build tools like OPM) are built in a second stage (`build-fat` job), using the base images newly published to GHCR.
14+
15+
### Workflows
16+
- `docker-publish.yml`: Handles building, testing (implicit in build), and publishing images. Uses a matrix strategy for different flavors and architectures.
17+
18+
## Verification
19+
A test script `test-build-actions.sh` is provided to verify the build process locally or in CI.
20+
21+
## Key Files
22+
- `.github/workflows/docker-publish.yml`: Main CI definition.
23+
- `README.md`: User-facing documentation.
24+
- `test-build-actions.sh`: Build verification script.
25+
26+
## Historical Context
27+
- Previously used Travis CI (`.travis.yml` - removed).
28+
- Windows builds are/were handled by AppVeyor (`appveyor.yml` - still present).

README.md

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
# docker-openresty - Docker tooling for OpenResty
22

3-
[![Travis Status](https://api.travis-ci.com/openresty/docker-openresty.svg?branch=master)](https://travis-ci.com/github/openresty/docker-openresty) [![Appveyor status](https://ci.appveyor.com/api/projects/status/github/openresty/docker-openresty?branch=master&svg=true)](https://ci.appveyor.com/project/openresty/docker-openresty) [![](https://images.microbadger.com/badges/image/openresty/openresty.svg)](https://microbadger.com/#/images/openresty/openresty "microbadger.com")
3+
[![Build Status](https://github.com/openresty/docker-openresty/actions/workflows/docker-publish.yml/badge.svg?branch=master)](https://github.com/openresty/docker-openresty/actions/workflows/docker-publish.yml) [![Appveyor status](https://ci.appveyor.com/api/projects/status/github/openresty/docker-openresty?branch=master&svg=true)](https://ci.appveyor.com/project/openresty/docker-openresty) [![](https://images.microbadger.com/badges/image/openresty/openresty.svg)](https://microbadger.com/#/images/openresty/openresty "microbadger.com")
44

55
`docker-openresty` is [Docker](https://www.docker.com) tooling for OpenResty (https://www.openresty.org).
66

77
Docker is a container management platform. OpenResty is a full-fledged web application server by
88
bundling the standard nginx core, lots of 3rd-party nginx modules, as well as most of their external dependencies.
99

10-
Thank you to [Travis CI](https://www.travis-ci.com) for donating their build infrastructure to this project for over seven years!
10+
Thank you to [Travis CI](https://www.travis-ci.com) for donating their build infrastructure to this project for over seven years! We have since migrated to GitHub Actions.
1111

1212
We provide a series of [pre-built images](#openresty-image-tags) for various operating systems. Some are built-from the upstream OpenResty pre-built images and some are built from source.
1313

@@ -63,12 +63,16 @@ There are also specific tags for [Debug](https://openresty.org/en/deb-packages.h
6363
| `openresty/openresty:bullseye-fat-debug` | Bullseye FAT flavor with `openresty-debug` |
6464
| `openresty/openresty:bullseye-fat-valgrind` | Bullseye FAT flavor with `openresty-valgrind` |
6565

66-
## Image Mirror
67-
68-
As of `1.27.1.2-6`, we also mirror to the [GitHub Container Registry](https://github.com/users/neomantra/packages/container/package/openresty). Note this is under the image maintainer's GitHub account and not the OpenResty GitHub account. To use it, rather than specifying the image`openresty/openresty`,
69-
use the full GHCR image path of `ghcr.io/neomantra/openresty`. For example:
66+
## Image Registries
67+
68+
The CI/CD pipeline builds images to the [GitHub Container Registry](https://github.com/openresty/docker-openresty/pkgs/container/openresty) (GHCR) as the primary source.
69+
70+
* `ghcr.io/neomantra/openresty`
71+
72+
The images are then mirrored to [Docker Hub](https://hub.docker.com/r/openresty/openresty/) for convenience and backward compatibility.
73+
74+
* `openresty/openresty` (or `docker.io/openresty/openresty`)
7075

71-
* `ghcr.io/neomantra/openresty:1.27.1.2-6-bullseye`
7276

7377
----
7478

@@ -119,7 +123,7 @@ The `openresty/openresty:latest` tag points to the latest `bookworm` image.
119123

120124
Since `1.19.3.2-1`, all flavors support multi-architecture builds, both `amd64` and `aarch64`. Since `1.21.4.1-1`, the `s390x` architecture is supported for build-from-source Ubuntu flavors (like `jammy`); prior to version `1.27.1.2-3`, [PCRE JIT](https://github.com/zherczeg/sljit/issues/89) is disabled for `s390x`.
121125

122-
Starting with `1.13.6.1`, releases are tagged with `<openresty-version>-<image-version>-<flavor>`. The latest `image-version` will also be tagged `<openresty-version>-<flavor>`. The HEAD of the master branch is also labeled plainly as `<flavor>`. The builds are managed by [Travis-CI](https://travis-ci.com/github/neomantra/docker-openresty) and [Appveyor](https://ci.appveyor.com/project/openresty/docker-openresty) (for Windows images).
126+
Starting with `1.13.6.1`, releases are tagged with `<openresty-version>-<image-version>-<flavor>`. The latest `image-version` will also be tagged `<openresty-version>-<flavor>`. The HEAD of the master branch is also labeled plainly as `<flavor>`. The builds are managed by [GitHub Actions](https://github.com/openresty/docker-openresty/actions) and [Appveyor](https://ci.appveyor.com/project/openresty/docker-openresty) (for Windows images).
123127

124128
There are architecture-specific tags as well, `<openresty-version>-<image-version>-<flavor>-<arch>`, but one would generally pull from the multi-architecture name above.
125129

0 commit comments

Comments
 (0)