Skip to content

Commit 647c448

Browse files
committed
chore: add Docker deployment support
- Add Dockerfile with multi-architecture support (amd64, arm64) - Add .dockerignore to optimize build context - Add GitHub workflow for automated Docker image builds - Add Makefile targets for Docker operations (build-linux, docker-build, docker-test, docker-run) - Update README.md with Docker usage instructions - Update AGENTS.md with Docker deployment documentation Docker images are published to ghcr.io/techprimate/github-actions-utils-cli with automatic tagging for main branch (latest) and semantic versions.
1 parent 875e630 commit 647c448

File tree

6 files changed

+387
-0
lines changed

6 files changed

+387
-0
lines changed

.dockerignore

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Git
2+
.git
3+
.gitignore
4+
.gitattributes
5+
6+
# CI/CD
7+
.github
8+
9+
# Documentation
10+
*.md
11+
docs/
12+
13+
# Development
14+
.cursor/
15+
.vscode/
16+
.idea/
17+
18+
# Build artifacts (we copy specific binaries)
19+
dist/*
20+
!dist/github-actions-utils-cli-linux-*
21+
22+
# Go
23+
go.sum
24+
*.test
25+
*.out
26+
coverage.txt
27+
28+
# Dependencies
29+
vendor/
30+
31+
# OS
32+
.DS_Store
33+
Thumbs.db
34+
35+
# Misc
36+
LICENSE
37+
renovate.json
38+
dprint.json
39+
Brewfile
40+
Makefile
41+
42+
# Keep only what's needed for the build
43+
!dist/github-actions-utils-cli-linux-amd64
44+
!dist/github-actions-utils-cli-linux-arm64
45+

.github/workflows/docker.yml

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
name: Docker
2+
3+
on:
4+
push:
5+
branches: [main]
6+
tags: ["v*"]
7+
pull_request:
8+
paths:
9+
- "Dockerfile"
10+
- ".dockerignore"
11+
- ".github/workflows/docker.yml"
12+
workflow_dispatch:
13+
14+
permissions:
15+
contents: read
16+
packages: write
17+
18+
concurrency:
19+
group: ${{ github.workflow }}-${{ github.ref }}
20+
cancel-in-progress: true
21+
22+
env:
23+
REGISTRY: ghcr.io
24+
IMAGE_NAME: ${{ github.repository }}
25+
26+
jobs:
27+
# Build binaries first (needed for Docker image)
28+
build-binaries:
29+
name: Build Linux Binaries
30+
runs-on: ubuntu-latest
31+
timeout-minutes: 10
32+
strategy:
33+
matrix:
34+
include:
35+
- platform: linux-amd64
36+
goos: linux
37+
goarch: amd64
38+
- platform: linux-arm64
39+
goos: linux
40+
goarch: arm64
41+
steps:
42+
- name: Checkout
43+
uses: actions/checkout@v5
44+
with:
45+
persist-credentials: false
46+
47+
- name: Set up Go
48+
uses: actions/setup-go@v6
49+
with:
50+
go-version-file: go.mod
51+
cache: true
52+
check-latest: false
53+
54+
- name: Build CLI
55+
run: |
56+
BINARY="github-actions-utils-cli-${{ matrix.platform }}"
57+
58+
# Build static binary (no CGO, static linking)
59+
CGO_ENABLED=0 GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} go build \
60+
-ldflags "-s -w -extldflags '-static'" \
61+
-a -installsuffix cgo \
62+
-o "dist/${BINARY}" \
63+
./cmd/cli
64+
65+
- name: Upload artifact
66+
uses: actions/upload-artifact@v5
67+
with:
68+
name: cli-${{ matrix.platform }}
69+
path: dist/github-actions-utils-cli-*
70+
retention-days: 1
71+
72+
# Build and push Docker images
73+
docker:
74+
name: Build and Push Docker Image
75+
needs: build-binaries
76+
runs-on: ubuntu-latest
77+
timeout-minutes: 15
78+
steps:
79+
- name: Checkout
80+
uses: actions/checkout@v5
81+
with:
82+
persist-credentials: false
83+
84+
- name: Download Linux binaries
85+
uses: actions/download-artifact@v6
86+
with:
87+
path: dist
88+
pattern: cli-linux-*
89+
merge-multiple: true
90+
91+
- name: Set up QEMU
92+
uses: docker/setup-qemu-action@v3
93+
94+
- name: Set up Docker Buildx
95+
uses: docker/setup-buildx-action@v3
96+
97+
- name: Log in to Container Registry
98+
uses: docker/login-action@v3
99+
with:
100+
registry: ${{ env.REGISTRY }}
101+
username: ${{ github.actor }}
102+
password: ${{ secrets.GITHUB_TOKEN }}
103+
104+
- name: Extract metadata
105+
id: meta
106+
uses: docker/metadata-action@v5
107+
with:
108+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
109+
tags: |
110+
# Tag as 'latest' on main branch
111+
type=raw,value=latest,enable={{is_default_branch}}
112+
# Tag with version on tags (e.g., v1.0.0 -> 1.0.0)
113+
type=semver,pattern={{version}}
114+
# Tag with major.minor on tags (e.g., v1.0.0 -> 1.0)
115+
type=semver,pattern={{major}}.{{minor}}
116+
# Tag with major on tags (e.g., v1.0.0 -> 1)
117+
type=semver,pattern={{major}}
118+
# Tag with short commit SHA
119+
type=sha,prefix={{branch}}-
120+
121+
- name: Build and push Docker image
122+
uses: docker/build-push-action@v6
123+
with:
124+
context: .
125+
platforms: linux/amd64,linux/arm64
126+
push: ${{ github.event_name != 'pull_request' }}
127+
tags: ${{ steps.meta.outputs.tags }}
128+
labels: ${{ steps.meta.outputs.labels }}
129+
cache-from: type=gha
130+
cache-to: type=gha,mode=max

AGENTS.md

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,13 +249,90 @@ All workflows use GitHub Actions:
249249
- **format.yml** - Checks code formatting with `make format`
250250
- **release.yml** - Creates GitHub releases with signed binaries (triggered by tags or main branch)
251251
- **build-binaries.yml** - Reusable workflow that builds for all platforms and signs macOS binaries
252+
- **docker.yml** - Builds and publishes Docker images to GitHub Container Registry
252253

253254
**Platforms built:**
254255

255256
- Linux: amd64, arm64
256257
- macOS: amd64 (Intel), arm64 (Apple Silicon) - **code signed and notarized**
257258
- Windows: amd64
258259

260+
## Docker Deployment
261+
262+
The project provides Docker images for easy deployment and containerized usage.
263+
264+
**Docker commands:**
265+
266+
```bash
267+
# Build Linux binaries for Docker
268+
make build-linux
269+
270+
# Build Docker image locally
271+
make docker-build
272+
273+
# Test Docker image
274+
make docker-test
275+
276+
# Run Docker container
277+
make docker-run
278+
```
279+
280+
**Image details:**
281+
282+
- **Registry**: `ghcr.io/techprimate/github-actions-utils-cli`
283+
- **Base image**: `buildpack-deps:bookworm`
284+
- **Platforms**: linux/amd64, linux/arm64
285+
286+
**Using the Docker image:**
287+
288+
```bash
289+
# Pull latest image
290+
docker pull ghcr.io/techprimate/github-actions-utils-cli:latest
291+
292+
# Run MCP server
293+
echo '{"jsonrpc":"2.0","id":1,"method":"tools/list"}' | \
294+
docker run -i --rm ghcr.io/techprimate/github-actions-utils-cli:latest mcp
295+
296+
# Use with MCP clients (Claude, Cursor, etc.)
297+
# Configure in MCP client settings:
298+
{
299+
"mcpServers": {
300+
"github-actions-utils": {
301+
"command": "docker",
302+
"args": [
303+
"run",
304+
"-i",
305+
"--rm",
306+
"ghcr.io/techprimate/github-actions-utils-cli:latest",
307+
"mcp"
308+
]
309+
}
310+
}
311+
}
312+
```
313+
314+
**Publishing images:**
315+
316+
Docker images are automatically built and published by the `docker.yml` workflow:
317+
318+
- On **main branch push**: Tagged as `latest`
319+
- On **version tags** (v1.0.0): Tagged as `1.0.0`, `1.0`, and `1`
320+
- On **pull requests**: Built but not pushed (validation only)
321+
322+
**Manual Docker build:**
323+
324+
```bash
325+
# Build for specific platform
326+
docker build --platform linux/amd64 -t github-actions-utils-cli:latest .
327+
328+
# Build multi-platform (requires buildx)
329+
docker buildx build \
330+
--platform linux/amd64,linux/arm64 \
331+
-t github-actions-utils-cli:latest \
332+
--load \
333+
.
334+
```
335+
259336
## Sentry Integration
260337

261338
This project uses Sentry for error tracking and monitoring.

Dockerfile

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# syntax=docker/dockerfile:1
2+
3+
# ====================================================== PRODUCT =======================================================
4+
5+
FROM buildpack-deps:bookworm
6+
7+
# Metadata
8+
LABEL maintainer="techprimate GmbH <[email protected]>"
9+
LABEL description="Container for github-actions-utils-cli"
10+
11+
# ARG for platform detection
12+
ARG TARGETARCH
13+
14+
# Copy the appropriate binary based on target architecture
15+
COPY dist/github-actions-utils-cli-linux-${TARGETARCH} /tmp/github-actions-utils-cli
16+
17+
# Install binary to PATH
18+
RUN install \
19+
-o root \
20+
-g root \
21+
-m 0755 \
22+
/tmp/github-actions-utils-cli /usr/local/bin/github-actions-utils-cli && \
23+
rm -f /tmp/github-actions-utils-cli
24+
25+
# Smoke test
26+
RUN set -x && \
27+
github-actions-utils-cli --version
28+
29+
# Set environment variables
30+
ENV TZ=UTC
31+
32+
# Entrypoint
33+
ENTRYPOINT ["/usr/local/bin/github-actions-utils-cli"]
34+

Makefile

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,57 @@ build:
6868
mkdir -p dist
6969
go build -o dist/github-actions-utils-cli ./cmd/cli
7070

71+
## Build Linux binaries for Docker image
72+
#
73+
# Builds static Linux binaries for both amd64 and arm64 architectures.
74+
# These binaries are used in the Docker multi-platform build.
75+
.PHONY: build-linux
76+
build-linux:
77+
mkdir -p dist
78+
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build \
79+
-ldflags "-s -w -extldflags '-static'" \
80+
-a -installsuffix cgo \
81+
-o dist/github-actions-utils-cli-linux-amd64 \
82+
./cmd/cli
83+
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build \
84+
-ldflags "-s -w -extldflags '-static'" \
85+
-a -installsuffix cgo \
86+
-o dist/github-actions-utils-cli-linux-arm64 \
87+
./cmd/cli
88+
89+
# ============================================================================
90+
# DOCKER
91+
# ============================================================================
92+
93+
## Build Docker image locally
94+
#
95+
# Builds a multi-platform Docker image for local testing.
96+
# Requires Linux binaries to be built first (make build-linux).
97+
# Image is tagged as github-actions-utils-cli:latest
98+
.PHONY: docker-build
99+
docker-build: build-linux
100+
docker buildx build \
101+
--platform linux/amd64,linux/arm64 \
102+
-t github-actions-utils-cli:latest \
103+
--load \
104+
.
105+
106+
## Run Docker container interactively
107+
#
108+
# Runs the Docker image with an interactive shell.
109+
# Useful for testing the CLI within the container environment.
110+
.PHONY: docker-run
111+
docker-run:
112+
docker run --rm -it github-actions-utils-cli:latest --help
113+
114+
## Test Docker image
115+
#
116+
# Builds and tests the Docker image by running version check.
117+
# Verifies that the image works correctly.
118+
.PHONY: docker-test
119+
docker-test: docker-build
120+
docker run --rm github-actions-utils-cli:latest --version
121+
71122
# ============================================================================
72123
# DEVELOPMENT & RUNNING
73124
# ============================================================================

0 commit comments

Comments
 (0)