-
Notifications
You must be signed in to change notification settings - Fork 38
/
Dockerfile
79 lines (68 loc) · 2.99 KB
/
Dockerfile
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
ARG GO_VERSION=1.13.15
# OS-X SDK parameters
# NOTE: when changing version here, make sure to also change OSX_CODENAME below to match
# TODO Go 1.13 supports macOS 10.11 (el capitan) and higher. Update this to 10.11 SDK
# once an updated version of the SDK is available on s3.dockerproject.org
ARG OSX_SDK=MacOSX10.10.sdk
ARG OSX_SDK_SUM=631b4144c6bf75bf7a4d480d685a9b5bda10ee8d03dbf0db829391e2ef858789
# OSX-cross parameters. Go 1.11 requires OSX >= 10.10
# TODO Go 1.13 supports macOS 10.11 (el capitan) and higher. Update this to 10.11
# once an updated version of the SDK is available on s3.dockerproject.org
ARG OSX_VERSION_MIN=10.10
ARG OSX_CROSS_COMMIT=a9317c18a3a457ca0a657f08cc4d0d43c6cf8953
# Libtool parameters
ARG LIBTOOL_VERSION=2.4.6
# TODO Go 1.13 supports macOS 10.11 (el capitan) and higher. Update this to 'el_capitan'
# once an updated version of the SDK is available on s3.dockerproject.org
ARG OSX_CODENAME=yosemite
FROM golang:${GO_VERSION}-buster AS base
ARG APT_MIRROR
RUN sed -ri "s/(httpredir|deb).debian.org/${APT_MIRROR:-deb.debian.org}/g" /etc/apt/sources.list \
&& sed -ri "s/(security).debian.org/${APT_MIRROR:-security.debian.org}/g" /etc/apt/sources.list
ENV OSX_CROSS_PATH=/osxcross
FROM base AS osx-sdk
ARG OSX_SDK
ARG OSX_SDK_SUM
ADD https://s3.dockerproject.org/darwin/v2/${OSX_SDK}.tar.xz "${OSX_CROSS_PATH}/tarballs/${OSX_SDK}.tar.xz"
RUN echo "${OSX_SDK_SUM}" "${OSX_CROSS_PATH}/tarballs/${OSX_SDK}.tar.xz" | sha256sum -c -
FROM base AS osx-cross-base
ARG DEBIAN_FRONTEND=noninteractive
# Dependencies for https://github.com/tpoechtrager/osxcross:
# TODO split these into "build-time" and "runtime" dependencies so that build-time deps do not end up in the final image
RUN apt-get update -qq && apt-get install -y -q --no-install-recommends \
clang \
file \
llvm \
patch \
xz-utils \
&& rm -rf /var/lib/apt/lists/*
FROM osx-cross-base AS osx-cross
ARG OSX_CROSS_COMMIT
WORKDIR "${OSX_CROSS_PATH}"
RUN git clone https://github.com/tpoechtrager/osxcross.git . \
&& git checkout -q "${OSX_CROSS_COMMIT}" \
&& rm -rf ./.git
COPY --from=osx-sdk "${OSX_CROSS_PATH}/." "${OSX_CROSS_PATH}/"
ARG OSX_VERSION_MIN
RUN UNATTENDED=yes OSX_VERSION_MIN=${OSX_VERSION_MIN} ./build.sh
FROM base AS libtool
ARG LIBTOOL_VERSION
ARG OSX_CODENAME
ARG OSX_SDK
RUN mkdir -p "${OSX_CROSS_PATH}/target/SDK/${OSX_SDK}/usr/"
RUN curl -fsSL "https://homebrew.bintray.com/bottles/libtool-${LIBTOOL_VERSION}.${OSX_CODENAME}.bottle.tar.gz" \
| gzip -dc | tar xf - \
-C "${OSX_CROSS_PATH}/target/SDK/${OSX_SDK}/usr/" \
--strip-components=2 \
"libtool/${LIBTOOL_VERSION}/include/" \
"libtool/${LIBTOOL_VERSION}/lib/"
FROM osx-cross-base AS final
ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get update -qq && apt-get install -y -q --no-install-recommends \
libltdl-dev \
gcc-mingw-w64 \
parallel \
&& rm -rf /var/lib/apt/lists/*
COPY --from=osx-cross "${OSX_CROSS_PATH}/." "${OSX_CROSS_PATH}/"
COPY --from=libtool "${OSX_CROSS_PATH}/." "${OSX_CROSS_PATH}/"
ENV PATH=${OSX_CROSS_PATH}/target/bin:$PATH