mirror of
https://github.com/netbirdio/dex.git
synced 2026-05-22 18:43:53 -07:00
build: add xx to cross-compile binaries in Docker
Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
This commit is contained in:
+22
-11
@@ -1,19 +1,30 @@
|
||||
ARG BASE_IMAGE=alpine
|
||||
|
||||
FROM golang:1.20.3-alpine3.16 AS builder
|
||||
FROM --platform=$BUILDPLATFORM tonistiigi/xx AS xx
|
||||
|
||||
FROM --platform=$BUILDPLATFORM golang:1.20.3-alpine3.16 AS builder
|
||||
|
||||
RUN apk add --no-cache --update alpine-sdk ca-certificates openssl clang lld
|
||||
|
||||
COPY --from=xx / /
|
||||
|
||||
ARG TARGETPLATFORM
|
||||
|
||||
RUN CC=$(xx-info)-gcc
|
||||
RUN xx-go --wrap
|
||||
|
||||
# gcc is only installed for libgcc
|
||||
RUN xx-apk --update --no-cache add musl-dev gcc
|
||||
|
||||
# lld has issues building static binaries for ppc so prefer ld for it
|
||||
RUN [ "$(xx-info arch)" != "ppc64le" ] || XX_CC_PREFER_LINKER=ld xx-clang --setup-target-triple
|
||||
|
||||
WORKDIR /usr/local/src/dex
|
||||
|
||||
RUN apk add --no-cache --update alpine-sdk ca-certificates openssl
|
||||
|
||||
ARG TARGETOS
|
||||
ARG TARGETARCH
|
||||
ARG TARGETVARIANT=""
|
||||
|
||||
ENV GOOS=${TARGETOS} GOARCH=${TARGETARCH} GOARM=${TARGETVARIANT}
|
||||
|
||||
ARG GOPROXY
|
||||
|
||||
ENV CGO_ENABLED=1
|
||||
|
||||
COPY go.mod go.sum ./
|
||||
COPY api/v2/go.mod api/v2/go.sum ./api/v2/
|
||||
RUN go mod download
|
||||
@@ -37,8 +48,8 @@ ARG TARGETVARIANT
|
||||
ENV GOMPLATE_VERSION=v3.11.4
|
||||
|
||||
RUN wget -O /usr/local/bin/gomplate \
|
||||
"https://github.com/hairyhenderson/gomplate/releases/download/${GOMPLATE_VERSION}/gomplate_${TARGETOS:-linux}-${TARGETARCH:-amd64}${TARGETVARIANT}" \
|
||||
&& chmod +x /usr/local/bin/gomplate
|
||||
"https://github.com/hairyhenderson/gomplate/releases/download/${GOMPLATE_VERSION}/gomplate_${TARGETOS:-linux}-${TARGETARCH:-amd64}${TARGETVARIANT}" \
|
||||
&& chmod +x /usr/local/bin/gomplate
|
||||
|
||||
# For Dependabot to detect base image versions
|
||||
FROM alpine:3.17.3 AS alpine
|
||||
|
||||
Reference in New Issue
Block a user