forked from florian-gauvin/Dockerfile-that-build-3-small-Docker-Images-of-Apache-Celix-Felix-and-Ace
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile~
179 lines (128 loc) · 7.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
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
# Version 1.0
FROM ubuntu:14.04
MAINTAINER Florian GAUVIN "[email protected]"
ENV DEBIAN_FRONTEND noninteractive
#Download all the packages needed
RUN apt-get update && apt-get install -y \
build-essential \
cmake \
git \
python \
wget \
unzip \
bc\
language-pack-en \
curl \
uuid-dev \
libjansson-dev \
libxml2-dev \
libcurl4-openssl-dev \
mercurial \
zip \
openjdk-7-jdk \
libcups2-dev \
libfreetype6-dev \
libasound2-dev\
libffi-dev \
libX11-dev \
libxext-dev \
libxrender-dev \
libxtst-dev \
libxt-dev \
&& apt-get clean
#Download and install the latest version of Docker (You need to be the same version to use this Dockerfile)
RUN wget -qO- https://get.docker.com/ | sh
#Prepare the usr directory by downloading in it : Buildroot, the configuration files of Buildroot, Apache Celix, Apache Felix and Apache Ace
WORKDIR /usr
RUN wget http://git.buildroot.net/buildroot/snapshot/buildroot-2015.05.tar.gz && \
tar -xf buildroot-2015.05.tar.gz && \
git clone https://github.com/florian-gauvin/Buildroot-configure.git --branch celix buildroot-configure-celix && \
git clone https://github.com/florian-gauvin/Buildroot-configure.git --branch ace buildroot-configure-ace && \
hg clone http://hg.openjdk.java.net/jdk8u/jdk8u openjdk8 && \
wget https://github.com/apache/celix/archive/develop.tar.gz && \
tar -xf develop.tar.gz && \
mkdir celix-build && \
wget http://www.eu.apache.org/dist/felix/org.apache.felix.main.distribution-5.0.1.tar.gz && \
tar -xf org.apache.felix.main.distribution-5.0.1.tar.gz && \
wget http://www.eu.apache.org/dist/ace/apache-ace-2.0.1/apache-ace-2.0.1-bin.zip && \
unzip apache-ace-2.0.1-bin.zip
#Let's begin with Apache Celix
#Copy the configuration file of Apache Celix in Buildroot and create a small base of the future image with buildroot and decompress it
RUN cp buildroot-configure-celix/.config buildroot-2015.05/
WORkDIR /usr/buildroot-2015.05
RUN make
WORKDIR /usr/buildroot-2015.05/output/images
RUN tar -xf rootfs.tar &&\
rm rootfs.tar
#Install etcd
RUN cd /tmp && curl -k -L https://github.com/coreos/etcd/releases/download/v2.0.12/etcd-v2.0.12-linux-amd64.tar.gz | tar xzf - && \
cp etcd-v2.0.12-linux-amd64/etcd /usr/buildroot-2015.05/output/images/bin/ && cp etcd-v2.0.12-linux-amd64/etcdctl /usr/buildroot-2015.05/output/images/bin/
#Add the resources
ADD resources-celix /usr/buildroot-2015.05/output/images/tmp/
#Build Celix and link against the libraries in the buildroot environment. It's not a real good way to do so but it's the only one that I have found : I remove the link.txt file and replace it by a one created manualy and not during the configuration, otherwise I don't have all the libraries linked against the environment in buildroot
WORKDIR /usr/celix-build
RUN cmake ../celix-develop -DWITH_APR=OFF -DCURL_LIBRARY=/usr/buildroot-2015.05/output/images/usr/lib/libcurl.so.4 -DZLIB_LIBRARY=/usr/buildroot-2015.05/output/images/usr/lib/libz.so.1 -DUUID_LIBRARY=/usr/buildroot-2015.05/output/images/usr/lib/libuuid.so -DBUILD_SHELL=TRUE -DBUILD_SHELL_TUI=TRUE -DBUILD_REMOTE_SHELL=TRUE -DBUILD_DEPLOYMENT_ADMIN=ON -DCMAKE_INSTALL_PREFIX=/usr/buildroot-2015.05/output/images/usr && \
rm -f /usr/celix-build/launcher/CMakeFiles/celix.dir/link.txt && \
echo "/usr/bin/cc -D_GNU_SOURCE -std=gnu99 -Wall -g CMakeFiles/celix.dir/private/src/launcher.c.o -o celix -rdynamic ../framework/libcelix_framework.so /usr/buildroot-2015.05/output/images/lib/libpthread.so.0 /usr/buildroot-2015.05/output/images/lib/libdl.so.2 /usr/buildroot-2015.05/output/images/lib/libc.so.6 /usr/buildroot-2015.05/output/images/usr/lib/libcurl.so.4 ../utils/libcelix_utils.so -lm /usr/buildroot-2015.05/output/images/usr/lib/libuuid.so /usr/buildroot-2015.05/output/images/usr/lib/libz.so.1" > /usr/celix-build/launcher/CMakeFiles/celix.dir/link.txt && \
make all && \
make install-all
# Create the config.properties file that celix will need in the futur small docker image
RUN echo "cosgi.auto.start.1= /usr/share/celix/bundles/deployment_admin.zip /usr/share/celix/bundles/log_service.zip /usr/share/celix/bundles/log_writer.zip /usr/share/celix/bundles/remote_shell.zip /usr/share/celix/bundles/shell.zip /usr/share/celix/bundles/shell_tui.zip" > /usr/buildroot-2015.05/output/images/usr/bin/config.properties
#We have all we need for the futur image so we can compress all the files, and store the tar file in a directory
WORKDIR /usr/buildroot-2015.05/output/images
RUN tar -cf rootfs.tar * && \
mkdir /usr/celix-image && \
cp rootfs.tar /usr/celix-image/
# Then the Apache ace image, copy the configuration file of Ace in Buildroot and create a small base of the future image with buildroot and decompress it
RUN cp -f /usr/buildroot-configure-ace/.config /usr/buildroot-2015.05/
WORKDIR /usr/buildroot-2015.05
RUN make clean all
WORKDIR /usr/buildroot-2015.05/output/images
RUN tar -xf rootfs.tar &&\
rm rootfs.tar
# Install etcdctl
RUN cd /tmp \
&& export ETCDVERSION=v2.0.13 \
&& curl -k -L https://github.com/coreos/etcd/releases/download/$ETCDVERSION/etcd-$ETCDVERSION-linux-amd64.tar.gz | gunzip | tar xf - \
&& cp etcd-$ETCDVERSION-linux-amd64/etcdctl /usr/buildroot-2015.05/output/images/bin/
#Add the resources
ADD resources-ace /usr/buildroot-2015.05/output/images/tmp
#Compile the 3 compact profiles of Openjdk8, for more information about the compact profiles of openjdk8 see this link : http://openjdk.java.net/jeps/161
WORKDIR /usr/openjdk8
RUN bash ./get_source.sh && \
export LIBFFI_CFLAGS=-I/usr/lib/x86_64-linux-gnu/include && \
export LIBFFI_LIBS="-L/usr/lib/x86_64-linux-gnu/ -lffi" && \
bash ./configure --with-jvm-variants=zero --enable-openjdk-only --with-freetype-include=/usr/include/freetype2 --with-freetype-lib=/usr/lib/x86_64-linux-gnu --with-extra-cflags=-Wno-error --with-extra-cxxflags=-Wno-error && \
make images profiles
#Copy the built compact 2 profiles of openjdk8 and Apache-Ace in the Base image created with buildroot (We choose compact 2 for our project but you can copy an other compact profiles if you need by replacing "j2re-compact2-image" by "j2re-compact1-image" or "j2re-compact3-image"). Then we have all we need so we can compress all the files. Next the image is stored in a directory outside of buildroot
RUN cp -fr /usr/openjdk8/build/linux-x86_64-normal-zero-release/images/j2re-compact2-image /usr/buildroot-2015.05/output/images/usr/ && \
cp -r /usr/apache-ace-2.0.1-bin /usr/buildroot-2015.05/output/images/usr && \
cd /usr/buildroot-2015.05/output/images/ &&\
tar -cf rootfs.tar * && \
mkdir /usr/ace-image && \
cp rootfs.tar /usr/ace-image && \
rm rootfs.tar
#Finnally for Apache Felix, INstall etcd and add the resources and then just replace the Apache Ace file by the Apache Felix one in the Buildroot environment because the buildroot configuration is the same, create the tar file and store it.
#Install etcd
RUN cd /tmp \
&& rm -r * \
&& export ETCDVERSION=v2.0.13 \
&& curl -k -L https://github.com/coreos/etcd/releases/download/$ETCDVERSION/etcd-$ETCDVERSION-linux-amd64.tar.gz | gunzip | tar xf - \
&& cp etcd-$ETCDVERSION-linux-amd64/etcdctl /usr/buildroot-2015.05/output/images/bin/
#Add the resources
ADD resources-felix /usr/buildroot-2015.05/output/images/tmp
WORKDIR /usr/buildroot-2015.05/output/images/
RUN rm -r usr/apache-ace-2.0.1-bin && \
rm -r usr/j2re-compact2-image && \
cp -r /usr/openjdk8/build/linux-x86_64-normal-zero-release/images/j2re-image && \
cp -r /usr/felix-framework-5.0.1 /usr/buildroot-2015.05/output/images/usr/ && \
tar -cf rootfs.tar * && \
mkdir /usr/felix-image && \
cp rootfs.tar /usr/felix-image
#When the builder image is launch, it creates the docker images automatically that you will be able to see by running the command : docker images
ENTRYPOINT for i in `seq 0 100`; do sudo mknod -m0660 /dev/loop$i b 7 $i; done && \
service docker start && \
docker import - inaetics/celix-agent < /usr/celix-image/rootfs.tar &&\
docker import - inaetics/felix-agent < /usr/felix-image/rootfs.tar &&\
docker import - inaetics/ace-agent < /usr/ace-image/rootfs.tar &&\
/bin/bash