Skip to content

Commit bda7c01

Browse files
committed
Add build and push image to repo
1 parent 5efa378 commit bda7c01

File tree

4 files changed

+151
-16
lines changed

4 files changed

+151
-16
lines changed

.github/workflows/build.yml

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
name: Build and Push Container Images
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
tags:
8+
- 'v[0-9]+.[0-9]+.[0-9]+'
9+
pull_request:
10+
types:
11+
- opened
12+
- reopened
13+
- synchronize
14+
15+
env:
16+
REGISTRY: quay.io
17+
IMAGE_NAME: stackrox-io/mcp
18+
19+
jobs:
20+
build-and-push:
21+
runs-on: ubuntu-latest
22+
23+
permissions:
24+
contents: read
25+
packages: write
26+
27+
steps:
28+
- name: Checkout repository
29+
uses: actions/checkout@v4
30+
31+
- name: Set up Docker Buildx
32+
uses: docker/setup-buildx-action@v3
33+
34+
- name: Log in to Quay.io
35+
uses: docker/login-action@v3
36+
with:
37+
registry: ${{ env.REGISTRY }}
38+
username: ${{ secrets.QUAY_STACKROX_IO_RW_USERNAME }}
39+
password: ${{ secrets.QUAY_STACKROX_IO_RW_PASSWORD }}
40+
41+
- name: Extract metadata (tags, labels)
42+
id: meta
43+
uses: docker/metadata-action@v5
44+
with:
45+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
46+
tags: |
47+
type=semver,pattern={{version}}
48+
type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/v') }}
49+
type=sha,prefix=,format=short
50+
labels: |
51+
summary=StackRox MCP Server
52+
description=Model Context Protocol server for StackRox
53+
maintainer=https://stackrox.io/
54+
vendor=StackRox
55+
56+
- name: Build and push multi-arch image
57+
uses: docker/build-push-action@v6
58+
with:
59+
context: .
60+
platforms: linux/amd64,linux/arm64,linux/ppc64le,linux/s390x
61+
push: true
62+
tags: ${{ steps.meta.outputs.tags }}
63+
labels: ${{ steps.meta.outputs.labels }}
64+
cache-from: type=gha
65+
cache-to: type=gha,mode=max
66+
build-args: |
67+
VERSION=${{ steps.meta.outputs.version }}
68+
69+
- name: Generate build summary
70+
run: |
71+
echo "## Build Summary" >> $GITHUB_STEP_SUMMARY
72+
echo "" >> $GITHUB_STEP_SUMMARY
73+
echo "**Registry**: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}" >> $GITHUB_STEP_SUMMARY
74+
echo "" >> $GITHUB_STEP_SUMMARY
75+
echo "**Tags**:" >> $GITHUB_STEP_SUMMARY
76+
echo '```' >> $GITHUB_STEP_SUMMARY
77+
echo "${{ steps.meta.outputs.tags }}" >> $GITHUB_STEP_SUMMARY
78+
echo '```' >> $GITHUB_STEP_SUMMARY
79+
echo "" >> $GITHUB_STEP_SUMMARY
80+
echo "**Platforms**: linux/amd64, linux/arm64, linux/ppc64le, linux/s390x" >> $GITHUB_STEP_SUMMARY

Dockerfile

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,15 @@
44
ARG GOLANG_BUILDER=registry.access.redhat.com/ubi10/go-toolset:1.25
55
ARG MCP_SERVER_BASE_IMAGE=registry.access.redhat.com/ubi10/ubi-micro:10.1
66

7+
# Build arguments for multi-arch support
8+
ARG TARGETPLATFORM
9+
ARG BUILDPLATFORM
10+
711
# Stage 1: Builder - Build the Go binary
8-
FROM $GOLANG_BUILDER AS builder
12+
FROM --platform=$BUILDPLATFORM $GOLANG_BUILDER AS builder
913

10-
# Build arguments for multi-arch support
11-
ARG TARGETOS=linux
12-
ARG TARGETARCH=amd64
14+
ARG TARGETOS
15+
ARG TARGETARCH
1316
ARG VERSION=dev
1417

1518
# Set working directory

Makefile

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
# Binary name
55
BINARY_NAME=stackrox-mcp
66

