-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathContainerfile.download
More file actions
60 lines (48 loc) · 2.08 KB
/
Containerfile.download
File metadata and controls
60 lines (48 loc) · 2.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# This Dockerfile is used to cross-build the kubectl-oadp binaries for all platforms
# It also builds a Go server that serves the built binaries
FROM --platform=$BUILDPLATFORM golang:1.25 AS builder
ARG TARGETOS
ARG TARGETARCH
WORKDIR /app
COPY go.mod go.sum ./
RUN go mod download && go mod verify
COPY . .
# Version information
ARG VERSION=dev
ARG GIT_COMMIT=unknown
# Build release binaries for all platforms as direct executables
# with clean names for direct curl/wget download.
RUN set -e && \
mkdir -p /archives && \
for platform in linux/amd64 linux/arm64 darwin/amd64 darwin/arm64 windows/amd64 windows/arm64; do \
os=$(echo $platform | cut -d'/' -f1) && \
arch=$(echo $platform | cut -d'/' -f2) && \
if [ "$os" = "windows" ]; then \
output="kubectl-oadp_${os}_${arch}.exe"; \
else \
output="kubectl-oadp_${os}_${arch}"; \
fi && \
echo "Building $output..." && \
CGO_ENABLED=0 GOOS=$os GOARCH=$arch \
go build -trimpath \
-ldflags="-s -w \
-X github.com/vmware-tanzu/velero/pkg/buildinfo.Version=${VERSION} \
-X github.com/vmware-tanzu/velero/pkg/buildinfo.GitSHA=${GIT_COMMIT} \
-X github.com/vmware-tanzu/velero/pkg/buildinfo.GitTreeState=clean" \
-o /archives/$output \
. && \
(cd /archives && sha256sum $output > $output.sha256); \
done && \
chmod -x /archives/kubectl-oadp_* && \
cp LICENSE /archives/LICENSE && \
rm -rf /root/.cache/go-build /tmp/*
# Build the download server for the TARGET platform (the arch this container will run on)
RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} \
go build -trimpath -o /usr/local/bin/download-server ./cmd/downloads/ && \
go clean -cache -modcache -testcache && \
rm -rf /root/.cache/go-build /go/pkg
FROM registry.access.redhat.com/ubi9/ubi-minimal:latest
COPY --from=builder /archives /archives
COPY --from=builder /usr/local/bin/download-server /usr/local/bin/download-server
EXPOSE 8080
CMD ["/usr/local/bin/download-server"]