docker
260 строк · 9.0 Кб
1FROM alpine:3.9
2MAINTAINER mail@racktear.com
3
4RUN addgroup -S tarantool \
5&& adduser -S -G tarantool tarantool \
6&& apk add --no-cache 'su-exec>=0.2'
7
8# An ARG instruction goes out of scope at the end of the build
9# stage where it was defined. To use an arg in multiple stages,
10# each stage must include the ARG instruction
11ARG TNT_VER
12ARG NPROC
13ENV TARANTOOL_VERSION=${TNT_VER} \
14TARANTOOL_DOWNLOAD_URL=https://github.com/tarantool/tarantool.git \
15TARANTOOL_INSTALL_LUADIR=/usr/local/share/tarantool \
16GPERFTOOLS_REPO=https://github.com/gperftools/gperftools.git \
17GPERFTOOLS_TAG=gperftools-2.5 \
18LUAROCKS_URL=https://github.com/tarantool/luarocks/archive/6e6fe62d9409fe2103c0fd091cccb3da0451faf5.tar.gz \
19LUAROCK_VSHARD_VERSION=0.1.18 \
20LUAROCK_AVRO_SCHEMA_VERSION=3.0.6 \
21LUAROCK_EXPERATIOND_VERSION=1.1.1 \
22LUAROCK_QUEUE_VERSION=1.1.0 \
23LUAROCK_CONNPOOL_VERSION=1.1.1 \
24LUAROCK_HTTP_VERSION=1.2.0 \
25LUAROCK_MEMCACHED_VERSION=1.0.1 \
26LUAROCK_METRICS_VERSION=0.12.0 \
27LUAROCK_TARANTOOL_PG_VERSION=2.0.2 \
28LUAROCK_TARANTOOL_MYSQL_VERSION=2.0.1 \
29LUAROCK_TARANTOOL_MQTT_VERSION=1.5.1 \
30LUAROCK_TARANTOOL_GIS_VERSION=1.0.0 \
31LUAROCK_TARANTOOL_PROMETHEUS_VERSION=1.0.4 \
32LUAROCK_TARANTOOL_GPERFTOOLS_VERSION=1.0.1
33
34COPY files/gperftools_alpine.diff /
35
36ARG ENABLE_BUNDLED_LIBYAML \
37LUAJIT_DISABLE_SYSPROF \
38GC64
39
40RUN set -x \
41&& apk add --no-cache --virtual .run-deps.1 \
42libstdc++ \
43readline \
44openssl \
45yaml \
46lz4 \
47binutils \
48ncurses \
49libgomp \
50lua \
51tar \
52zip \
53zlib \
54libunwind \
55icu \
56ca-certificates \
57&& apk add --no-cache --virtual .build-deps.1 \
58gcc \
59g++ \
60cmake \
61file \
62readline-dev \
63openssl-dev \
64yaml-dev \
65bsd-compat-headers \
66lz4-dev \
67zlib-dev \
68binutils-dev \
69ncurses-dev \
70lua-dev \
71musl-dev \
72make \
73git \
74libunwind-dev \
75autoconf \
76automake \
77libtool \
78linux-headers \
79go \
80icu-dev \
81wget \
82&& : "---------- gperftools ----------" \
83&& mkdir -p /usr/src/gperftools \
84&& git clone "$GPERFTOOLS_REPO" /usr/src/gperftools \
85&& git -C /usr/src/gperftools checkout "$GPERFTOOLS_TAG" \
86&& (cd /usr/src/gperftools; \
87patch -p1 < /gperftools_alpine.diff; \
88rm /gperftools_alpine.diff; \
89./autogen.sh; \
90./configure; \
91make -j ${NPROC}; \
92cp .libs/libprofiler.so* /usr/local/lib;) \
93&& : "---------- pprof for gperftools ----------" \
94&& : "To avoid of the issue:" \
95&& : "'The master branch is Incompatible with go version < 1.13 #538'" \
96&& : "https://github.com/google/pprof/issues/538" \
97&& : "use latest workable commits with the old GO versions" \
98&& ( export GOPATH=/root/go && \
99export PATH=${GOPATH}/bin:/usr/local/go/bin:$PATH && \
100export GOBIN=$GOROOT/bin && \
101mkdir -p ${GOPATH}/src ${GOPATH}/bin && \
102go get github.com/google/pprof || : && \
103cd /root/go/src/github.com/google/pprof && \
104git checkout 160c4290d1d8cee56daa51d7ba5d223291d392aa && \
105( cd /root/go/src/github.com/chzyer/readline && \
106git checkout f6d7a1f6fbf35bbf9beb80dc63c56a29dcfb759f ) && \
107( cd /root/go/src/github.com/ianlancetaylor/demangle && \
108git checkout 039b1ae3a3406573c84daaf91166d70ad2bc0519 ) && \
109go build && \
110cp pprof /usr/local/bin/pprof ) \
111&& : "---------- tarantool ----------" \
112&& mkdir -p /usr/src/tarantool \
113&& git clone "$TARANTOOL_DOWNLOAD_URL" /usr/src/tarantool \
114&& git -C /usr/src/tarantool checkout "$TARANTOOL_VERSION" \
115&& git -C /usr/src/tarantool submodule update --init --recursive \
116&& (cd /usr/src/tarantool; \
117echo "WARNING: Temporary fix for test/unit/cbus_hang test" ; \
118git cherry-pick d7fa6d34ab4e0956fe8a80966ba628e0e3f81067 2>/dev/null || \
119git cherry-pick --abort ; \
120cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo\
121-DENABLE_BUNDLED_LIBYAML:BOOL=${ENABLE_BUNDLED_LIBYAML}\
122-DENABLE_BACKTRACE:BOOL=ON\
123-DLUAJIT_DISABLE_SYSPROF:BOOL=${LUAJIT_DISABLE_SYSPROF} \
124-DLUAJIT_ENABLE_GC64:BOOL=${GC64} \
125-DENABLE_DIST:BOOL=ON\
126.) \
127&& make -C /usr/src/tarantool -j ${NPROC} \
128&& make -C /usr/src/tarantool install \
129&& make -C /usr/src/tarantool clean \
130&& : "---------- luarocks ----------" \
131&& wget -O luarocks.tar.gz "$LUAROCKS_URL" \
132&& mkdir -p /usr/src/luarocks \
133&& tar -xzf luarocks.tar.gz -C /usr/src/luarocks --strip-components=1 \
134&& (cd /usr/src/luarocks; \
135./configure; \
136make -j build; \
137make install) \
138&& rm -r /usr/src/luarocks \
139&& rm -rf /usr/src/tarantool \
140&& rm -rf /usr/src/gperftools \
141&& rm -rf /usr/src/go \
142&& : "---------- remove build deps ----------" \
143&& apk del .build-deps.1
144
145RUN mkdir -p /usr/local/etc/luarocks \
146&& mkdir -p /usr/local/etc/tarantool/rocks
147
148COPY files/luarocks-config.lua /usr/local/etc/luarocks/config-5.1.lua
149COPY files/luarocks-config.lua /usr/local/etc/tarantool/rocks/config-5.1.lua
150
151ARG ROCKS_INSTALLER
152RUN set -x \
153&& apk add --no-cache --virtual .run-deps.2 \
154mariadb-connector-c-dev \
155libpq \
156cyrus-sasl \
157libev \
158&& apk add --no-cache --virtual .build-deps.2 \
159git \
160cmake \
161make \
162coreutils \
163gcc \
164g++ \
165postgresql-dev \
166lua-dev \
167musl-dev \
168cyrus-sasl-dev \
169libev-dev \
170wget \
171unzip \
172&& mkdir -p /rocks \
173&& : "---------- proj (for gis module) ----------" \
174&& wget -O proj.tar.gz http://download.osgeo.org/proj/proj-4.9.3.tar.gz \
175&& mkdir -p /usr/src/proj \
176&& tar -xzf proj.tar.gz -C /usr/src/proj --strip-components=1 \
177&& (cd /usr/src/proj; \
178./configure; \
179make -j ${NPROC}; \
180make install) \
181&& rm -r /usr/src/proj \
182&& rm -rf /usr/src/proj \
183&& rm -rf /proj.tar.gz \
184&& : "---------- geos (for gis module) ----------" \
185&& wget -O geos.tar.bz2 http://download.osgeo.org/geos/geos-3.6.0.tar.bz2 \
186&& mkdir -p /usr/src/geos \
187&& tar -xjf geos.tar.bz2 -C /usr/src/geos --strip-components=1 \
188&& (cd /usr/src/geos; \
189./configure; \
190make -j ${NPROC}; \
191make install) \
192&& rm -r /usr/src/geos \
193&& rm -rf /usr/src/geos \
194&& rm -rf /geos.tar.bz2 \
195&& : "---------- luarocks ----------" \
196&& : "ldoc" \
197&& ${ROCKS_INSTALLER} install ldoc \
198&& : "lua-term" \
199&& ${ROCKS_INSTALLER} install lua-term \
200&& : "avro" \
201&& ${ROCKS_INSTALLER} install avro-schema $LUAROCK_AVRO_SCHEMA_VERSION \
202&& : "expirationd" \
203&& ${ROCKS_INSTALLER} install expirationd $LUAROCK_EXPERATIOND_VERSION \
204&& : "queue" \
205&& ${ROCKS_INSTALLER} install queue $LUAROCK_QUEUE_VERSION \
206&& : "connpool" \
207&& ${ROCKS_INSTALLER} install connpool $LUAROCK_CONNPOOL_VERSION \
208&& : "vshard" \
209&& ${ROCKS_INSTALLER} install vshard $LUAROCK_VSHARD_VERSION \
210&& : "http" \
211&& ${ROCKS_INSTALLER} install http $LUAROCK_HTTP_VERSION \
212&& : "pg" \
213&& ${ROCKS_INSTALLER} install pg $LUAROCK_TARANTOOL_PG_VERSION \
214&& : "mysql" \
215&& ${ROCKS_INSTALLER} install mysql $LUAROCK_TARANTOOL_MYSQL_VERSION \
216&& : "memcached" \
217&& ${ROCKS_INSTALLER} install memcached $LUAROCK_MEMCACHED_VERSION \
218&& : "metrics" \
219&& ${ROCKS_INSTALLER} install metrics $LUAROCK_METRICS_VERSION \
220&& : "prometheus" \
221&& ${ROCKS_INSTALLER} install prometheus $LUAROCK_TARANTOOL_PROMETHEUS_VERSION \
222&& : "mqtt" \
223&& ${ROCKS_INSTALLER} install mqtt $LUAROCK_TARANTOOL_MQTT_VERSION \
224&& : "gis" \
225&& ${ROCKS_INSTALLER} install gis $LUAROCK_TARANTOOL_GIS_VERSION \
226&& : "gperftools" \
227&& ${ROCKS_INSTALLER} install gperftools $LUAROCK_TARANTOOL_GPERFTOOLS_VERSION \
228&& : "---------- remove build deps ----------" \
229&& apk del .build-deps.2
230
231# gh-170: needed for luarocks
232RUN apk update \
233&& apk add wget git
234
235RUN mkdir -p /var/lib/tarantool \
236&& chown tarantool:tarantool /var/lib/tarantool \
237&& mkdir -p /opt/tarantool \
238&& chown tarantool:tarantool /opt/tarantool \
239&& mkdir -p /var/run/tarantool \
240&& chown tarantool:tarantool /var/run/tarantool \
241&& mkdir /etc/tarantool \
242&& chown tarantool:tarantool /etc/tarantool
243
244VOLUME /var/lib/tarantool
245WORKDIR /opt/tarantool
246
247COPY files/tarantool-entrypoint.lua /usr/local/bin/
248COPY files/tarantool_set_config.lua /usr/local/bin/
249COPY files/docker-entrypoint.sh /usr/local/bin/
250COPY files/console /usr/local/bin/
251COPY files/tarantool_is_up /usr/local/bin/
252COPY files/tarantool.default /usr/local/etc/default/tarantool
253
254RUN ln -s usr/local/bin/docker-entrypoint.sh /entrypoint.sh # backwards compat
255ENTRYPOINT ["docker-entrypoint.sh"]
256
257HEALTHCHECK CMD tarantool_is_up
258
259EXPOSE 3301
260CMD [ "tarantool" ]
261