Skip to content

Commit 1cf86e4

Browse files
committed
build: add version tagging and labeling to Docker images and workflow
- Pass VERSION as a build argument in Docker workflow jobs - Update README with instructions for building Docker images with version tags and verifying image version labels - Add VERSION build argument to Dockerfile and set version labels for both OCI and Label Schema standards Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
1 parent f08d031 commit 1cf86e4

File tree

3 files changed

+31
-2
lines changed

3 files changed

+31
-2
lines changed

.github/workflows/docker.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ jobs:
7171
push: false
7272
load: true
7373
tags: ${{ env.REPO }}:scan
74+
build-args: |
75+
VERSION=${{ steps.docker-meta.outputs.version }}
7476
7577
- name: Run Trivy vulnerability scanner on Docker image
7678
uses: aquasecurity/trivy-action@0.33.1
@@ -95,5 +97,7 @@ jobs:
9597
push: ${{ github.event_name != 'pull_request' }}
9698
tags: ${{ steps.docker-meta.outputs.tags }}
9799
labels: ${{ steps.docker-meta.outputs.labels }}
100+
build-args: |
101+
VERSION=${{ steps.docker-meta.outputs.version }}
98102
cache-from: type=registry,ref=ghcr.io/${{ env.REPO }}:buildcache
99103
cache-to: type=registry,ref=ghcr.io/${{ env.REPO }}:buildcache,mode=max

README.md

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,14 @@ AuthGate provides multi-architecture Docker images for easy deployment:
211211
make build_linux_amd64 # For Linux x86_64
212212
make build_linux_arm64 # For Linux ARM64
213213

214-
# Build Docker image
214+
# Build Docker image (with version tag)
215+
docker build -f docker/Dockerfile \
216+
--build-arg VERSION=v1.0.0 \
217+
-t authgate:v1.0.0 \
218+
-t authgate:latest \
219+
.
220+
221+
# Or build without version (defaults to "dev")
215222
docker build -f docker/Dockerfile -t authgate .
216223

217224
# Run with Docker
@@ -226,6 +233,9 @@ docker run -d \
226233

227234
# Check health
228235
curl http://localhost:8080/health
236+
237+
# Inspect image labels to verify version
238+
docker inspect authgate:v1.0.0 | grep -A 5 Labels
229239
```
230240

231241
#### Docker Features
@@ -236,6 +246,7 @@ curl http://localhost:8080/health
236246
- Built-in health check endpoint
237247
- Persistent volume for SQLite database
238248
- Embedded templates and static files (single binary)
249+
- Version labels via `--build-arg VERSION=<version>` (supports both OCI and Label Schema standards)
239250

240251
#### Docker Compose Example
241252

@@ -702,6 +713,14 @@ systemctl start authgate
702713
#### 2. Docker Deployment
703714

704715
```bash
716+
# Build with version information
717+
VERSION=$(git describe --tags --always --dirty)
718+
docker build -f docker/Dockerfile \
719+
--build-arg VERSION=${VERSION} \
720+
-t authgate:${VERSION} \
721+
-t authgate:latest \
722+
.
723+
705724
# Using Docker Compose (recommended)
706725
docker-compose up -d
707726

@@ -715,6 +734,9 @@ docker run -d \
715734
-e SESSION_SECRET=$(openssl rand -hex 32) \
716735
-e BASE_URL=https://auth.yourdomain.com \
717736
authgate:latest
737+
738+
# Verify deployed version
739+
docker inspect authgate:latest --format '{{index .Config.Labels "org.opencontainers.image.version"}}'
718740
```
719741

720742
#### 3. Reverse Proxy Setup (Nginx)

docker/Dockerfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,18 @@ FROM alpine:3.21
22

33
ARG TARGETOS
44
ARG TARGETARCH
5+
ARG VERSION=dev
56

67
LABEL maintainer="AuthGate Team" \
78
org.label-schema.name="AuthGate" \
89
org.label-schema.vendor="AuthGate" \
9-
org.label-schema.schema-version="1.0"
10+
org.label-schema.schema-version="1.0" \
11+
org.label-schema.version="${VERSION}"
1012

1113
LABEL org.opencontainers.image.source=https://github.com/your-org/authgate
1214
LABEL org.opencontainers.image.description="OAuth 2.0 Device Authorization Grant server for CLI tools and browserless devices"
1315
LABEL org.opencontainers.image.licenses=MIT
16+
LABEL org.opencontainers.image.version="${VERSION}"
1417

1518
RUN apk add --no-cache ca-certificates wget && \
1619
rm -rf /var/cache/apk/* && \

0 commit comments

Comments
 (0)