Dockerfile 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. # Build Apache APISIX
  19. FROM api7/apisix-base:1.21.4.1.2
  20. ARG APISIX_VERSION=3.0.0
  21. LABEL apisix_version="${APISIX_VERSION}"
  22. ARG ENABLE_PROXY
  23. RUN set -x \
  24. && (test "${ENABLE_PROXY}" != "true" || /bin/sed -i 's,http://dl-cdn.alpinelinux.org,https://mirrors.aliyun.com,g' /etc/apk/repositories) \
  25. && apk add --no-cache --virtual .builddeps \
  26. build-base \
  27. automake \
  28. autoconf \
  29. make \
  30. libtool \
  31. pkgconfig \
  32. cmake \
  33. unzip \
  34. curl \
  35. openssl \
  36. git \
  37. openldap-dev \
  38. && luarocks install https://github.com/apache/apisix/raw/master/rockspec/apisix-${APISIX_VERSION}-0.rockspec --tree=/usr/local/apisix/deps PCRE_DIR=/usr/local/openresty/pcre \
  39. && cp -v /usr/local/apisix/deps/lib/luarocks/rocks-5.1/apisix/${APISIX_VERSION}-0/bin/apisix /usr/bin/ \
  40. && (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;) \
  41. && mv /usr/local/apisix/deps/share/lua/5.1/apisix /usr/local/apisix \
  42. && apk del .builddeps \
  43. && apk add --no-cache \
  44. bash \
  45. curl \
  46. libstdc++ \
  47. openldap \
  48. tzdata \
  49. # forward request and error logs to docker log collector
  50. && ln -sf /dev/stdout /usr/local/apisix/logs/access.log \
  51. && ln -sf /dev/stderr /usr/local/apisix/logs/error.log
  52. WORKDIR /usr/local/apisix
  53. ENV PATH=$PATH:/usr/local/openresty/luajit/bin:/usr/local/openresty/nginx/sbin:/usr/local/openresty/bin
  54. EXPOSE 9180 9080 9443
  55. CMD ["sh", "-c", "/usr/bin/apisix init && /usr/bin/apisix init_etcd && /usr/local/openresty/bin/openresty -p /usr/local/apisix -g 'daemon off;'"]
  56. STOPSIGNAL SIGQUIT