-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3c8b617
commit e4b2c97
Showing
2 changed files
with
23 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,28 @@ | ||
FROM docker.io/golang:1.22.5-alpine3.20 AS builder | ||
|
||
ENV CGO_ENABLED=0 \ | ||
GOOS=linux | ||
|
||
# Build stage | ||
FROM --platform=$BUILDPLATFORM docker.io/golang:1.22.5-alpine3.20 AS builder | ||
ARG TARGETARCH | ||
WORKDIR /src | ||
|
||
# Install project dependencies | ||
ENV CGO_ENABLED=0 \ | ||
GOOS=linux \ | ||
GOARCH=${TARGETARCH} | ||
COPY ./go.mod ./go.sum ./ | ||
RUN go mod download | ||
|
||
# Copy project code | ||
COPY . . | ||
|
||
# Build | ||
RUN go build -ldflags="-s -w" -o /build/radix-vulnerability-scanner | ||
|
||
# Install SNYK | ||
FROM alpine:3 as tools | ||
ADD https://github.com/snyk/cli/releases/download/v1.1292.1/snyk-linux-arm64 / | ||
RUN chmod +x /snyk-linux-arm64 | ||
# SNYK cli | ||
FROM --platform=$BUILDPLATFORM docker.io/alpine:3.20 AS tools | ||
ARG TARGETARCH | ||
RUN snykVersion=v1.1292.1 snykBinary=snyk-linux && \ | ||
if [ "${TARGETARCH}" = "arm64" ]; then snykBinary=snyk-linux-arm64; fi && \ | ||
wget -O /snyk -q https://github.com/snyk/cli/releases/download/${snykVersion}/${snykBinary} | ||
|
||
# Run scanner | ||
FROM alpine:3 | ||
RUN apk update && \ | ||
apk add ca-certificates libstdc++ | ||
# Final stage | ||
FROM docker.io/ubuntu:24.04 | ||
WORKDIR /app | ||
RUN usermod --home /home/radix-vulnerability-scanner ubuntu | ||
COPY --from=builder /build/radix-vulnerability-scanner . | ||
COPY --from=tools /snyk-linux-arm64 /usr/local/bin/snyk | ||
RUN addgroup -S -g 1000 radix-vulnerability-scanner | ||
RUN adduser -S -u 1000 -G radix-vulnerability-scanner radix-vulnerability-scanner | ||
|
||
COPY --from=tools --chmod=755 /snyk /usr/local/bin/snyk | ||
COPY --from=gcr.io/distroless/static /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ | ||
USER 1000 | ||
|
||
ENTRYPOINT ["/app/radix-vulnerability-scanner"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters