Tarantool nginx upstream module
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Dockerfile 7.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. # Image includes:
  2. # - nginx (with few common modules)
  3. # - nginx_upstream_module (for tarantool)
  4. # - nginx_lua_module (required by luajit)
  5. # - nginx_devel_kit (required by luajit)
  6. # - luajit
  7. # - luarocks
  8. # - lua rock "lua-cjson" (is necessary to work with tarantool response, can be extended with env variable)
  9. FROM alpine:3.5
  10. MAINTAINER Konstantin Nazarov "mail@racktear.com"
  11. RUN addgroup -S nginx \
  12. && adduser -S -G nginx nginx \
  13. && apk add --no-cache 'su-exec>=0.2'
  14. ENV NGINX_VERSION=1.11.1 \
  15. NGINX_UPSTREAM_MODULE_URL=https://github.com/tarantool/nginx_upstream_module.git \
  16. NGINX_UPSTREAM_MODULE_COMMIT=3736239b51cc48776ee49088d7d674ff37791544 \
  17. NGINX_GPG_KEYS=B0F4253373F8F6F510D42178520A9993A1C052F8
  18. ENV NGINX_LUA_MODULE_URL=https://github.com/openresty/lua-nginx-module \
  19. NGINX_LUA_MODULE_PATH=/usr/src/lua-nginx-module \
  20. NGINX_LUA_MODULE_VERSION=0.10.15rc1
  21. ENV NGINX_DEVEL_KIT_URL=https://github.com/simpl/ngx_devel_kit \
  22. NGINX_DEVEL_KIT_PATH=/usr/src/nginx-devel-kit
  23. ENV LUAJIT_VERSION=2.0.5 \
  24. LUAJIT_URL=http://luajit.org/git/luajit-2.0.git \
  25. LUAJIT_PATH=/usr/src/luajit \
  26. LUAJIT_LIB=/usr/local/lib \
  27. LUAJIT_INC=/usr/local/include/luajit-2.0
  28. ENV LUAROCKS_VERSION=2.4.2 \
  29. LUAROCKS_URL=https://github.com/luarocks/luarocks \
  30. LUAROCKS_PATH=/usr/src/luarocks
  31. ENV LUAROCKS_ROCKS="\
  32. lua-cjson\
  33. "
  34. RUN set -x \
  35. && apk add --no-cache --virtual .build-deps \
  36. build-base \
  37. cmake \
  38. linux-headers \
  39. libressl-dev \
  40. pcre-dev \
  41. zlib-dev \
  42. libxslt-dev \
  43. gd-dev \
  44. geoip-dev \
  45. git \
  46. tar \
  47. gnupg \
  48. curl \
  49. perl-dev \
  50. unzip \
  51. gcc \
  52. perl \
  53. && apk add --no-cache --virtual .run-deps \
  54. ca-certificates \
  55. libressl \
  56. pcre \
  57. zlib \
  58. libxslt \
  59. gd \
  60. geoip \
  61. gettext \
  62. libgcc \
  63. && git config --global http.postBuffer 524288000 \
  64. && : "---------- download nginx-devel-kit ----------" \
  65. && git clone "$NGINX_DEVEL_KIT_URL" $NGINX_DEVEL_KIT_PATH \
  66. && : "---------- download nginx-lua-module ----------" \
  67. && git clone "$NGINX_LUA_MODULE_URL" $NGINX_LUA_MODULE_PATH \
  68. && git -C $NGINX_LUA_MODULE_PATH checkout tags/v$NGINX_LUA_MODULE_VERSION \
  69. && : "---------- download luajit ----------" \
  70. && git clone "$LUAJIT_URL" $LUAJIT_PATH \
  71. && git -C $LUAJIT_PATH checkout tags/v$LUAJIT_VERSION \
  72. && make -C $LUAJIT_PATH \
  73. && make -C $LUAJIT_PATH install \
  74. && : "---------- download and install luarocks (depends on luajit) ----------" \
  75. && git clone $LUAROCKS_URL $LUAROCKS_PATH \
  76. && git -C $LUAROCKS_PATH checkout tags/v$LUAROCKS_VERSION \
  77. && ln -s /usr/local/bin/luajit-$LUAJIT_VERSION /usr/local/bin/lua \
  78. && cd $LUAROCKS_PATH \
  79. && ./configure --with-lua-bin=/usr/local/bin --with-lua-include=/usr/src/luajit/src/ \
  80. && make build \
  81. && make install \
  82. && cd \
  83. && : "---------- download nginx-upstream-module ----------" \
  84. && git clone "$NGINX_UPSTREAM_MODULE_URL" /usr/src/nginx_upstream_module \
  85. && git -C /usr/src/nginx_upstream_module checkout "${NGINX_UPSTREAM_MODULE_COMMIT}" \
  86. && git -C /usr/src/nginx_upstream_module submodule init \
  87. && git -C /usr/src/nginx_upstream_module submodule update \
  88. && make -C /usr/src/nginx_upstream_module yajl \
  89. && make -C /usr/src/nginx_upstream_module msgpack \
  90. && : "---------- download nginx ----------" \
  91. && curl -fSL http://nginx.org/download/nginx-$NGINX_VERSION.tar.gz \
  92. -o nginx.tar.gz \
  93. && curl -fSL http://nginx.org/download/nginx-$NGINX_VERSION.tar.gz.asc \
  94. -o nginx.tar.gz.asc \
  95. && : "---------- verify signatures ----------" \
  96. && mkdir -p /usr/src/nginx \
  97. && tar -xzf nginx.tar.gz -C /usr/src/nginx \
  98. --strip-components=1 \
  99. && cd /usr/src/nginx \
  100. && : "---------- build nginx ----------" \
  101. && ./configure \
  102. --with-cc-opt='-I/usr/src/nginx_upstream_module/third_party/third_party/msgpuck -I /usr/src/nginx_upstream_module/third_party/yajl/build/yajl-2.1.0/include' \
  103. --with-ld-opt='/usr/src/nginx_upstream_module/third_party/yajl/build/yajl-2.1.0/lib/libyajl_s.a -L /usr/src/nginx_upstream_module/third_party/third_party/msgpuck' \
  104. --add-module=/usr/src/nginx_upstream_module \
  105. --prefix=/etc/nginx \
  106. --sbin-path=/usr/sbin/nginx \
  107. --modules-path=/usr/lib/nginx/modules \
  108. --conf-path=/etc/nginx/nginx.conf \
  109. --error-log-path=/var/log/nginx/error.log \
  110. --http-log-path=/var/log/nginx/access.log \
  111. --pid-path=/var/run/nginx.pid \
  112. --lock-path=/var/run/nginx.lock \
  113. --http-client-body-temp-path=/var/cache/nginx/client_temp \
  114. --http-proxy-temp-path=/var/cache/nginx/proxy_temp \
  115. --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp \
  116. --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp \
  117. --http-scgi-temp-path=/var/cache/nginx/scgi_temp \
  118. --user=nginx \
  119. --group=nginx \
  120. --with-http_ssl_module \
  121. --with-http_realip_module \
  122. --with-http_addition_module \
  123. --with-http_sub_module \
  124. --with-http_dav_module \
  125. --with-http_flv_module \
  126. --with-http_mp4_module \
  127. --with-http_gunzip_module \
  128. --with-http_gzip_static_module \
  129. --with-http_random_index_module \
  130. --with-http_secure_link_module \
  131. --with-http_stub_status_module \
  132. --with-http_auth_request_module \
  133. --with-http_xslt_module=dynamic \
  134. --with-http_image_filter_module=dynamic \
  135. --with-http_geoip_module=dynamic \
  136. --with-http_perl_module=dynamic \
  137. --with-threads \
  138. --with-stream \
  139. --with-stream_ssl_module \
  140. --with-http_slice_module \
  141. --with-mail \
  142. --with-mail_ssl_module \
  143. --with-file-aio \
  144. --with-http_v2_module \
  145. --with-ipv6 \
  146. --with-ld-opt="-Wl,-rpath,$LUAJIT_LIB" \
  147. --add-module=$NGINX_DEVEL_KIT_PATH \
  148. --add-module=$NGINX_LUA_MODULE_PATH \
  149. && make \
  150. && make install \
  151. && rm -rf /etc/nginx/html/ \
  152. && mkdir /etc/nginx/conf.d/ \
  153. && mkdir -p /usr/share/nginx/html/ \
  154. && install -m644 html/index.html /usr/share/nginx/html/ \
  155. && install -m644 html/50x.html /usr/share/nginx/html/ \
  156. && : "---------- install module deps ----------" \
  157. && runDeps="$( \
  158. scanelf --needed --nobanner /usr/sbin/nginx /usr/lib/nginx/modules/*.so \
  159. | awk '{ gsub(/,/, "\nso:", $2); print "so:" $2 }' \
  160. | sort -u \
  161. | xargs -r apk info --installed \
  162. | sort -u \
  163. )" \
  164. && apk add --virtual .run-deps $runDeps \
  165. && : "---------- install lua rocks ----------" \
  166. && for rock in $LUAROCKS_ROCKS; do luarocks install $rock; done \
  167. && : "---------- remove build deps ----------" \
  168. && rm -rf /usr/src/nginx \
  169. && rm -rf /usr/src/nginx_upstream_module \
  170. && apk del .build-deps \
  171. && : "---------- redirect logs to default collector ----------" \
  172. && ln -sf /dev/stdout /var/log/nginx/access.log \
  173. && ln -sf /dev/stderr /var/log/nginx/error.log
  174. COPY nginx.conf /etc/nginx/nginx.conf
  175. COPY nginx.vh.default.conf /etc/nginx/conf.d/default.conf
  176. VOLUME ["/var/cache/nginx"]
  177. EXPOSE 80 443
  178. CMD ["nginx", "-g", "daemon off;"]