Dockerfile 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. #
  2. # Licensed to the Apache Software Foundation (ASF) under one or more
  3. # contributor license agreements. See the NOTICE file distributed with
  4. # this work for additional information regarding copyright ownership.
  5. # The ASF licenses this file to You under the Apache License, Version 2.0
  6. # (the "License"); you may not use this file except in compliance with
  7. # the License. You may obtain a copy of the License at
  8. #
  9. # http://www.apache.org/licenses/LICENSE-2.0
  10. #
  11. # Unless required by applicable law or agreed to in writing, software
  12. # distributed under the License is distributed on an "AS IS" BASIS,
  13. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. # See the License for the specific language governing permissions and
  15. # limitations under the License.
  16. #
  17. ARG ENABLE_PROXY=false
  18. FROM openresty/openresty:1.19.3.2-alpine-fat AS production-stage
  19. ARG ENABLE_PROXY
  20. ARG APISIX_PATH
  21. COPY $APISIX_PATH ./apisix
  22. RUN set -x \
  23. && (test "${ENABLE_PROXY}" != "true" || /bin/sed -i 's,http://dl-cdn.alpinelinux.org,https://mirrors.aliyun.com,g' /etc/apk/repositories) \
  24. && apk add --no-cache --virtual .builddeps \
  25. automake \
  26. autoconf \
  27. libtool \
  28. pkgconfig \
  29. cmake \
  30. git \
  31. pcre \
  32. pcre-dev \
  33. openldap-dev \
  34. && cd apisix \
  35. && git config --global url.https://github.com/.insteadOf git://github.com/ \
  36. && make deps \
  37. && cp -v bin/apisix /usr/bin/ \
  38. && mv ../apisix /usr/local/apisix \
  39. && apk del .builddeps build-base make unzip
  40. FROM alpine:3.13 AS last-stage
  41. ARG ENABLE_PROXY
  42. # add runtime for Apache APISIX
  43. RUN set -x \
  44. && (test "${ENABLE_PROXY}" != "true" || /bin/sed -i 's,http://dl-cdn.alpinelinux.org,https://mirrors.aliyun.com,g' /etc/apk/repositories) \
  45. && apk add --no-cache \
  46. bash \
  47. curl \
  48. libstdc++ \
  49. openldap \
  50. tzdata
  51. WORKDIR /usr/local/apisix
  52. COPY --from=production-stage /usr/local/openresty/ /usr/local/openresty/
  53. COPY --from=production-stage /usr/local/apisix/ /usr/local/apisix/
  54. COPY --from=production-stage /usr/bin/apisix /usr/bin/apisix
  55. # forward request and error logs to docker log collector
  56. RUN mkdir -p logs && touch logs/access.log && touch logs/error.log \
  57. && ln -sf /dev/stdout /usr/local/apisix/logs/access.log \
  58. && ln -sf /dev/stderr /usr/local/apisix/logs/error.log
  59. ENV PATH=$PATH:/usr/local/openresty/luajit/bin:/usr/local/openresty/nginx/sbin:/usr/local/openresty/bin
  60. EXPOSE 9080 9443
  61. CMD ["sh", "-c", "/usr/bin/apisix init && /usr/bin/apisix init_etcd && /usr/local/openresty/bin/openresty -p /usr/local/apisix -g 'daemon off;'"]
  62. STOPSIGNAL SIGQUIT