7-
# Version (can be overridden with VERSION=x.y.z make build)
8-
VERSION?=0.1.0
7+
# Version can be overridden with VERSION=x.y.z make build (default: extracted from git tags or use dev)
8+
VERSION?=$(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
99

1010
# Go parameters
1111
GOCMD=go
@@ -40,7 +40,10 @@ build: ## Build the binary
4040

4141
.PHONY: image
4242
image: ## Build the docker image
43-
$(DOCKER_CMD) build -t quay.io/stackrox-io/stackrox-mcp:$(VERSION) .
43+
$(DOCKER_CMD) build \
44+
--build-arg VERSION=$(VERSION) \
45+
-t quay.io/stackrox-io/mcp:$(VERSION) \
46+
.
4447

4548
.PHONY: dockerfile-lint
4649
dockerfile-lint: ## Run hadolint for Dockerfile

README.md

Lines changed: 58 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -173,33 +173,82 @@ You: "Can you list all the clusters from StackRox?"
173173
Claude: [Uses list_clusters tool to retrieve cluster information]
174174
```
175175

176-
## Docker
176+
## Container Images
177177

178-
### Building the Docker Image
178+
### Registry
179+
180+
Official images are published to Quay.io:
181+
182+
```
183+
quay.io/stackrox-io/mcp
184+
```
185+
186+
### Supported Architectures
187+
188+
Multi-architecture images support the following platforms:
189+
190+
- `linux/amd64` - Standard x86_64 architecture
191+
- `linux/arm64` - ARM 64-bit (Apple Silicon, AWS Graviton, etc.)
192+
- `linux/ppc64le` - IBM POWER architecture
193+
- `linux/s390x` - IBM Z mainframe architecture
194+
195+
Docker/Podman will automatically pull the correct image for your platform.
196+
197+
### Available Tags
198+
199+
| Tag Pattern | Description | Example |
200+
|-------------|-------------|---------|
201+
| `latest` | Latest release version | `quay.io/stackrox-io/mcp:latest` |
202+
| `v{version}` | Specific release version | `quay.io/stackrox-io/mcp:v1.0.0` |
203+
| `{commit-sha}` | Specific commit from main branch | `quay.io/stackrox-io/mcp:a1b2c3d` |
204+
205+
### Usage
206+
207+
#### Pull Image
179208

180-
Build the image locally:
181209
```bash
182-
VERSION=dev make image
210+
docker pull quay.io/stackrox-io/mcp:latest
211+
# or
212+
podman pull quay.io/stackrox-io/mcp:latest
183213
```
184214

185-
### Running the Container
215+
#### Run Container
186216

187-
Run with default settings:
188217
```bash
189-
docker run --publish 8080:8080 --env STACKROX_MCP__TOOLS__CONFIG_MANAGER__ENABLED=true --env STACKROX_MCP__CENTRAL__URL=<central host:port> quay.io/stackrox-io/stackrox-mcp:dev
218+
docker run -p 8080:8080 \
219+
--env STACKROX_MCP__CENTRAL__URL=central.stackrox:443 \
220+
--env STACKROX_MCP__TOOLS__CONFIG_MANAGER__ENABLED=true \
221+
quay.io/stackrox-io/mcp:latest
222+
```
223+
224+
### Building Images Locally
225+
226+
Build a single-platform image:
227+
```bash
228+
VERSION=dev make image
190229
```
191230

192231
### Build Arguments
193232

194233
- `TARGETOS` - Target operating system (default: `linux`)
195234
- `TARGETARCH` - Target architecture (default: `amd64`)
196-
- `VERSION` - Application version (default: `dev`)
235+
- `VERSION` - Application version (default: auto-detected from git)
197236

198237
### Image Details
199238

200239
- **Base Image**: Red Hat UBI10-micro (minimal, secure)
201-
- **User**: Non-root user `mcp` (UID/GID 4000)
240+
- **User**: Non-root user (UID/GID 4000)
202241
- **Port**: 8080
242+
- **Health Check**: Built-in health endpoint at `/health`
243+
244+
### Automated Builds
245+
246+
Images are automatically built and pushed on:
247+
248+
- **Main branch commits**: Tagged with commit SHA
249+
- **Version tags**: Tagged with version number and `latest`
250+
251+
See [.github/workflows/build.yml](.github/workflows/build.yml) for build pipeline details.
203252

204253
## Development
205254

0 commit comments

Comments
 (0)