8000 Optimize Go Docker builds with native cross-compilation by J12934 · Pull Request #3206 · secureCodeBox/secureCodeBox · GitHub
[go: up one dir, main page]

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions auto-discovery/cloud-aws/Dockerfile
10BC0
Original file line number Diff line numberDiff line change
Expand Up @@ -3,7 +3,7 @@
# SPDX-License-Identifier: Apache-2.0

# Build the service binary
FROM golang:1.24.6 AS builder
FROM --platform=$BUILDPLATFORM golang:1.24.6 AS builder

WORKDIR /workspace
# Copy the Go Modules manifests
Expand All @@ -18,7 +18,8 @@ COPY cmd/ cmd/
COPY pkg/ pkg/

# Build
RUN CGO_ENABLED=0 go build -a -o service cmd/service/main.go
ARG TARGETOS TARGETARCH
RUN GOOS="$TARGETOS" GOARCH="$TARGETARCH" CGO_ENABLED=0 go build -a -o service cmd/service/main.go

# Use distroless as minimal base image to package the service binary
# Refer to https://github.com/GoogleContainerTools/distroless for more details
Expand Down
5 changes: 3 additions & 2 deletions auto-discovery/kubernetes/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# SPDX-License-Identifier: Apache-2.0

# Build the manager binary
FROM golang:1.24.6 AS builder
FROM --platform=$BUILDPLATFORM golang:1.24.6 AS builder

WORKDIR /workspace
# Copy the Go Modules manifests
Expand All @@ -19,7 +19,8 @@ COPY controllers/ controllers/
COPY pkg/ pkg/

# Build
RUN CGO_ENABLED=0 go build -a -o manager main.go
ARG TARGETOS TARGETARCH
RUN GOOS="$TARGETOS" GOARCH="$TARGETARCH" CGO_ENABLED=0 go build -a -o manager main.go

# Use distroless as minimal base image to package the manager binary
# Refer to https://github.com/GoogleContainerTools/distroless for more details
Expand Down
5 changes: 3 additions & 2 deletions lurker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# SPDX-License-Identifier: Apache-2.0

# Build the manager binary
FROM golang:1.24.6 AS builder
FROM --platform=$BUILDPLATFORM golang:1.24.6 AS builder

WORKDIR /workspace
# Copy the Go Modules manifests
Expand All @@ -17,7 +17,8 @@ RUN go mod download
COPY main.go main.go

# Build
RUN CGO_ENABLED=0 go build -a -o lurker main.go
ARG TARGETOS TARGETARCH
RUN GOOS="$TARGETOS" GOARCH="$TARGETARCH" CGO_ENABLED=0 go build -a -o lurker main.go

# Use distroless as minimal base image to package the manager binary
# Refer to https://github.com/GoogleContainerTools/distroless for more details
Expand Down
5 changes: 3 additions & 2 deletions operator/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# SPDX-License-Identifier: Apache-2.0

# Build the manager binary
FROM golang:1.24.6 AS builder
FROM --platform=$BUILDPLATFORM golang:1.24.6 AS builder

WORKDIR /workspace
# Copy the Go Modules manifests
Expand All @@ -21,7 +21,8 @@ COPY internal/ internal/
COPY utils/ utils/

# Build
RUN CGO_ENABLED=0 go build -a -o manager main.go
ARG TARGETOS TARGETARCH
RUN GOOS="$TARGETOS" GOARCH="$TARGETARCH" CGO_ENABLED=0 go build -a -o manager main.go

# Use distroless as minimal base image to package the manager binary
# Refer to https://github.com/GoogleContainerTools/distroless for more details
Expand Down
2 changes: 1 addition & 1 deletion scanners/ffuf/scanner/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

FROM --platform=$BUILDPLATFORM golang:1.24-alpine AS builder
ARG scannerVersion
RUN GOOS=$TARGETOS GOARCH=$TARGETARCH CGO_ENABLED=0 go install github.com/ffuf/ffuf/v2@$scannerVersion
RUN GOOS="$TARGETOS" GOARCH="$TARGETARCH" CGO_ENABLED=0 go install github.com/ffuf/ffuf/v2@$scannerVersion

RUN mkdir -p /home/ffuf/.config/ffuf
RUN mkdir -p /home/ffuf/.config/ffuf/scraper
Expand Down
Loading
0