Skip to content

Commit e5a4d8d

Browse files
authored
ROX-31485: Add build and push image to repo (#10)
1 parent 520e95f commit e5a4d8d

File tree

4 files changed

+152
-16
lines changed

4 files changed

+152
-16
lines changed

.github/workflows/build.yml

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
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+
26+
steps:
27+
- name: Checkout repository
28+
uses: actions/checkout@v4
29+
30+
- name: Set up Docker Buildx
31+
uses: docker/setup-buildx-action@v3
32+
33+
- name: Log in to Quay.io
34+
uses: docker/login-action@v3
35+
with:
36+
registry: ${{ env.REGISTRY }}
37+
username: ${{ secrets.QUAY_STACKROX_IO_RW_USERNAME }}
38+
password: ${{ secrets.QUAY_STACKROX_IO_RW_PASSWORD }}
39+
40+
- name: Extract metadata (tags, labels)
41+
id: meta
42+
uses: docker/metadata-action@v5
43+
with:
44+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
45+
tags: |
46+
type=semver,pattern={{version}}
47+
type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/v') }}
48+
type=sha,prefix=,format=short
49+
labels: |
50+
summary=StackRox MCP Server
51+
description=Model Context Protocol server for StackRox
52+
maintainer=https://stackrox.io/
53+
vendor=StackRox
54+
55+
- name: Build and push multi-arch image
56+
uses: docker/build-push-action@v6
57+
with:
58+
context: .
59+
platforms: linux/amd64,linux/arm64,linux/ppc64le,linux/s390x
60+
push: true
61+
tags: ${{ steps.meta.outputs.tags }}
62+
labels: ${{ steps.meta.outputs.labels }}
63+
cache-from: type=gha
64+
cache-to: type=gha,mode=max
65+
build-args: |
66+
VERSION=${{ steps.meta.outputs.version }}
67+
68+
- name: Generate build summary
69+
run: |
70+
echo "## Build Summary" >> $GITHUB_STEP_SUMMARY
71+
echo "" >> $GITHUB_STEP_SUMMARY
72+
echo "**Registry**: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}" >> $GITHUB_STEP_SUMMARY
73+
echo "" >> $GITHUB_STEP_SUMMARY
74+
echo "**Tags**:" >> $GITHUB_STEP_SUMMARY
75+
echo '```' >> $GITHUB_STEP_SUMMARY
76+
echo "${{ steps.meta.outputs.tags }}" >> $GITHUB_STEP_SUMMARY
77+
echo '```' >> $GITHUB_STEP_SUMMARY
78+
echo "" >> $GITHUB_STEP_SUMMARY
79+
echo "**Platforms**: linux/amd64, linux/arm64, linux/ppc64le, linux/s390x" >> $GITHUB_STEP_SUMMARY

Dockerfile

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,17 @@
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 build support
8+
ARG BUILDPLATFORM
9+
710
# Stage 1: Builder - Build the Go binary
8-
FROM $GOLANG_BUILDER AS builder
11+
FROM --platform=$BUILDPLATFORM $GOLANG_BUILDER AS builder
12+
13+
# Build arguments for multi-arch target
14+
ARG TARGETOS
15+
ARG TARGETARCH
916

10-
# Build arguments for multi-arch support
11-
ARG TARGETOS=linux
12-
ARG TARGETARCH=amd64
17+
# Build arguments for application version
1318
ARG VERSION=dev
1419

1520
# 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)