forked from boot2docker/boot2docker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
294 lines (244 loc) · 10.8 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
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
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
FROM debian:jessie
RUN apt-get update && apt-get -y install unzip \
xz-utils \
curl \
bc \
git \
build-essential \
cpio \
gcc libc6 libc6-dev \
kmod \
squashfs-tools \
genisoimage \
xorriso \
syslinux \
isolinux \
automake \
pkg-config \
p7zip-full
# https://www.kernel.org/
ENV KERNEL_VERSION 4.0.5
# Fetch the kernel sources
RUN curl --retry 10 https://www.kernel.org/pub/linux/kernel/v${KERNEL_VERSION%%.*}.x/linux-$KERNEL_VERSION.tar.xz | tar -C / -xJ && \
mv /linux-$KERNEL_VERSION /linux-kernel
# http://aufs.sourceforge.net/
ENV AUFS_REPO https://github.com/sfjro/aufs4-standalone
ENV AUFS_BRANCH aufs4.0
ENV AUFS_COMMIT a8c8a849e236d7f7fa121c8344899a796ccf7b8f
# we use AUFS_COMMIT to get stronger repeatability guarantees
# Download AUFS and apply patches and files, then remove it
RUN git clone -b "$AUFS_BRANCH" "$AUFS_REPO" aufs-standalone && \
cd aufs-standalone && \
git checkout $AUFS_COMMIT && \
cd /linux-kernel && \
cp -r /aufs-standalone/Documentation /linux-kernel && \
cp -r /aufs-standalone/fs /linux-kernel && \
cp -r /aufs-standalone/include/uapi/linux/aufs_type.h /linux-kernel/include/uapi/linux/ && \
set -e && for patch in \
/aufs-standalone/aufs*-kbuild.patch \
/aufs-standalone/aufs*-base.patch \
/aufs-standalone/aufs*-mmap.patch \
/aufs-standalone/aufs*-standalone.patch \
/aufs-standalone/aufs*-loopback.patch \
; do \
patch -p1 < "$patch"; \
done
COPY kernel_config /linux-kernel/.config
RUN jobs=$(nproc); \
cd /linux-kernel && \
make -j ${jobs} oldconfig && \
make -j ${jobs} bzImage && \
make -j ${jobs} modules
# The post kernel build process
ENV ROOTFS /rootfs
ENV TCL_REPO_BASE http://tinycorelinux.net/6.x/x86_64
# Note that the ncurses is here explicitly so that top continues to work
ENV TCZ_DEPS iptables \
iproute2 \
openssh openssl-1.0.0 \
tar \
gcc_libs \
ncurses \
acpid \
xz liblzma \
git expat2 libiconv libidn libgpg-error libgcrypt libssh2 \
nfs-utils tcp_wrappers portmap rpcbind libtirpc \
curl ntpclient \
procps glib2 libtirpc libffi fuse pcre \
parted
# Make the ROOTFS
RUN mkdir -p $ROOTFS
# Prepare the build directory (/tmp/iso)
RUN mkdir -p /tmp/iso/boot
# Install the kernel modules in $ROOTFS
RUN cd /linux-kernel && \
make INSTALL_MOD_PATH=$ROOTFS modules_install firmware_install
# Remove useless kernel modules, based on unclejack/debian2docker
RUN cd $ROOTFS/lib/modules && \
rm -rf ./*/kernel/sound/* && \
rm -rf ./*/kernel/drivers/gpu/* && \
rm -rf ./*/kernel/drivers/infiniband/* && \
rm -rf ./*/kernel/drivers/isdn/* && \
rm -rf ./*/kernel/drivers/media/* && \
rm -rf ./*/kernel/drivers/staging/lustre/* && \
rm -rf ./*/kernel/drivers/staging/comedi/* && \
rm -rf ./*/kernel/fs/ocfs2/* && \
rm -rf ./*/kernel/net/bluetooth/* && \
rm -rf ./*/kernel/net/mac80211/* && \
rm -rf ./*/kernel/net/wireless/*
# Install libcap
RUN curl -L http://http.debian.net/debian/pool/main/libc/libcap2/libcap2_2.22.orig.tar.gz | tar -C / -xz && \
cd /libcap-2.22 && \
sed -i 's/LIBATTR := yes/LIBATTR := no/' Make.Rules && \
make && \
mkdir -p output && \
make prefix=`pwd`/output install && \
mkdir -p $ROOTFS/usr/local/lib && \
cp -av `pwd`/output/lib64/* $ROOTFS/usr/local/lib
# Make sure the kernel headers are installed for aufs-util, and then build it
RUN cd /linux-kernel && \
make INSTALL_HDR_PATH=/tmp/kheaders headers_install && \
cd / && \
git clone http://git.code.sf.net/p/aufs/aufs-util && \
cd /aufs-util && \
git checkout aufs4.0 && \
CPPFLAGS="-I/tmp/kheaders/include" CLFAGS=$CPPFLAGS LDFLAGS=$CPPFLAGS make && \
DESTDIR=$ROOTFS make install && \
rm -rf /tmp/kheaders
# Prepare the ISO directory with the kernel
RUN cp -v /linux-kernel/arch/x86_64/boot/bzImage /tmp/iso/boot/vmlinuz64
# Download the rootfs, don't unpack it though:
RUN curl -L -o /tcl_rootfs.gz $TCL_REPO_BASE/release/distribution_files/rootfs64.gz
# Install the TCZ dependencies
RUN for dep in $TCZ_DEPS; do \
echo "Download $TCL_REPO_BASE/tcz/$dep.tcz" &&\
curl -L -o /tmp/$dep.tcz $TCL_REPO_BASE/tcz/$dep.tcz && \
unsquashfs -f -d $ROOTFS /tmp/$dep.tcz && \
rm -f /tmp/$dep.tcz ;\
done
# get generate_cert
RUN curl -L -o $ROOTFS/usr/local/bin/generate_cert https://github.com/SvenDowideit/generate_cert/releases/download/0.1/generate_cert-0.1-linux-386/ && \
chmod +x $ROOTFS/usr/local/bin/generate_cert
# Build VBox guest additions
ENV VBOX_VERSION 4.3.28
RUN mkdir -p /vboxguest && \
cd /vboxguest && \
\
curl -L -o vboxguest.iso http://download.virtualbox.org/virtualbox/${VBOX_VERSION}/VBoxGuestAdditions_${VBOX_VERSION}.iso && \
7z x vboxguest.iso -ir'!VBoxLinuxAdditions.run' && \
rm vboxguest.iso && \
\
sh VBoxLinuxAdditions.run --noexec --target . && \
mkdir amd64 && tar -C amd64 -xjf VBoxGuestAdditions-amd64.tar.bz2 && \
rm VBoxGuestAdditions*.tar.bz2 && \
\
KERN_DIR=/linux-kernel/ make -C amd64/src/vboxguest-${VBOX_VERSION} && \
cp amd64/src/vboxguest-${VBOX_VERSION}/*.ko $ROOTFS/lib/modules/$KERNEL_VERSION-boot2docker/ && \
\
mkdir -p $ROOTFS/sbin && \
cp amd64/lib/VBoxGuestAdditions/mount.vboxsf $ROOTFS/sbin/
# Build VMware Tools
ENV OVT_VERSION 9.10.0
# use fixes for post 3.19 and 4.0 kernels from https://github.com/davispuh/open-vm-tools/tree/fixed and http://git.io/vIXpn
# rebased onto the 9.10.0 release
ENV OVT_REPO https://github.com/cloudnativeapps/open-vm-tools
ENV OVT_BRANCH stable-9.10.x-kernel4-vmhgfs-fix
RUN git clone $OVT_REPO \
&& cd /open-vm-tools \
&& git checkout $OVT_BRANCH \
&& mv /open-vm-tools /vmtoolsd
RUN apt-get install -y libfuse2 libtool autoconf libglib2.0-dev libdumbnet-dev libdumbnet1 libfuse2 libfuse-dev libglib2.0-0 \
libtirpc-dev libtirpc1 libmspack-dev libssl-dev
# Compile
RUN cd /vmtoolsd/open-vm-tools && \
autoreconf -i && \
./configure --disable-multimon --disable-docs --disable-tests --with-gnu-ld \
--without-kernel-modules --without-procps --without-gtk2 \
--without-gtkmm --without-pam --without-x --without-icu \
--without-xerces --without-xmlsecurity --without-ssl && \
make LIBS="-ltirpc" CFLAGS="-Wno-implicit-function-declaration" && \
make DESTDIR=$ROOTFS install &&\
/vmtoolsd/open-vm-tools/libtool --finish $ROOTFS/usr/local/lib
# Kernel modules to build and install
ENV VM_MODULES vmhgfs
RUN cd /vmtoolsd/open-vm-tools &&\
TOPDIR=$PWD &&\
for module in $VM_MODULES; do \
cd modules/linux/$module; \
make -C /linux-kernel modules M=$PWD VM_CCVER=$(gcc -dumpversion) HEADER_DIR="/linux-kernel/include" SRCROOT=$PWD OVT_SOURCE_DIR=$TOPDIR; \
cd -; \
done && \
for module in $VM_MODULES; do \
make -C /linux-kernel INSTALL_MOD_PATH=$ROOTFS modules_install M=$PWD/modules/linux/$module; \
done
ENV LIBDNET libdnet-1.11
RUN mkdir -p /vmtoolsd/${LIBDNET} &&\
curl -L http://sourceforge.net/projects/libdnet/files/libdnet/${LIBDNET}/${LIBDNET}.tar.gz \
| tar -xzC /vmtoolsd/${LIBDNET} --strip-components 1 &&\
cd /vmtoolsd/${LIBDNET} && ./configure --build=i486-pc-linux-gnu &&\
make &&\
make install && make DESTDIR=$ROOTFS install
# Horrible hack again
RUN cd $ROOTFS && cd usr/local/lib && ln -s libdnet.1 libdumbnet.so.1 &&\
cd $ROOTFS && ln -s lib lib64
# Make sure that all the modules we might have added are recognized (especially VBox guest additions)
RUN depmod -a -b $ROOTFS $KERNEL_VERSION-boot2docker
COPY VERSION $ROOTFS/etc/version
RUN cp -v $ROOTFS/etc/version /tmp/iso/version
# Get the Docker version that matches our boot2docker version
# Note: `docker version` returns non-true when there is no server to ask
RUN curl -L -o $ROOTFS/usr/local/bin/docker https://get.docker.io/builds/Linux/x86_64/docker-$(cat $ROOTFS/etc/version) && \
chmod +x $ROOTFS/usr/local/bin/docker && \
{ $ROOTFS/usr/local/bin/docker version || true; }
# Get the git versioning info
COPY .git /git/.git
RUN cd /git && \
GIT_BRANCH=$(git rev-parse --abbrev-ref HEAD) && \
GITSHA1=$(git rev-parse --short HEAD) && \
DATE=$(date) && \
echo "${GIT_BRANCH} : ${GITSHA1} - ${DATE}" > $ROOTFS/etc/boot2docker
# Install Tiny Core Linux rootfs
RUN cd $ROOTFS && zcat /tcl_rootfs.gz | cpio -f -i -H newc -d --no-absolute-filenames
# Copy our custom rootfs
COPY rootfs/rootfs $ROOTFS
# setup acpi config dir &
# tcl6's sshd is compiled without `/usr/local/sbin` in the path
# Boot2Docker and Docker Machine need `ip`, so I'm linking it in here
RUN cd $ROOTFS \
&& ln -s /usr/local/etc/acpi etc/ \
&& ln -s /usr/local/sbin/ip usr/sbin/
# Build the Hyper-V KVP Daemon
RUN cd /linux-kernel && \
make INSTALL_HDR_PATH=/tmp/kheaders headers_install && \
cd /linux-kernel/tools/hv && \
sed -i 's!\(^CFLAGS = .*\)!\1 -I/tmp/kheaders/include!' Makefile && \
make hv_kvp_daemon && \
cp hv_kvp_daemon $ROOTFS/usr/sbin && \
rm -rf /tmp/kheaders
# These steps can only be run once, so can't be in make_iso.sh (which can be run in chained Dockerfiles)
# see https://github.com/boot2docker/boot2docker/blob/master/doc/BUILD.md
# Make sure init scripts are executable
RUN find $ROOTFS/etc/rc.d/ $ROOTFS/usr/local/etc/init.d/ -exec chmod +x '{}' ';'
# Change MOTD
RUN mv $ROOTFS/usr/local/etc/motd $ROOTFS/etc/motd
# Make sure we have the correct bootsync
RUN mv $ROOTFS/boot*.sh $ROOTFS/opt/ && \
chmod +x $ROOTFS/opt/*.sh
# Make sure we have the correct shutdown
RUN mv $ROOTFS/shutdown.sh $ROOTFS/opt/shutdown.sh && \
chmod +x $ROOTFS/opt/shutdown.sh
# Add serial console
RUN echo "#!/bin/sh" > $ROOTFS/usr/local/bin/autologin && \
echo "/bin/login -f docker" >> $ROOTFS/usr/local/bin/autologin && \
chmod 755 $ROOTFS/usr/local/bin/autologin && \
echo 'ttyS0:2345:respawn:/sbin/getty -l /usr/local/bin/autologin 9600 ttyS0 vt100' >> $ROOTFS/etc/inittab && \
echo 'ttyS1:2345:respawn:/sbin/getty -l /usr/local/bin/autologin 9600 ttyS1 vt100' >> $ROOTFS/etc/inittab
# fix "su -"
RUN echo root > $ROOTFS/etc/sysconfig/superuser
# crontab
COPY rootfs/crontab $ROOTFS/var/spool/cron/crontabs/root
# Copy boot params
COPY rootfs/isolinux /tmp/iso/boot/isolinux
COPY rootfs/make_iso.sh /
RUN /make_iso.sh
CMD ["cat", "boot2docker.iso"]