Dockerfile 2.1 KB

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