Dockerfile 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. ARG ENABLE_PROXY=false
  2. FROM openresty/openresty:1.19.3.1-alpine-fat AS production-stage
  3. ARG ENABLE_PROXY
  4. RUN set -x \
  5. && (test "${ENABLE_PROXY}" != "true" || /bin/sed -i 's,http://dl-cdn.alpinelinux.org,https://mirrors.aliyun.com,g' /etc/apk/repositories) \
  6. && apk add --no-cache --virtual .builddeps \
  7. automake \
  8. autoconf \
  9. libtool \
  10. pkgconfig \
  11. cmake \
  12. git \
  13. pcre \
  14. pcre-dev \
  15. && mkdir ~/.luarocks \
  16. && luarocks config variables.OPENSSL_LIBDIR /usr/local/openresty/openssl/lib \
  17. && luarocks config variables.OPENSSL_INCDIR /usr/local/openresty/openssl/include \
  18. && luarocks install https://github.com/apache/apisix/raw/master/rockspec/apisix-master-0.rockspec --tree=/usr/local/apisix/deps \
  19. && cp -v /usr/local/apisix/deps/lib/luarocks/rocks-5.1/apisix/master-0/bin/apisix /usr/bin/ \
  20. && mv /usr/local/apisix/deps/share/lua/5.1/apisix /usr/local/apisix \
  21. && apk del .builddeps build-base make unzip
  22. FROM alpine:3.13 AS last-stage
  23. ARG ENABLE_PROXY
  24. # add runtime for Apache APISIX
  25. RUN set -x \
  26. && (test "${ENABLE_PROXY}" != "true" || /bin/sed -i 's,http://dl-cdn.alpinelinux.org,https://mirrors.aliyun.com,g' /etc/apk/repositories) \
  27. && apk add --no-cache bash libstdc++ curl tzdata
  28. WORKDIR /usr/local/apisix
  29. COPY --from=production-stage /usr/local/openresty/ /usr/local/openresty/
  30. COPY --from=production-stage /usr/local/apisix/ /usr/local/apisix/
  31. COPY --from=production-stage /usr/bin/apisix /usr/bin/apisix
  32. # forward request and error logs to docker log collector
  33. RUN ln -sf /dev/stdout /usr/local/apisix/logs/access.log \
  34. && ln -sf /dev/stderr /usr/local/apisix/logs/error.log
  35. ENV PATH=$PATH:/usr/local/openresty/luajit/bin:/usr/local/openresty/nginx/sbin:/usr/local/openresty/bin
  36. EXPOSE 9080 9443
  37. CMD ["sh", "-c", "/usr/bin/apisix init && /usr/bin/apisix init_etcd && /usr/local/openresty/bin/openresty -p /usr/local/apisix -g 'daemon off;'"]
  38. STOPSIGNAL SIGQUIT