Dockerfile 2.3 KB

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