Dockerfile 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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. FROM alpine:latest as pre-build
  18. ARG APISIX_DASHBOARD_VERSION=release/2.7.1
  19. RUN set -x \
  20. && apk add --no-cache --virtual .builddeps git \
  21. && git clone https://github.com/apache/apisix-dashboard.git -b ${APISIX_DASHBOARD_VERSION} /usr/local/apisix-dashboard \
  22. && cd /usr/local/apisix-dashboard && git clean -Xdf \
  23. && rm -f ./.githash && git log --pretty=format:"%h" -1 > ./.githash
  24. FROM golang:1.14 as api-builder
  25. ARG ENABLE_PROXY=false
  26. WORKDIR /usr/local/apisix-dashboard
  27. COPY --from=pre-build /usr/local/apisix-dashboard .
  28. RUN if [ "$ENABLE_PROXY" = "true" ] ; then go env -w GOPROXY=https://goproxy.io,direct ; fi \
  29. && go env -w GO111MODULE=on \
  30. && CGO_ENABLED=0 ./api/build.sh
  31. FROM node:14-alpine as fe-builder
  32. ARG ENABLE_PROXY=false
  33. WORKDIR /usr/local/apisix-dashboard
  34. COPY --from=pre-build /usr/local/apisix-dashboard .
  35. WORKDIR /usr/local/apisix-dashboard/web
  36. RUN if [ "$ENABLE_PROXY" = "true" ] ; then yarn config set registry https://registry.npm.taobao.org/ ; fi \
  37. && yarn install \
  38. && yarn build
  39. FROM alpine:latest as prod
  40. ARG ENABLE_PROXY=false
  41. RUN if [ "$ENABLE_PROXY" = "true" ] ; then sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories ; fi
  42. WORKDIR /usr/local/apisix-dashboard
  43. COPY --from=api-builder /usr/local/apisix-dashboard/output/ ./
  44. COPY --from=fe-builder /usr/local/apisix-dashboard/output/ ./
  45. RUN mkdir logs
  46. EXPOSE 9000
  47. CMD [ "/usr/local/apisix-dashboard/manager-api" ]