Skip to content

Commit f0a05a3

Browse files
committed
Move dustilock to cross compile
1 parent 48a46c6 commit f0a05a3

File tree

4 files changed

+39
-7
lines changed

4 files changed

+39
-7
lines changed

Dockerfile

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,16 @@ ARG TARGETARCH
3535
RUN export DL_LOCATION="https://github.com/charliermarsh/ruff/releases/latest/download/ruff-$([[ "${TARGETARCH}" == "amd64" ]] && echo "x86_64" || echo "aarch64")-unknown-linux-musl.tar.gz" \
3636
&& echo "Downloading from ${DL_LOCATION}" \
3737
&& curl --location "${DL_LOCATION}" | tar -xzv
38+
FROM --platform=$BUILDPLATFORM golang:alpine as dustilock-build
39+
RUN mkdir temp && cd temp && go mod init temp && go get -d github.com/checkmarx/[email protected]
40+
ARG BUILDARCH
41+
ARG TARGETARCH
42+
RUN GOOS=linux GOARCH=${TARGETARCH} go install github.com/checkmarx/[email protected] \
43+
&& ([[ "${BUILDARCH}" == "${TARGETARCH}" ]] && mv bin/dustilock /usr/bin) || mv bin/linux_${TARGETARCH}/dustilock /usr/bin
3844
FROM golang:alpine as dustilock
39-
RUN GOBIN=/usr/bin go install github.com/checkmarx/[email protected]
45+
COPY --from=dustilock-build /usr/bin/dustilock /usr/bin/dustilock
46+
# Verify Binary
47+
RUN /usr/bin/dustilock --version
4048

4149
FROM zricethezav/gitleaks:v8.17.0 as gitleaks
4250
FROM checkmarx/kics:alpine as kics

flavors/security/Dockerfile

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,16 @@
1515
FROM koalaman/shellcheck:stable as shellcheck
1616
FROM hadolint/hadolint:v2.12.0-alpine as hadolint
1717
FROM ghcr.io/yannh/kubeconform:latest-alpine as kubeconform
18+
FROM --platform=$BUILDPLATFORM golang:alpine as dustilock-build
19+
RUN mkdir temp && cd temp && go mod init temp && go get -d github.com/checkmarx/[email protected]
20+
ARG BUILDARCH
21+
ARG TARGETARCH
22+
RUN GOOS=linux GOARCH=${TARGETARCH} go install github.com/checkmarx/[email protected] \
23+
&& ([[ "${BUILDARCH}" == "${TARGETARCH}" ]] && mv bin/dustilock /usr/bin) || mv bin/linux_${TARGETARCH}/dustilock /usr/bin
1824
FROM golang:alpine as dustilock
19-
RUN GOBIN=/usr/bin go install github.com/checkmarx/[email protected]
25+
COPY --from=dustilock-build /usr/bin/dustilock /usr/bin/dustilock
26+
# Verify Binary
27+
RUN /usr/bin/dustilock --version
2028

2129
FROM zricethezav/gitleaks:v8.17.0 as gitleaks
2230
FROM checkmarx/kics:alpine as kics

linters/repository_dustilock/Dockerfile

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,16 @@
1111
## @generated by .automation/build.py using descriptor files, please do not update manually ##
1212
#############################################################################################
1313
#FROM__START
14+
FROM --platform=$BUILDPLATFORM golang:alpine as dustilock-build
15+
RUN mkdir temp && cd temp && go mod init temp && go get -d github.com/checkmarx/[email protected]
16+
ARG BUILDARCH
17+
ARG TARGETARCH
18+
RUN GOOS=linux GOARCH=${TARGETARCH} go install github.com/checkmarx/[email protected] \
19+
&& ([[ "${BUILDARCH}" == "${TARGETARCH}" ]] && mv bin/dustilock /usr/bin) || mv bin/linux_${TARGETARCH}/dustilock /usr/bin
1420
FROM golang:alpine as dustilock
15-
RUN GOBIN=/usr/bin go install github.com/checkmarx/[email protected]
21+
COPY --from=dustilock-build /usr/bin/dustilock /usr/bin/dustilock
22+
# Verify Binary
23+
RUN /usr/bin/dustilock --version
1624

1725
#FROM__END
1826

megalinter/descriptors/repository.megalinter-descriptor.yml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,10 +137,18 @@ linters:
137137
dockerfile:
138138
# The golang image used as a builder is a temporary workaround
139139
# Dustilock is not released as a binary or container
140-
- |
141-
FROM golang:alpine as dustilock
142-
RUN GOBIN=/usr/bin go install github.com/checkmarx/[email protected]
143-
- COPY --link --from=dustilock /usr/bin/dustilock /usr/bin/dustilock
140+
- |
141+
FROM --platform=$BUILDPLATFORM golang:alpine as dustilock-build
142+
RUN mkdir temp && cd temp && go mod init temp && go get -d github.com/checkmarx/[email protected]
143+
ARG BUILDARCH
144+
ARG TARGETARCH
145+
RUN GOOS=linux GOARCH=${TARGETARCH} go install github.com/checkmarx/[email protected] \
146+
&& ([[ "${BUILDARCH}" == "${TARGETARCH}" ]] && mv bin/dustilock /usr/bin) || mv bin/linux_${TARGETARCH}/dustilock /usr/bin
147+
FROM golang:alpine as dustilock
148+
COPY --from=dustilock-build /usr/bin/dustilock /usr/bin/dustilock
149+
# Verify Binary
150+
RUN /usr/bin/dustilock --version
151+
- COPY --link --from=dustilock /usr/bin/dustilock /usr/bin/dustilock
144152
supported_platforms:
145153
platform:
146154
- linux/amd64

0 commit comments

Comments
 (0)