-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile.darwin
38 lines (31 loc) · 1.51 KB
/
Dockerfile.darwin
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
FROM --platform=${BUILDPLATFORM} ghcr.io/darkness4/fc2-live-dl-go:latest-darwin-base-${TARGETARCH} AS builder
WORKDIR /work
COPY go.mod go.sum ./
RUN go mod download
COPY . .
ARG TARGETARCH
ENV OSXCROSS_PKG_CONFIG_USE_NATIVE_VARIABLES=1
ENV PKG_CONFIG_PATH=/osxcross/lib/pkgconfig:/lib/pkgconfig
ARG VERSION=dev
RUN file=$(find /osxcross/bin -name 'x86_64-apple-darwin*-clang' | head -n 1); \
version=$(echo "$file" | sed -n 's/.*x86_64-apple-darwin\([0-9]*\.[0-9]*\)-clang.*/\1/p'); \
if [ "${TARGETARCH}" = "amd64" ]; then \
export CC="x86_64-apple-darwin$version-clang"; \
export CXX="x86_64-apple-darwin$version-clang++"; \
export PKG_CONFIG="x86_64-apple-darwin$version-pkg-config"; \
export AR="x86_64-apple-darwin$version-ar"; \
export NM="x86_64-apple-darwin$version-nm"; \
export RANLIB="x86_64-apple-darwin$version-ranlib"; \
elif [ "${TARGETARCH}" = "arm64" ]; then \
export CC="aarch64-apple-darwin$version-clang"; \
export CXX="aarch64-apple-darwin$version-clang++"; \
export PKG_CONFIG="aarch64-apple-darwin$version-pkg-config"; \
export AR="aarch64-apple-darwin$version-ar"; \
export NM="aarch64-apple-darwin$version-nm"; \
export RANLIB="aarch64-apple-darwin$version-ranlib"; \
fi; \
GOARCH=${TARGETARCH} make bin/fc2-live-dl-go-darwin VERSION=${VERSION}
# Helper container to copy binaries outside the container using podman/buildx export. Unused in production.
FROM scratch AS export
ARG TARGETARCH
COPY --from=builder /work/bin/fc2-live-dl-go-darwin /fc2-live-dl-go-darwin-${TARGETARCH}