-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathDockerfile
156 lines (132 loc) · 5.72 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
ARG GO_VERSION=1.22
# OS-X SDK parameters
# NOTE: when changing version here, make sure to also change OSX_CODENAME below to match
ARG OSX_SDK=MacOSX11.3.sdk
# To get the SHA sum do:8056533314010954413
# wget https://s3.dockerproject.org/darwin/v2/${OSX_SDK}.tar.xz
#
# We no longer use this.
#
# ARG OSX_SDK_SUM=694a66095a3514328e970b14978dc78c0f4d170e590fa7b2c3d3674b75f0b713
# OSX-cross parameters. Go 1.15 requires OSX >= 10.11
ARG OSX_VERSION_MIN=11.3
# Choose latest commit from here: https://github.com/tpoechtrager/osxcross/commits/master/CHANGELOG
ARG OSX_CROSS_COMMIT=c0cb74c8c01a66be0b6d05788f05201d87d9df9f
# Libtool parameters
ARG LIBTOOL_VERSION=2.4.6_4
# Use ouput from:
#
# brew reinstall libtool --verbose --debug | grep curl
#
# You may wnant to clean the homebrew cache first.
ARG LIBTOOL_SHA=dfb94265706b7204b346e3e5d48e149d7c7870063740f0c4ab2d6ec971260517
ARG OSX_CODENAME=big_sur
FROM golang:${GO_VERSION}-bullseye 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
# This is generated from: https://github.com/tpoechtrager/osxcross#packaging-the-sdk
ADD https://storage.googleapis.com/ory.sh/build-assets/${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
RUN apt-get install -y -q --no-install-recommends \
clang \
file \
llvm \
patch \
xz-utils \
cmake make libssl-dev lzma-dev libxml2-dev \
gcc g++ zlib1g-dev libmpc-dev libmpfr-dev libgmp-dev
RUN 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 LIBTOOL_SHA
ARG OSX_CODENAME
ARG OSX_SDK
RUN mkdir -p "${OSX_CROSS_PATH}/target/SDK/${OSX_SDK}/usr/"
RUN curl -L --globoff --show-error --user-agent Homebrew/3.2.9\ \(Macintosh\;\ Intel\ Mac\ OS\ X\ 11.5.1\)\ curl/7.64.1 --header Accept-Language:\ en --retry 3 --header Authorization:\ Bearer\ QQ== --location --silent --request GET https://ghcr.io/v2/homebrew/core/libtool/blobs/sha256:${LIBTOOL_SHA} --output - \
| 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 curl -fsSL test.docker.com -o get-docker.sh && sh get-docker.sh
RUN curl -sL https://deb.nodesource.com/setup_21.x | bash -s
RUN apt-get update -y
RUN apt-get upgrade -y
RUN apt-get install -y --no-install-recommends \
libltdl-dev \
gcc-mingw-w64 \
parallel \
apt-transport-https \
ca-certificates \
curl \
gnupg2 \
software-properties-common \
gettext \
jq \
nodejs \
build-essential \
docker-ce docker-ce-cli containerd.io \
gcc cpp gcc-9 binutils
RUN apt-get update -y
RUN apt-get install -y \
gcc-aarch64-linux-gnu \
gcc-arm-linux-gnueabihf
RUN rm -rf /var/lib/apt/lists/*
# Install libusl with arm support which is only available on "bookworm"
RUN echo "deb http://ftp.us.debian.org/debian bookworm main" >> /etc/apt/sources.list
RUN apt-get update -y
RUN apt-get install -y \
musl-tools
RUN rm -rf /var/lib/apt/lists/*
ARG GORELEASER_VERSION=2.3.2
RUN curl -LO https://github.com/goreleaser/goreleaser/releases/download/v${GORELEASER_VERSION}/goreleaser_Linux_x86_64.tar.gz \
&& mkdir -p goreleaser_Linux_x86_64 \
&& tar -xvf goreleaser_Linux_x86_64.tar.gz -C goreleaser_Linux_x86_64 \
&& mv goreleaser_Linux_x86_64/goreleaser /usr/local/bin/goreleaser-oss \
&& rm -rf goreleaser_Linux_x86_64.* goreleaser_Linux_x86_64/
RUN curl -Lo "goreleaser-pro_Linux_x86_64.tar.gz" "https://github.com/goreleaser/goreleaser-pro/releases/download/v${GORELEASER_VERSION}-pro/goreleaser-pro_Linux_x86_64.tar.gz" \
&& mkdir -p goreleaser-pro_Linux_x86_64 \
&& tar -xvf goreleaser-pro_Linux_x86_64.tar.gz -C goreleaser-pro_Linux_x86_64 \
&& mv goreleaser-pro_Linux_x86_64/goreleaser /usr/local/bin/goreleaser \
&& rm -rf goreleaser-pro_Linux_x86_64.* goreleaser-pro_Linux_x86_64/
RUN goreleaser --version && goreleaser-oss --version
RUN go install github.com/sigstore/cosign/cmd/cosign@v1.3.0
RUN go install github.com/CycloneDX/cyclonedx-gomod@v1.0.0
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
RUN curl -O https://musl.cc/aarch64-linux-musl-cross.tgz \
&& tar xzf aarch64-linux-musl-cross.tgz \
&& mv aarch64-linux-musl-cross /aarch64-linux-musl-cross
RUN curl -O https://musl.cc/arm-linux-musleabihf-cross.tgz \
&& tar xzf arm-linux-musleabihf-cross.tgz \
&& mv arm-linux-musleabihf-cross /arm-linux-musleabihf-cross
ENV PATH=/aarch64-linux-musl-cross/bin:/arm-linux-musleabihf-cross/bin:$PATH
COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
VOLUME /project
WORKDIR /project
RUN git config --global --add safe.directory /project
ENTRYPOINT ["/entrypoint.sh"]
CMD ["-v"]