Skip to content

Commit 3a97288

Browse files
committed
Add Konflux Dockerfile and adjust config
1 parent c1faac7 commit 3a97288

3 files changed

Lines changed: 67 additions & 2 deletions

File tree

.tekton/acs-mcp-server-pull-request.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ spec:
2828
- name: image-expires-after
2929
value: 5d
3030
- name: dockerfile
31-
value: Dockerfile
31+
value: konflux.Dockerfile
3232
pipelineSpec:
3333
description: |
3434
This pipeline is ideal for building container images from a Containerfile while maintaining trust after pipeline customization.

.tekton/acs-mcp-server-push.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ spec:
2525
- name: output-image
2626
value: quay.io/redhat-user-workloads/rh-acs-tenant/acs-mcp-server:{{revision}}
2727
- name: dockerfile
28-
value: Dockerfile
28+
value: konflux.Dockerfile
2929
pipelineSpec:
3030
description: |
3131
This pipeline is ideal for building container images from a Containerfile while maintaining trust after pipeline customization.

konflux.Dockerfile

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# Multi-stage Dockerfile for ACS MCP Server build on Konflux
2+
3+
# Stage 1: Builder - Build the Go binary
4+
FROM brew.registry.redhat.io/rh-osbs/openshift-golang-builder:rhel_9_golang_1.25@sha256:bd531796aacb86e4f97443797262680fbf36ca048717c00b6f4248465e1a7c0c AS builder
5+
6+
# Build arguments for application version and branding
7+
ARG VERSION=dev
8+
ARG SERVER_NAME="acs-mcp-server"
9+
ARG PRODUCT_DISPLAY_NAME="Red Hat Advanced Cluster Security (ACS)"
10+
11+
# Set working directory
12+
WORKDIR /workspace
13+
14+
# Copy go module files first for better layer caching
15+
COPY go.mod go.sum ./
16+
17+
# Download dependencies (cached layer)
18+
RUN go mod download
19+
20+
# Copy source code
21+
COPY . .
22+
23+
# Build the binary with optimizations
24+
# Output to "/tmp" directory, because user can not copy built binary to "/workspace"
25+
# Go build uses "venodr" mode and that fails, that's why explicit "-mod=mod" is set.
26+
RUN RACE=0 CGO_ENABLED=0 GOOS=$(go env GOOS) GOARCH=$(go env GOARCH) \
27+
go build \
28+
-mod=mod \
29+
-ldflags="-w -s \
30+
-X 'github.com/stackrox/stackrox-mcp/internal/config.version=${VERSION}' \
31+
-X 'github.com/stackrox/stackrox-mcp/internal/config.serverName=${SERVER_NAME}' \
32+
-X 'github.com/stackrox/stackrox-mcp/internal/config.productDisplayName=${PRODUCT_DISPLAY_NAME}'" \
33+
-trimpath \
34+
-o /tmp/stackrox-mcp \
35+
./cmd/stackrox-mcp
36+
37+
# Stage 2: Runtime - Minimal runtime image
38+
FROM registry.access.redhat.com/ubi9/ubi-micro@sha256:093a704be0eaef9bb52d9bc0219c67ee9db13c2e797da400ddb5d5ae6849fa10
39+
40+
# Set default environment variables
41+
ENV LOG_LEVEL=INFO
42+
43+
# Set working directory
44+
WORKDIR /app
45+
46+
# Copy trusted certificates from builder
47+
COPY --from=builder /etc/pki/ca-trust/extracted/ /etc/pki/ca-trust/extracted/
48+
COPY --from=builder /etc/ssl/certs/ /etc/ssl/certs/
49+
50+
# Copy binary from builder
51+
COPY --from=builder /tmp/stackrox-mcp /app/stackrox-mcp
52+
53+
# Set ownership for OpenShift arbitrary UID support
54+
# Files owned by 4000, group 0 (root), with group permissions matching user
55+
RUN chown -R 4000:0 /app && \
56+
chmod -R g=u /app
57+
58+
# Switch to non-root user (can be overridden by OpenShift SCC)
59+
USER 4000
60+
61+
# Expose port for MCP server
62+
EXPOSE 8080
63+
64+
# Run the application
65+
ENTRYPOINT ["/app/stackrox-mcp"]

0 commit comments

Comments
 (0)