This is an automated email from the ASF dual-hosted git repository. chenjunxu pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/apisix-docker.git
The following commit(s) were added to refs/heads/master by this push: new 388757e feat: add apisix-dashboard dockerfile & CI (#152) 388757e is described below commit 388757eb835b7b6d68e3d8eccc5dce8467cdd28f Author: kv <gxt...@163.com> AuthorDate: Mon Mar 22 15:14:11 2021 +0800 feat: add apisix-dashboard dockerfile & CI (#152) --- .github/workflows/dashboard-docker-test.yaml | 41 +++++++++++++++++ Makefile | 15 +++++- compose/dashboard-compose.yaml | 35 ++++++++++++++ dashboard/Dockerfile | 69 ++++++++++++++++++++++++++++ dashboard/README.md | 7 +++ 5 files changed, 166 insertions(+), 1 deletion(-) diff --git a/.github/workflows/dashboard-docker-test.yaml b/.github/workflows/dashboard-docker-test.yaml new file mode 100644 index 0000000..96f93d0 --- /dev/null +++ b/.github/workflows/dashboard-docker-test.yaml @@ -0,0 +1,41 @@ +name: dashboard docker test + +on: + push: + branches: + - master + pull_request: + branches: + - master + +jobs: + dashboard-docker-test: + name: build dashboard & test + runs-on: ubuntu-latest + env: + APISIX_DASHBOARD_TAG: 2.4 + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Build and run + run: | + make build-dashboard + docker-compose -f ./compose/dashboard-compose.yaml up -d + sleep 30 + docker logs compose_dashboard_1 + + - name: check + run: | + wget https://raw.githubusercontent.com/apache/apisix-dashboard/master/api/test/shell/manager_smoking.sh + chmod +x ./manager_smoking.sh + sh manager_smoking.sh -s true + + - name: Tar Image + run: | + make save-dashboard-tar + + - name: Upload Image + uses: actions/upload-artifact@v2 + with: + path: ./package diff --git a/Makefile b/Makefile index 4671949..1488a5a 100644 --- a/Makefile +++ b/Makefile @@ -20,6 +20,10 @@ APISIX_VERSION ?= 2.4 IMAGE_NAME = apache/apisix IMAGE_TAR_NAME = apache_apisix +APISIX_DASHBOARD_VERSION ?= 2.4 +APISIX_DASHBOARD_IMAGE_NAME = apache/apisix-dashboard +APISIX_DASHBOARD_IMAGE_TAR_NAME = apache_apisix_dashboard + ### build-on-centos: Build apache/apisix:xx-centos image build-on-centos: docker build -t $(IMAGE_NAME):$(APISIX_VERSION)-centos -f ./centos/Dockerfile . @@ -32,7 +36,7 @@ build-on-alpine: # Actually it is not build on certain version but on local code # Use this name (in the same patterns with others) for convenient CI build-on-alpine-local: - docker build -t $(IMAGE_NAME):$(APISIX_VERSION)-alpine-local --build-arg APISIX_PATH=${APISIX_PATH} -f ./alpine-local/Dockerfile . + docker build -t $(IMAGE_NAME):$(APISIX_VERSION)-alpine-local --build-arg APISIX_PATH=${APISIX_PATH} -f ./alpine-local/Dockerfile . ### save-centos-tar: tar apache/apisix:xx-centos image save-centos-tar: @@ -44,6 +48,15 @@ save-alpine-tar: mkdir -p package docker save -o ./package/$(IMAGE_TAR_NAME)_$(APISIX_VERSION)-alpine.tar $(IMAGE_NAME):$(APISIX_VERSION)-alpine +### build-dashboard: Build apache/dashboard:tag image +build-dashboard: + docker build -t $(APISIX_DASHBOARD_IMAGE_NAME):$(APISIX_DASHBOARD_VERSION) -f ./dashboard/Dockerfile . + +### save-dashboard-tar: tar apaceh/apisix-dashboard:tag image +save-dashboard-tar: + mkdir -p package + docker save -o ./package/$(APISIX_DASHBOARD_IMAGE_TAR_NAME)_$(APISIX_DASHBOARD_VERSION).tar $(APISIX_DASHBOARD_IMAGE_NAME):$(APISIX_DASHBOARD_VERSION) + ### help: Show Makefile rules help: @echo Makefile rules: diff --git a/compose/dashboard-compose.yaml b/compose/dashboard-compose.yaml new file mode 100644 index 0000000..8e3cf76 --- /dev/null +++ b/compose/dashboard-compose.yaml @@ -0,0 +1,35 @@ +version: "3" + +services: + dashboard: + image: "apache/apisix-dashboard:${APISIX_DASHBOARD_TAG}" + restart: always + volumes: + - ../example/dashboard_conf/conf.yaml:/usr/local/apisix-dashboard/conf/conf.yaml:ro + depends_on: + - etcd + ports: + - "9000:9000/tcp" + networks: + - apisix + + etcd: + image: bitnami/etcd:3.4.9 + user: root + restart: always + volumes: + - ../example/etcd_data:/etcd_data + environment: + ETCD_DATA_DIR: /etcd_data + ETCD_ENABLE_V2: "true" + ALLOW_NONE_AUTHENTICATION: "yes" + ETCD_ADVERTISE_CLIENT_URLS: "http://0.0.0.0:2379" + ETCD_LISTEN_CLIENT_URLS: "http://0.0.0.0:2379" + ports: + - "2379:2379/tcp" + networks: + - apisix + +networks: + apisix: + driver: bridge diff --git a/dashboard/Dockerfile b/dashboard/Dockerfile new file mode 100644 index 0000000..296678e --- /dev/null +++ b/dashboard/Dockerfile @@ -0,0 +1,69 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +FROM alpine:latest as pre-build + +ARG APISIX_DASHBOARD_VERSION=v2.4 + +RUN set -x \ + && apk add --no-cache --virtual .builddeps git \ + && git clone https://github.com/apache/apisix-dashboard.git -b ${APISIX_DASHBOARD_VERSION} /usr/local/apisix-dashboard \ + && cd /usr/local/apisix-dashboard && git clean -Xdf \ + && rm -f ./.githash && git log --pretty=format:"%h" -1 > ./.githash + +FROM golang:1.14 as api-builder + +ARG ENABLE_PROXY=false + +WORKDIR /usr/local/apisix-dashboard + +COPY --from=pre-build /usr/local/apisix-dashboard . + +RUN if [ "$ENABLE_PROXY" = "true" ] ; then go env -w GOPROXY=https://goproxy.io,direct ; fi \ + && go env -w GO111MODULE=on \ + && CGO_ENABLED=0 ./api/build.sh + +FROM node:14-alpine as fe-builder + +ARG ENABLE_PROXY=false + +WORKDIR /usr/local/apisix-dashboard + +COPY --from=pre-build /usr/local/apisix-dashboard . + +WORKDIR /usr/local/apisix-dashboard/web + +RUN if [ "$ENABLE_PROXY" = "true" ] ; then yarn config set registry https://registry.npm.taobao.org/ ; fi \ + && yarn install \ + && yarn build + +FROM alpine:latest as prod + +ARG ENABLE_PROXY=false + +RUN if [ "$ENABLE_PROXY" = "true" ] ; then sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories ; fi + +WORKDIR /usr/local/apisix-dashboard + +COPY --from=api-builder /usr/local/apisix-dashboard/output/ ./ + +COPY --from=fe-builder /usr/local/apisix-dashboard/output/ ./ + +RUN mkdir logs + +EXPOSE 9000 + +CMD [ "/usr/local/apisix-dashboard/manager-api" ] diff --git a/dashboard/README.md b/dashboard/README.md new file mode 100644 index 0000000..ff0b81f --- /dev/null +++ b/dashboard/README.md @@ -0,0 +1,7 @@ +### build command + +```shell +$ docker build --build-arg APISIX_DASHBOARD_VERSION=$APISIX_DASHBOARD_VERSION -t $IMAGE_NAME . +``` + +Note: The minimum version of docker that supports building image is `docker 17.05.0-ce`.