openresty.dockerfile 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. FROM buildpack-deps:xenial
  2. ENV LUA_VERSION="5.1"
  3. ENV LUA_MICRO="5"
  4. RUN apt-get update -yqq && apt-get install -yqq unzip
  5. RUN wget https://github.com/LuaDist/lua/archive/$LUA_VERSION.$LUA_MICRO.tar.gz
  6. RUN tar xf $LUA_VERSION.$LUA_MICRO.tar.gz
  7. ENV LUA_HOME=/lua-$LUA_VERSION.$LUA_MICRO
  8. RUN cd $LUA_HOME && \
  9. cp src/luaconf.h.orig src/luaconf.h && \
  10. make linux && \
  11. cd src && \
  12. mkdir ../bin ../include ../lib && \
  13. install -p -m 0755 lua luac ../bin && \
  14. install -p -m 0644 lua.h luaconf.h lualib.h lauxlib.h ../include && \
  15. install -p -m 0644 liblua.a ../lib
  16. ENV LUA=/lua${LUA_VERSION}.${LUA_MICRO}
  17. ENV PATH=${LUA_HOME}/bin:${PATH}
  18. ENV LUA_PATH="./?.lua;./?.lc;$LUA_HOME/share/lua/5.1/?/init.lua;$LUA_HOME/share/lua/5.1/?.lua;$LUA_HOME/lib/lua/5.1/?/init.lua;$LUA_HOME/lib/lua/5.1/?.lua"
  19. ENV LUA_CPATH="./?.lua;./?.lc;$LUA_HOME/share/lua/5.1/?/init.so;$LUA_HOME/share/lua/5.1/?.so;$LUA_HOME/lib/lua/5.1/?/init.so;$LUA_HOME/lib/lua/5.1/?.so"
  20. ENV LUAROCKS_VERSION="3.2.1"
  21. ENV LUAROCKS=/luarocks-$LUAROCKS_VERSION
  22. RUN wget -q http://luarocks.org/releases/luarocks-$LUAROCKS_VERSION.tar.gz
  23. RUN tar xf luarocks-$LUAROCKS_VERSION.tar.gz
  24. RUN cd $LUAROCKS && \
  25. ./configure --prefix=$LUA_HOME --with-lua=$LUA_HOME && \
  26. make --quiet bootstrap
  27. ENV OPENRESTY_VERSION="1.15.8.2"
  28. ENV OPENRESTY=/openresty
  29. ENV OPENRESTY_HOME=$OPENRESTY-$OPENRESTY_VERSION
  30. RUN wget http://openresty.org/download/openresty-$OPENRESTY_VERSION.tar.gz
  31. RUN tar xf openresty-$OPENRESTY_VERSION.tar.gz
  32. RUN cd openresty-$OPENRESTY_VERSION && \
  33. ./configure --with-http_postgres_module --prefix=$OPENRESTY_HOME --with-luajit-xcflags="-DLUAJIT_NUMMODE=2 -O3" --with-cc-opt="-O3" -j4 && \
  34. make -j4 --quiet && \
  35. make --quiet install
  36. ENV OPENRESTY_HOME=${OPENRESTY_HOME}
  37. ENV PATH=${OPENRESTY_HOME}/nginx/sbin:${PATH}
  38. ADD ./nginx.conf /openresty/
  39. ADD ./app.lua /openresty/
  40. WORKDIR /openresty
  41. RUN luarocks install lua-resty-template
  42. CMD export DBIP=`getent hosts tfb-database | awk '{ print $1 }'` && \
  43. nginx -c /openresty/nginx.conf -g "worker_processes '"$(nproc)"';"