Dockerfile 2.2 KB

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