Skip to content

Commit 745b9aa

Browse files
committed
Install trusted certs instead of copy
1 parent 3a97288 commit 745b9aa

File tree

3 files changed

+37
-6
lines changed

3 files changed

+37
-6
lines changed

.github/workflows/style.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ jobs:
3737
with:
3838
dockerfile: Dockerfile
3939

40+
- name: Run hadolint Konflux
41+
uses: hadolint/hadolint-action@v3.3.0
42+
with:
43+
dockerfile: konflux.Dockerfile
44+
4045
- name: Create ../results directory for SARIF report files
4146
shell: bash
4247
run: mkdir -p ../results

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ image: ## Build the docker image
5757
.PHONY: dockerfile-lint
5858
dockerfile-lint: ## Run hadolint for Dockerfile
5959
$(DOCKER_CMD) run --rm -i --env HADOLINT_FAILURE_THRESHOLD=info ghcr.io/hadolint/hadolint < Dockerfile
60+
$(DOCKER_CMD) run --rm -i --env HADOLINT_FAILURE_THRESHOLD=info ghcr.io/hadolint/hadolint < konflux.Dockerfile
6061

6162
.PHONY: helm-lint
6263
helm-lint: ## Run helm lint for Helm chart

konflux.Dockerfile

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ COPY . .
2323
# Build the binary with optimizations
2424
# Output to "/tmp" directory, because user can not copy built binary to "/workspace"
2525
# 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) \
26+
RUN RACE=0 GOOS=$(go env GOOS) GOARCH=$(go env GOARCH) \
2727
go build \
2828
-mod=mod \
2929
-ldflags="-w -s \
@@ -34,18 +34,43 @@ RUN RACE=0 CGO_ENABLED=0 GOOS=$(go env GOOS) GOARCH=$(go env GOARCH) \
3434
-o /tmp/stackrox-mcp \
3535
./cmd/stackrox-mcp
3636

37-
# Stage 2: Runtime - Minimal runtime image
38-
FROM registry.access.redhat.com/ubi9/ubi-micro@sha256:093a704be0eaef9bb52d9bc0219c67ee9db13c2e797da400ddb5d5ae6849fa10
37+
38+
# Stage 2: Runtime base - used to preserve rpmdb when installing packages
39+
FROM registry.access.redhat.com/ubi9/ubi-micro:latest@sha256:093a704be0eaef9bb52d9bc0219c67ee9db13c2e797da400ddb5d5ae6849fa10 AS ubi-micro-base
40+
41+
42+
# Stage 3: Package installer - installs ca-certificates and openssl into /ubi-micro-base-root/
43+
FROM registry.access.redhat.com/ubi9/ubi:latest@sha256:05fa0100593c08b5e9dde684cd3eaa94b4d5d7b3cc09944f1f73924e49fde036 AS package_installer
44+
45+
# Copy ubi-micro base to /ubi-micro-base-root/ to preserve its rpmdb
46+
COPY --from=ubi-micro-base / /ubi-micro-base-root/
47+
48+
# Install packages directly to /ubi-micro-base-root/ using --installroot
49+
# Note: --setopt=reposdir=/etc/yum.repos.d instructs dnf to use repo configurations pointing to RPMs
50+
# prefetched by Hermeto/Cachi2, instead of installroot's default UBI repos.
51+
# hadolint ignore=DL3041 # We are installing ca-certificates and openssl only to include trusted certs.
52+
RUN dnf install -y \
53+
--installroot=/ubi-micro-base-root/ \
54+
--releasever=9 \
55+
--setopt=install_weak_deps=False \
56+
--setopt=reposdir=/etc/yum.repos.d \
57+
--nodocs \
58+
ca-certificates \
59+
openssl && \
60+
dnf clean all --installroot=/ubi-micro-base-root/ && \
61+
rm -rf /ubi-micro-base-root/var/cache/*
62+
63+
64+
# Stage 4: Runtime - Minimal runtime image
65+
FROM ubi-micro-base
3966

4067
# Set default environment variables
4168
ENV LOG_LEVEL=INFO
4269

4370
# Set working directory
4471
WORKDIR /app
4572

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/
73+
COPY --from=package_installer /ubi-micro-base-root/ /
4974

5075
# Copy binary from builder
5176
COPY --from=builder /tmp/stackrox-mcp /app/stackrox-mcp

0 commit comments

Comments
 (0)