diff --git a/.github/workflows/apisix_dev_docker_local_test.yaml b/.github/workflows/apisix_dev_docker_local_test.yaml index e8974c37..0a488b57 100644 --- a/.github/workflows/apisix_dev_docker_local_test.yaml +++ b/.github/workflows/apisix_dev_docker_local_test.yaml @@ -36,15 +36,17 @@ jobs: - name: Build image run: | - cd apisix tag="apache/apisix:$APISIX_IMAGE_TAG" - docker build -t $tag -f ../debian-dev/Dockerfile.local . - + docker build -t $tag -f debian-dev/Dockerfile.local . + - name: use docker-compose run: docker-compose -p docker-apisix -f example/docker-compose.yml up -d - name: Test APISIX run: | + sleep 2 + docker logs docker-apisix_apisix_1 + sleep 30 curl http://127.0.0.1:9180/apisix/admin/routes/1 \ diff --git a/.github/workflows/dashboard_all_in_one_ci.yaml b/.github/workflows/dashboard_all_in_one_ci.yaml new file mode 100644 index 00000000..c7552eb2 --- /dev/null +++ b/.github/workflows/dashboard_all_in_one_ci.yaml @@ -0,0 +1,27 @@ +name: apisix dashboard all in one docker + +on: + push: + branches: + - master + pull_request: + branches: + - master + +jobs: + build: + runs-on: ubuntu-latest + + env: + APISIX_DASHBOARD_VERSION: "3.0.1" # in semver + + steps: + - uses: actions/checkout@v2 + + - name: Build and Test + run: | + docker build -t apache/apisix-dashboard:whole --build-arg APISIX_DASHBOARD_TAG=v${APISIX_DASHBOARD_VERSION} -f ./all-in-one/apisix-dashboard/Dockerfile . + docker run -v `pwd`/all-in-one/apisix/config.yaml:/usr/local/apisix/conf/config.yaml -v `pwd`/all-in-one/apisix-dashboard/conf.yaml:/usr/local/apisix-dashboard/conf/conf.yaml -p 9080:9080 -p 2379:2379 -p 9000:9000 -d apache/apisix-dashboard:whole + sleep 30 + curl http://127.0.0.1:9080/apisix/admin/schema/service -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' + curl http://127.0.0.1:9000 diff --git a/.github/workflows/dashboard_push_docker_hub.yaml b/.github/workflows/dashboard_push_docker_hub.yaml new file mode 100644 index 00000000..e1b92964 --- /dev/null +++ b/.github/workflows/dashboard_push_docker_hub.yaml @@ -0,0 +1,56 @@ +name: Push apisix dashboard to Docker image +on: + push: + branches: ['release/apisix-dashboard**'] +jobs: + build: + strategy: + fail-fast: false + matrix: + os: + - alpine + + name: build dashboard & test on ${{ matrix.os }} && push to docker hub + runs-on: ubuntu-latest + + env: + APISIX_DASHBOARD_VERSION: "3.0.1" # in semver + + steps: + - name: Check out the repo + uses: actions/checkout@v2 + + - name: Build and run + run: | + make build-dashboard-${{ matrix.os }} + 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-${{ matrix.os }}-tar + + - name: Upload Image + uses: actions/upload-artifact@v2 + with: + path: ./package + + - name: Login to Docker Hub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USER }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + diff --git a/Makefile b/Makefile index 08042913..c3de3881 100644 --- a/Makefile +++ b/Makefile @@ -26,6 +26,10 @@ MAX_APISIX_VERSION ?= 3.7.0 IMAGE_NAME = apache/apisix IMAGE_TAR_NAME = apache_apisix +APISIX_DASHBOARD_VERSION ?= $(shell echo ${APISIX_DASHBOARD_VERSION:=3.0.1}) +APISIX_DASHBOARD_IMAGE_NAME = apache/apisix-dashboard +APISIX_DASHBOARD_IMAGE_TAR_NAME = apache_apisix_dashboard + # Makefile ENV ENV_OS_NAME ?= $(shell uname -s | tr '[:upper:]' '[:lower:]') @@ -136,6 +140,14 @@ build-all-in-one: @$(call func_echo_success_status, "$@ -> [ Done ]") +### build-dashboard-all-in-one : Build All in one Docker container for Apache APISIX-dashboard +.PHONY: build-dashboard-all-in-one +build-dashboard-all-in-one: + @$(call func_echo_status, "$@ -> [ Start ]") + $(ENV_DOCKER) build -t $(APISIX_DASHBOARD_IMAGE_NAME):whole -f ./all-in-one/apisix-dashboard/Dockerfile . + @$(call func_echo_success_status, "$@ -> [ Done ]") + + ### save-debian-tar : tar apache/apisix:xx-debian image .PHONY: save-debian-tar save-debian-tar: @@ -145,6 +157,25 @@ save-debian-tar: @$(call func_echo_success_status, "$@ -> [ Done ]") +### build-dashboard-alpine : Build apache/dashboard:tag image on alpine +.PHONY: build-dashboard-alpine +build-dashboard-alpine: + @$(call func_echo_status, "$@ -> [ Start ]") + $(ENV_DOCKER) build -t $(APISIX_DASHBOARD_IMAGE_NAME):$(APISIX_DASHBOARD_VERSION) \ + --build-arg APISIX_DASHBOARD_TAG=v$(APISIX_DASHBOARD_VERSION) \ + -f ./dashboard/Dockerfile.alpine . + @$(call func_echo_success_status, "$@ -> [ Done ]") + + +### save-dashboard-alpine-tar : tar apache/apisix-dashboard:tag image +.PHONY: save-dashboard-alpine-tar +save-dashboard-alpine-tar: + @$(call func_echo_status, "$@ -> [ Start ]") + mkdir -p package + $(ENV_DOCKER) save -o ./package/$(APISIX_DASHBOARD_IMAGE_TAR_NAME)_$(APISIX_DASHBOARD_VERSION)-alpine.tar $(APISIX_DASHBOARD_IMAGE_NAME):$(APISIX_DASHBOARD_VERSION) + @$(call func_echo_success_status, "$@ -> [ Done ]") + + ### help : Show Makefile rules .PHONY: help help: diff --git a/all-in-one/apisix-dashboard/Dockerfile b/all-in-one/apisix-dashboard/Dockerfile new file mode 100644 index 00000000..f41eb82b --- /dev/null +++ b/all-in-one/apisix-dashboard/Dockerfile @@ -0,0 +1,144 @@ +# +# 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. +# + +ARG ENABLE_PROXY=false +ARG ETCD_VERSION=v3.4.14 +ARG APISIX_VERSION=master +ARG APISIX_DASHBOARD_VERSION=master + +# Build Apache APISIX +FROM openresty/openresty:1.21.4.2-alpine-fat AS production-stage + +ARG APISIX_VERSION +ARG ENABLE_PROXY +LABEL apisix_version="${APISIX_VERSION}" + +RUN set -x \ + && (test "${ENABLE_PROXY}" != "true" || /bin/sed -i 's,http://dl-cdn.alpinelinux.org,https://mirrors.aliyun.com,g' /etc/apk/repositories) \ + && apk add --no-cache --virtual .builddeps \ + automake \ + autoconf \ + libtool \ + pkgconfig \ + cmake \ + git \ + openldap-dev \ + sudo \ + && mkdir ~/.luarocks \ + && luarocks config variables.OPENSSL_LIBDIR /usr/local/openresty/openssl/lib \ + && luarocks config variables.OPENSSL_INCDIR /usr/local/openresty/openssl/include \ + && git config --global url.https://github.com/.insteadOf git://github.com/ \ + && curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sudo sh -s -- -y \ + && source "$HOME/.cargo/env" \ + && export CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse \ + # next line is for rust cdylib compile on musl + && export RUSTFLAGS="-C target-feature=-crt-static" \ + && luarocks install https://raw.githubusercontent.com/apache/apisix/master/apisix-master-0.rockspec --tree=/usr/local/apisix/deps PCRE_DIR=/usr/local/openresty/pcre \ + && cp -v /usr/local/apisix/deps/lib/luarocks/rocks-5.1/apisix/${APISIX_VERSION}-0/bin/apisix /usr/bin/ \ + && (if [ "$APISIX_VERSION" = "master" ] || [ "$APISIX_VERSION" \> "2.2" ]; 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;) \ + && mv /usr/local/apisix/deps/share/lua/5.1/apisix /usr/local/apisix \ + && apk del .builddeps build-base make unzip + +# Build etcd +FROM alpine:3.13 AS etcd-stage + +ARG ETCD_VERSION +LABEL etcd_version="${ETCD_VERSION}" + +WORKDIR /tmp +RUN wget https://github.com/etcd-io/etcd/releases/download/${ETCD_VERSION}/etcd-${ETCD_VERSION}-linux-amd64.tar.gz \ + && tar -zxvf etcd-${ETCD_VERSION}-linux-amd64.tar.gz \ + && ln -s etcd-${ETCD_VERSION}-linux-amd64 etcd + + +# Build APISIX Dashboard - 1. download source code from github +FROM alpine:latest as pre-build + +ARG APISIX_DASHBOARD_TAG + +RUN set -x \ + && wget https://github.com/apache/apisix-dashboard/archive/${APISIX_DASHBOARD_TAG}.tar.gz -O /tmp/apisix-dashboard.tar.gz \ + && mkdir /usr/local/apisix-dashboard \ + && tar -xvf /tmp/apisix-dashboard.tar.gz -C /usr/local/apisix-dashboard --strip 1 + +# Build APISIX Dashboard - 2. build manager-api from source code +FROM golang:1.17 as api-builder + +ARG APISIX_DASHBOARD_VERSION +ARG ENABLE_PROXY + +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 + +# Build APISIX Dashboard - 3. build dashboard web-UI from source code +FROM node:14-alpine as fe-builder + +ARG ENABLE_PROXY + +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.npmmirror.com/ ; fi \ + && yarn install \ + && yarn build + +# Finally combine all the resources into one image +FROM alpine:3.13 AS last-stage + +ARG ENABLE_PROXY + +# add runtime for Apache APISIX +RUN set -x \ + && (test "${ENABLE_PROXY}" != "true" || /bin/sed -i 's,http://dl-cdn.alpinelinux.org,https://mirrors.aliyun.com,g' /etc/apk/repositories) \ + && apk add --no-cache bash libstdc++ curl + +WORKDIR /usr/local/apisix + +COPY --from=production-stage /usr/local/openresty/ /usr/local/openresty/ +COPY --from=production-stage /usr/local/apisix/ /usr/local/apisix/ +COPY --from=production-stage /usr/bin/apisix /usr/bin/apisix + +COPY --from=etcd-stage /tmp/etcd/etcd /usr/bin/etcd +COPY --from=etcd-stage /tmp/etcd/etcdctl /usr/bin/etcdctl + +ENV PATH=$PATH:/usr/local/openresty/luajit/bin:/usr/local/openresty/nginx/sbin:/usr/local/openresty/bin + +# dashboard + +RUN if [ "$ENABLE_PROXY" = "true" ] ; then sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories ; fi \ + && apk add lua5.1 + +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 9080 9443 2379 2380 9000 + +CMD ["sh", "-c", "(nohup etcd >/tmp/etcd.log 2>&1 &) && sleep 10 && (/usr/local/apisix-dashboard/manager-api &) && cd /usr/local/apisix && /usr/bin/apisix init && /usr/bin/apisix init_etcd && /usr/local/openresty/bin/openresty -p /usr/local/apisix -g 'daemon off;'"] + +STOPSIGNAL SIGQUIT diff --git a/all-in-one/apisix-dashboard/conf.yaml b/all-in-one/apisix-dashboard/conf.yaml new file mode 100644 index 00000000..0ca5ec26 --- /dev/null +++ b/all-in-one/apisix-dashboard/conf.yaml @@ -0,0 +1,51 @@ +# +# 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. +# + +conf: + listen: + host: 0.0.0.0 # `manager api` listening ip or host name + port: 9000 # `manager api` listening port + etcd: + endpoints: # supports defining multiple etcd host addresses for an etcd cluster + - 127.0.0.1:2379 + + # etcd basic auth info + # username: "root" # ignore etcd username if not enable etcd auth + # password: "123456" # ignore etcd password if not enable etcd auth + log: + error_log: + level: warn # supports levels, lower to higher: debug, info, warn, error, panic, fatal + file_path: + logs/error.log # supports relative path, absolute path, standard output + # such as: logs/error.log, /tmp/logs/error.log, /dev/stdout, /dev/stderr +authentication: + secret: + secret # secret for jwt token generation. + # NOTE: Highly recommended to modify this value to protect `manager api`. + # if it's default value, when `manager api` start, it will generate a random string to replace it. + expire_time: 3600 # jwt token expire time, in second + users: + - username: admin # username and password for login `manager api` + password: admin + - username: user + password: user + +plugin_attr: + prometheus: + export_addr: + ip: "0.0.0.0" + port: 9091 diff --git a/compose/dashboard-compose.yaml b/compose/dashboard-compose.yaml new file mode 100644 index 00000000..bb195ab8 --- /dev/null +++ b/compose/dashboard-compose.yaml @@ -0,0 +1,52 @@ +# +# 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. +# + +version: "3" + +services: + dashboard: + image: "apache/apisix-dashboard:${APISIX_DASHBOARD_VERSION}" + 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://etcd: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.alpine b/dashboard/Dockerfile.alpine new file mode 100644 index 00000000..2a220559 --- /dev/null +++ b/dashboard/Dockerfile.alpine @@ -0,0 +1,71 @@ +# +# 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. +# +ARG BUILDPLATFORM=amd64 + +FROM --platform=$BUILDPLATFORM alpine:latest as pre-build + +ARG APISIX_DASHBOARD_TAG=v3.0.1 + +RUN set -x \ + && apk add --no-cache --virtual .builddeps git \ + && git clone https://github.com/apache/apisix-dashboard.git -b ${APISIX_DASHBOARD_TAG} /usr/local/apisix-dashboard \ + && cd /usr/local/apisix-dashboard && git clean -Xdf \ + && rm -f ./.githash && git log --pretty=format:"%h" -1 > ./.githash \ + && rm /usr/local/openresty/bin/etcdctl + +FROM --platform=$BUILDPLATFORM golang:1.19 as api-builder + +ARG ENABLE_PROXY=false + +WORKDIR /usr/local/apisix-dashboard + +COPY --from=pre-build /usr/local/apisix-dashboard . + +ARG TARGETOS +ARG TARGETARCH + +RUN if [ "$ENABLE_PROXY" = "true" ] ; then go env -w GOPROXY=https://goproxy.io,direct ; fi \ + && go env -w GO111MODULE=on \ + && CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} ./api/build.sh + +FROM --platform=$BUILDPLATFORM 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 + +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 + +ENTRYPOINT [ "/usr/local/apisix-dashboard/manager-api" ] diff --git a/dashboard/README.md b/dashboard/README.md new file mode 100644 index 00000000..ff0b81fc --- /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`. diff --git a/debian-dev/Dockerfile b/debian-dev/Dockerfile index 59df830f..a5c810cc 100644 --- a/debian-dev/Dockerfile +++ b/debian-dev/Dockerfile @@ -15,7 +15,7 @@ # limitations under the License. # -FROM api7/apisix-base:dev AS build +FROM api7/apisix-runtime:dev AS build ARG ENABLE_PROXY=false @@ -35,14 +35,14 @@ RUN set -x \ unzip \ wget \ && curl https://raw.githubusercontent.com/apache/apisix/master/utils/linux-install-luarocks.sh -sL | bash - \ - && luarocks install https://github.com/apache/apisix/raw/master/rockspec/apisix-master-0.rockspec --tree=/usr/local/apisix/deps PCRE_DIR=/usr/local/openresty/pcre \ + && luarocks install https://raw.githubusercontent.com/apache/apisix/master/apisix-master-0.rockspec --tree=/usr/local/apisix/deps PCRE_DIR=/usr/local/openresty/pcre \ && cp -v /usr/local/apisix/deps/lib/luarocks/rocks-5.1/apisix/master-0/bin/apisix /usr/bin/ \ && mv /usr/local/apisix/deps/share/lua/5.1/apisix /usr/local/apisix \ # forward request and error logs to docker log collector && ln -sf /dev/stdout /usr/local/apisix/logs/access.log \ && ln -sf /dev/stderr /usr/local/apisix/logs/error.log -FROM api7/apisix-base:dev AS production-stage +FROM api7/apisix-runtime:dev AS production-stage COPY --from=build /usr/local/apisix /usr/local/apisix COPY --from=build /usr/bin/apisix /usr/bin/apisix @@ -55,7 +55,7 @@ RUN apt-get -y update --fix-missing \ WORKDIR /usr/local/apisix -ENV PATH=$PATH:/usr/local/openresty-debug/luajit/bin:/usr/local/openresty-debug/nginx/sbin:/usr/local/openresty-debug/bin +ENV PATH=$PATH:/usr/local/openresty/luajit/bin:/usr/local/openresty/nginx/sbin:/usr/local/openresty/bin EXPOSE 9080 9443 diff --git a/debian-dev/Dockerfile.local b/debian-dev/Dockerfile.local index c861088d..0ff3ea44 100644 --- a/debian-dev/Dockerfile.local +++ b/debian-dev/Dockerfile.local @@ -17,7 +17,7 @@ # Use this dockerfile to create a docker image of your apisix local/patched codebase -FROM api7/apisix-base:dev AS build +FROM api7/apisix-runtime:dev AS build ARG ENABLE_PROXY=false @@ -26,16 +26,31 @@ ENV DEBIAN_FRONTEND noninteractive # replace the source path with the location of apisix related directories in your host machine # refer: https://web.archive.org/web/20230604150902/https://www.jamestharpe.com/docker-include-files-outside-build-context/ -COPY ./apisix /usr/local/apisix/apisix -COPY ./conf /usr/local/apisix/conf -COPY ./bin/apisix /usr/bin/apisix -COPY ./rockspec/apisix-master-0.rockspec /usr/local/apisix/rockspec/apisix-master-0.rockspec -COPY ./utils/linux-install-luarocks.sh /usr/local/apisix/linux-install-luarocks.sh +COPY apisix/apisix /usr/local/apisix/apisix +COPY apisix/conf /usr/local/apisix/conf +COPY apisix/bin/apisix /usr/bin/apisix +COPY apisix/apisix-master-0.rockspec /usr/local/apisix/apisix-master-0.rockspec +COPY apisix/utils/linux-install-luarocks.sh /usr/local/apisix/linux-install-luarocks.sh +COPY debian-dev/docker-entrypoint.sh /docker-entrypoint.sh + WORKDIR /usr/local/apisix SHELL ["/bin/bash", "-c"] +RUN set -x \ + && DEBIAN_FRONTEND=noninteractive apt-get update \ + && DEBIAN_FRONTEND=noninteractive apt-get install -y libreadline-dev lsb-release libpcre3 libpcre3-dev libldap2-dev libssl-dev perl build-essential \ + && DEBIAN_FRONTEND=noninteractive apt-get -y install --no-install-recommends wget gnupg ca-certificates + +RUN set -x \ + && wget -O - https://openresty.org/package/pubkey.gpg | apt-key add - \ + && wget -O - http://repos.apiseven.com/pubkey.gpg | apt-key add - \ + && echo "deb http://openresty.org/package/debian bullseye openresty" | tee /etc/apt/sources.list.d/openresty.list \ + && echo "deb http://repos.apiseven.com/packages/debian bullseye main" | tee /etc/apt/sources.list.d/apisix.list \ + && DEBIAN_FRONTEND=noninteractive apt-get update \ + && DEBIAN_FRONTEND=noninteractive apt-get install -y apisix-runtime + RUN set -x \ && (test "${ENABLE_PROXY}" != "true" || /bin/sed -i 's,http://deb.debian.org,http://mirrors.aliyun.com,g' /etc/apt/sources.list) \ && apt-get -y update --fix-missing \ @@ -50,26 +65,25 @@ RUN set -x \ wget \ make \ libssl-dev \ - && curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y \ + && curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y \ && source "$HOME/.cargo/env" \ # rust version 1.69.0 required to compile lua-resty-ldap && rustup install 1.69.0 \ && rustup default 1.69.0 \ && bash ./linux-install-luarocks.sh \ - && luarocks config variables.OPENSSL_INCDIR /usr/include/ \ + && luarocks config variables.OPENSSL_INCDIR /usr/include/ \ && luarocks config variables.PCRE_DIR /usr/local/openresty/pcre \ - && luarocks install rockspec/apisix-master-0.rockspec --tree=/usr/local/apisix/deps --deps-only \ + && luarocks install apisix-master-0.rockspec --tree=/usr/local/apisix/deps --deps-only \ && mkdir /usr/local/apisix/logs && touch /usr/local/apisix/logs/error.log && touch /usr/local/apisix/logs/access.log -ENV PATH=$PATH:/usr/local/openresty-debug/luajit/bin:/usr/local/openresty-debug/nginx/sbin:/usr/local/openresty-debug/bin +ENV PATH=$PATH:/usr/local/openresty/luajit/bin:/usr/local/openresty/nginx/sbin:/usr/local/openresty/bin EXPOSE 9080 9443 -RUN wget https://raw.githubusercontent.com/apache/apisix-docker/master/debian-dev/docker-entrypoint.sh -RUN ["chmod", "+x", "./docker-entrypoint.sh"] +RUN ["chmod", "+x", "/docker-entrypoint.sh"] -ENTRYPOINT ["./docker-entrypoint.sh"] +ENTRYPOINT ["/docker-entrypoint.sh"] CMD ["docker-start"] diff --git a/debian-dev/docker-entrypoint.sh b/debian-dev/docker-entrypoint.sh index e7fdc010..1fe8c44c 100755 --- a/debian-dev/docker-entrypoint.sh +++ b/debian-dev/docker-entrypoint.sh @@ -54,8 +54,8 @@ _EOC_ if [ -e "/usr/local/apisix/conf/config_listen.sock" ]; then rm -f "/usr/local/apisix/conf/config_listen.sock" fi - - exec /usr/local/openresty-debug/bin/openresty -p /usr/local/apisix -g 'daemon off;' + + exec /usr/local/openresty/bin/openresty -p /usr/local/apisix -g 'daemon off;' fi exec "$@"