-
Notifications
You must be signed in to change notification settings - Fork 2
/
Dockerfile.osx
243 lines (212 loc) · 8.43 KB
/
Dockerfile.osx
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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
FROM debian:bullseye-slim
ARG DOCKER_RELEASE_STAGE
ARG INSTALLER_VERSION
ARG DOCKER_VERSION
ARG DOCKER_BUILDX_VERSION
ARG DOCKER_COMPOSE2_VERSION
ARG DOCKER_MACHINE_VERSION
ARG GITLAB_MACHINE_VERSION
ARG T2D_MACHINE_VERSION
ARG VBOX_VERSION
ARG VBOX_VERSION_ALPHA
ARG VBOX_REV
ARG MIXPANEL_TOKEN
RUN echo "deb http://deb.debian.org/debian bullseye-backports main" \
> /etc/apt/sources.list.d/backports.list && \
apt-get update && \
apt-get -y install \
apt-utils autoconf build-essential curl \
libxml2-dev libssl-dev libbz2-dev \
zlib1g-dev \
cpio \
&& apt-get -y install -t bullseye-backports 7zip
# We need the bomutils to create the Mac OS X Bill of Materials (BOM) files.
# https://github.com/hogliux/bomutils
RUN curl -fsSL https://github.com/hogliux/bomutils/archive/0.2.tar.gz | tar xvz && \
cd bomutils-* && \
make && make install
# Needed to pack/unpack the .pkg files
RUN curl -fsSL https://github.com/mackyle/xar/archive/xar-1.6.1.tar.gz | tar xvz && \
cd xar-*/xar && \
sed -i 's/OpenSSL_add_all_ciphers/OPENSSL_init_crypto/g' \
/xar-*/xar/configure.ac && \
./autogen.sh && ./configure && \
make && make install
ENV VBOX_URL https://download.virtualbox.org/virtualbox/$VBOX_VERSION
RUN curl -fsSL -o /vbox.dmg \
"$VBOX_URL/VirtualBox-$VBOX_VERSION$VBOX_VERSION_ALPHA-$VBOX_REV-OSX.dmg" \
&& echo "$(curl -fsSL "$VBOX_URL"'/SHA256SUMS' \
| awk '$2 ~ /-OSX.dmg$/ { print $1 }') */vbox.dmg" \
| sha256sum -c -
# Why '--strip-components 3'? The client binary is in usr/local/bin/docker in
# the tar archive. If we extract directly, it will create a usr/local/bin
# subdirectory (not what we want). So we use --strip-components to remove the
# `usr/local/bin` part and drop the bin in the current directory.
RUN curl -fsSL -o dockerbins.tgz "https://download.docker.com/mac/static/${DOCKER_RELEASE_STAGE}/x86_64/docker-${DOCKER_VERSION}.tgz" && \
tar xvf dockerbins.tgz docker/docker --strip-components 1 && \
rm dockerbins.tgz
# docker buildx plugin
ENV DOCKER_BUILDX_URL "https://github.com/docker/buildx/releases/download/v$DOCKER_BUILDX_VERSION"
ENV DOCKER_BUILDX_FILE "buildx-v$DOCKER_BUILDX_VERSION.darwin-amd64"
RUN mkdir cli-plugins && \
curl -fsSL -o cli-plugins/docker-buildx \
"$DOCKER_BUILDX_URL/$DOCKER_BUILDX_FILE"
# Currently there are no sha256 hashes for darwin in checksums.txt
# && echo "$(curl -fsSL "$DOCKER_BUILDX_URL"'/checksums.txt' \
# | awk '$2 ~ /darwin-amd64$/ { print $1 }') *cli-plugins/docker-buildx" \
# | sha256sum -c -
RUN chmod +x /docker && chmod +x /cli-plugins/*
# Docker Machine
ENV DOCKER_MACHINE_URL "https://github.com/kaosagnt/docker-machine/releases/download/v$DOCKER_MACHINE_VERSION-$GITLAB_MACHINE_VERSION-$T2D_MACHINE_VERSION"
ENV DOCKER_MACHINE_FILE "docker-machine-Darwin-x86_64"
RUN curl -fsSL -o /docker-machine \
"$DOCKER_MACHINE_URL/$DOCKER_MACHINE_FILE" \
&& echo "$(curl -fsSL "$DOCKER_MACHINE_URL"'/SHA256SUMS.txt' \
| awk '$2 ~ /Darwin-x86_64$/ { print $1 }') */docker-machine" \
| sha256sum -c -
RUN chmod +x /docker-machine
# Docker Compose 2.x is now a plugin.
ENV DOCKER_COMPOSE2_URL "https://github.com/docker/compose/releases/download/v$DOCKER_COMPOSE2_VERSION"
ENV DOCKER_COMPOSE2_FILE "docker-compose-darwin-x86_64"
RUN curl -fsSL -o /docker-compose2 \
"$DOCKER_COMPOSE2_URL/$DOCKER_COMPOSE2_FILE" \
&& echo "$(curl -fsSL "$DOCKER_COMPOSE2_URL"'/checksums.txt' \
| awk '$2 ~ /darwin-x86_64$/ { print $1 }') */docker-compose2" \
| sha256sum -c -
RUN chmod +x /docker-compose2
# boot2docker iso
ENV BOOT2DOCKER_URL "https://github.com/kaosagnt/boot2docker-xfs-ng/releases/download/$DOCKER_VERSION"
ENV BOOT2DOCKER_FILE "boot2docker.iso"
RUN curl -fsSL -o /boot2docker.iso \
"$BOOT2DOCKER_URL/$BOOT2DOCKER_FILE" \
&& echo "$(curl -fsSL "$BOOT2DOCKER_URL"'/SHA256SUMS.txt' \
| awk '$2 ~ /iso$/ { print $1 }') */boot2docker.iso" \
| sha256sum -c -
# Extract the VirtualBox .pkg
RUN mkdir -p /mpkg/vbox && \
cd /mpkg/vbox && \
7zz x /vbox.dmg -ir'!*.pkg' && \
rm -rf vbox.dmg
# Extract the .pkg files
RUN cd /mpkg/vbox && \
mv VirtualBox.pkg /tmp && \
xar -xf /tmp/VirtualBox.pkg && \
rm -rf /tmp/VirtualBox.pkg
RUN cd /mpkg/vbox && \
mv *.pkg .. && \
rm -rf vbox
# Add components
COPY osx/mpkg/Distribution /mpkg/Distribution
# docker.pkg
COPY osx/mpkg/docker.pkg /mpkg/docker.pkg
RUN cd /mpkg/docker.pkg && \
mkdir rootfs && \
cd rootfs && \
mkdir -p usr/local/bin && \
mv /docker usr/local/bin/ && \
mkdir -p usr/local/lib/docker/cli-plugins && \
mv /cli-plugins/* usr/local/lib/docker/cli-plugins/ && \
ls -al /usr/local/bin/ && \
find . | cpio -o --format odc | gzip -c > ../Payload && \
mkbom . ../Bom && \
sed -i \
-e "s/%DOCKER_NUMBER_OF_FILES%/`find . | wc -l`/g" \
-e "s/%DOCKER_INSTALL_KBYTES%/`du -sk | cut -f1`/g" \
-e "s/%DOCKER_VERSION%/$DOCKER_VERSION/g" \
../PackageInfo /mpkg/Distribution && \
cd .. && \
rm -rf ./rootfs
# dockermachine.pkg
COPY osx/mpkg/dockermachine.pkg /mpkg/dockermachine.pkg
RUN cd /mpkg/dockermachine.pkg && \
mkdir rootfs && \
cd rootfs && \
mkdir -p usr/local/bin && \
mv /docker-machine usr/local/bin/ && \
ls -al /usr/local/bin/ && \
find . | cpio -o --format odc | gzip -c > ../Payload && \
mkbom . ../Bom && \
sed -i \
-e "s/%DOCKERMACHINE_NUMBER_OF_FILES%/`find . | wc -l`/g" \
-e "s/%DOCKERMACHINE_INSTALL_KBYTES%/`du -sk | cut -f1`/g" \
-e "s/%DOCKERMACHINE_VERSION%/$DOCKER_MACHINE_VERSION/g" \
../PackageInfo /mpkg/Distribution && \
cd .. && \
rm -rf ./rootfs
# dockercompose2.pkg
COPY osx/mpkg/dockercompose2.pkg /mpkg/dockercompose2.pkg
RUN cd /mpkg/dockercompose2.pkg && \
mkdir rootfs && \
cd rootfs && \
mkdir -p usr/local/lib/docker/cli-plugins && \
mv /docker-compose2 usr/local/lib/docker/cli-plugins/docker-compose && \
ls -al usr/local/lib/docker/cli-plugins && \
find . | cpio -o --format odc | gzip -c > ../Payload && \
mkbom . ../Bom && \
sed -i \
-e "s/%DOCKERCOMPOSE2_NUMBER_OF_FILES%/`find . | wc -l`/g" \
-e "s/%DOCKERCOMPOSE2_INSTALL_KBYTES%/`du -sk | cut -f1`/g" \
-e "s/%DOCKERCOMPOSE2_VERSION%/$DOCKER_COMPOSE2_VERSION/g" \
../PackageInfo /mpkg/Distribution && \
cd .. && \
rm -rf ./rootfs
# boot2dockeriso.pkg
COPY osx/mpkg/boot2dockeriso.pkg /mpkg/boot2dockeriso.pkg
RUN cd /mpkg/boot2dockeriso.pkg && \
cd Scripts && find . | cpio -o --format odc | gzip -c > ../Scripts.bin && cd .. && \
rm -r Scripts && mv Scripts.bin Scripts && \
mkdir ./rootfs && \
cd ./rootfs && \
cp /boot2docker.iso . && \
find . | cpio -o --format odc | gzip -c > ../Payload && \
mkbom . ../Bom && \
sed -i \
-e "s/%BOOT2DOCKER_ISO_NUMBER_OF_FILES%/`find . | wc -l`/g" \
-e "s/%BOOT2DOCKER_ISO_INSTALL_KBYTES%/`du -sk | cut -f1`/g" \
-e "s/%DOCKER_VERSION%/$DOCKER_VERSION/g" \
../PackageInfo /mpkg/Distribution && \
cd .. && \
rm -rf ./rootfs
# dockerquickstartterminalapp.pkg
COPY osx/mpkg/dockerquickstartterminalapp.pkg /mpkg/dockerquickstartterminalapp.pkg
COPY osx/mpkg/quickstart.app /mpkg/quickstart.app
RUN cd /mpkg/dockerquickstartterminalapp.pkg && \
mkdir ./rootfs && \
cd ./rootfs && \
mv /mpkg/quickstart.app ./Docker\ Quickstart\ Terminal.app && \
find . | cpio -o --format odc | gzip -c > ../Payload && \
mkbom . ../Bom && \
sed -i \
-e "s/%DOCKERQUICKSTARTTERMINALAPP_NUMBER_OF_FILES%/`find . | wc -l`/g" \
-e "s/%DOCKERQUICKSTARTTERMINALAPP_INSTALL_KBYTES%/`du -sk | cut -f1`/g" \
-e "s/%DOCKERQUICKSTARTTERMINALAPP_VERSION%/$INSTALLER_VERSION/g" \
../PackageInfo /mpkg/Distribution && \
cd .. && \
rm -rf ./rootfs
COPY osx/mpkg/Resources /mpkg/Resources
COPY osx/mpkg/Plugins /mpkg/Plugins
RUN sed -i \
-e "s/%MIXPANEL_TOKEN%/$MIXPANEL_TOKEN/g" \
-e "s/%INSTALLER_VERSION%/$INSTALLER_VERSION/g" \
mpkg/Plugins/*.bundle/Contents/Info.plist
RUN sed -i \
-e "s/%INSTALLER_VERSION%/$INSTALLER_VERSION/g" \
mpkg/Plugins/*.bundle/Contents/Resources/*.html
RUN sed -i \
-e "s/%INSTALLER_VERSION%/$INSTALLER_VERSION/g" \
mpkg/Resources/en.lproj/welcome.rtfd/TXT.rtf
RUN sed -i \
-e "s/%VBOX_VERSION%/$VBOX_VERSION/g" \
/mpkg/Distribution && \
sed -i \
-e "s/%VBOX_VERSION%/$VBOX_VERSION/g" \
-e "s/%DOCKER_VERSION%/$DOCKER_VERSION/g" \
-e "s/%DOCKERMACHINE_VERSION%/$DOCKER_MACHINE_VERSION/g" \
-e "s/%DOCKERCOMPOSE2_VERSION%/$DOCKER_COMPOSE2_VERSION/g" \
-e "s/%DOCKER_VERSION%/$DOCKER_VERSION/g" \
-e "s/%DOCKERQUICKSTARTTERMINALAPP_VERSION%/$INSTALLER_VERSION/g" \
mpkg/Resources/en.lproj/Localizable.strings
# Repackage back. Yes, --compression=none is mandatory.
# or this won't install in OSX.
RUN cd /mpkg && \
xar -c --compression=none -f /Toolbox2docker.pkg .