Dockerfile 1.9 KB

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