Skip to content

Commit 1b7b51d

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

3 files changed

Lines changed: 64 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: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
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+
RUN CGO_ENABLED=0 go build \
26+
-ldflags="-w -s \
27+
-X 'github.com/stackrox/stackrox-mcp/internal/config.version=${VERSION}' \
28+
-X 'github.com/stackrox/stackrox-mcp/internal/config.serverName=${SERVER_NAME}' \
29+
-X 'github.com/stackrox/stackrox-mcp/internal/config.productDisplayName=${PRODUCT_DISPLAY_NAME}'" \
30+
-trimpath \
31+
-o /tmp/stackrox-mcp \
32+
./cmd/stackrox-mcp
33+
34+
# Stage 2: Runtime - Minimal runtime image
35+
FROM registry.access.redhat.com/ubi9/ubi-micro@sha256:093a704be0eaef9bb52d9bc0219c67ee9db13c2e797da400ddb5d5ae6849fa10
36+
37+
# Set default environment variables
38+
ENV LOG_LEVEL=INFO
39+
40+
# Set working directory
41+
WORKDIR /app
42+
43+
# Copy trusted certificates from builder
44+
COPY --from=builder /etc/pki/ca-trust/extracted/ /etc/pki/ca-trust/extracted/
45+
COPY --from=builder /etc/ssl/certs/ /etc/ssl/certs/
46+
47+
# Copy binary from builder
48+
COPY --from=builder /tmp/stackrox-mcp /app/stackrox-mcp
49+
50+
# Set ownership for OpenShift arbitrary UID support
51+
# Files owned by 4000, group 0 (root), with group permissions matching user
52+
RUN chown -R 4000:0 /app && \
53+
chmod -R g=u /app
54+
55+
# Switch to non-root user (can be overridden by OpenShift SCC)
56+
USER 4000
57+
58+
# Expose port for MCP server
59+
EXPOSE 8080
60+
61+
# Run the application
62+
ENTRYPOINT ["/app/stackrox-mcp"]

0 commit comments

Comments
 (0)