Skip to content

Commit

Permalink
install snyk cli for arm and amd
Browse files Browse the repository at this point in the history
  • Loading branch information
nilsgstrabo committed Aug 1, 2024
1 parent 3c8b617 commit e4b2c97
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 25 deletions.
41 changes: 17 additions & 24 deletions Dockerfile
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"]
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,15 @@ build:
docker build -t $(IMAGE_NAME) .

.PHONY: push
push:
push: build
az acr login -n $(DOCKER_REGISTRY)
docker push $(IMAGE_NAME)

.PHONY: pushmultiplatform
pushmultiplatform:
az acr login -n $(DOCKER_REGISTRY)
docker buildx build --platform=linux/amd64,linux/arm64 -t $(IMAGE_NAME) --push .

.PHONY: test
test:
go test -cover `go list ./... | grep -v 'pkg/client'`
Expand Down

0 comments on commit e4b2c97

Please sign in to comment.