You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by sp...@apache.org on 2022/06/16 12:04:22 UTC

[apisix-docker] branch master updated: feat: use debian to build apisix dev (#314)

This is an automated email from the ASF dual-hosted git repository.

spacewander 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 86826eb  feat: use debian to build apisix dev (#314)
86826eb is described below

commit 86826eb3ed578e934022f8c4199db3ddf1e81e55
Author: tzssangglass <tz...@gmail.com>
AuthorDate: Thu Jun 16 20:04:18 2022 +0800

    feat: use debian to build apisix dev (#314)
---
 .github/workflows/apisix-docker-test.yaml         |  8 +--
 .github/workflows/apisix_dev_push_docker_hub.yaml |  4 +-
 Makefile                                          | 26 +++-----
 alpine-local/Dockerfile                           | 74 -----------------------
 debian-dev/Dockerfile                             | 60 ++++++++++++++++++
 5 files changed, 71 insertions(+), 101 deletions(-)

diff --git a/.github/workflows/apisix-docker-test.yaml b/.github/workflows/apisix-docker-test.yaml
index 2010ff5..d34483c 100644
--- a/.github/workflows/apisix-docker-test.yaml
+++ b/.github/workflows/apisix-docker-test.yaml
@@ -16,8 +16,7 @@ jobs:
         platform:
           - alpine
           - centos
-          - alpine-local
-          - alpine-dev
+          - debian-dev
 
     runs-on: ubuntu-latest
     env:
@@ -26,11 +25,6 @@ jobs:
     steps:
       - uses: actions/checkout@v2
 
-      - name: Clone apisix for local test
-        if: ${{ matrix.platform == 'alpine-local' }}
-        run: |
-          git clone --depth 1 http://github.com/apache/apisix apisix-local
-
       - name: Build and run
         run: |
           make build-on-${{ matrix.platform }}
diff --git a/.github/workflows/apisix_dev_push_docker_hub.yaml b/.github/workflows/apisix_dev_push_docker_hub.yaml
index c059115..60b85cc 100644
--- a/.github/workflows/apisix_dev_push_docker_hub.yaml
+++ b/.github/workflows/apisix_dev_push_docker_hub.yaml
@@ -4,7 +4,7 @@ name: Build and Push apisix-dev to Docker DockerHub
 on:
   schedule:
     # UTC 0:00 AM (See https://pubs.opengroup.org/onlinepubs/9699919799/utilities/crontab.html#tag_20_25_07)
-    - cron: "0 0 * * *"
+    - cron: "0 1 * * *"
 
 jobs:
   build:
@@ -28,4 +28,4 @@ jobs:
 
       - name: Push apisix image to Docker Hub
         run: |
-          make push-multiarch-dev-on-alpine
+          make push-multiarch-dev-on-debian
diff --git a/Makefile b/Makefile
index 1c6fb56..f29b91d 100644
--- a/Makefile
+++ b/Makefile
@@ -76,21 +76,11 @@ build-on-alpine:
 	@$(call func_echo_success_status, "$@ -> [ Done ]")
 
 
-### build-on-alpine-dev : Build apache/apisix:xx-alpine-dev image
-.PHONY: build-on-alpine-dev
-build-on-alpine-dev:
+### build-on-debian-dev : Build apache/apisix:xx-debian-dev image
+.PHONY: build-on-debian-dev
+build-on-debian-dev:
 	@$(call func_echo_status, "$@ -> [ Start ]")
-	$(ENV_DOCKER) build -t $(ENV_APISIX_IMAGE_TAG_NAME)-alpine-dev -f ./alpine-dev/Dockerfile .
-	@$(call func_echo_success_status, "$@ -> [ Done ]")
-
-
-### build-on-alpine-local : Build apache/apisix:xx-alpine-local image
-# Actually it is not build on certain version but on local code
-# Use this name (in the same patterns with others) for convenient CI
-.PHONY: build-on-alpine-local
-build-on-alpine-local:
-	@$(call func_echo_status, "$@ -> [ Start ]")
-	$(ENV_DOCKER) build -t $(ENV_APISIX_IMAGE_TAG_NAME)-alpine-local --build-arg APISIX_PATH=${APISIX_PATH} -f ./alpine-local/Dockerfile .
+	$(ENV_DOCKER) build -t $(ENV_APISIX_IMAGE_TAG_NAME)-debian-dev -f ./debian-dev/Dockerfile .
 	@$(call func_echo_success_status, "$@ -> [ Done ]")
 
 
@@ -117,13 +107,13 @@ push-multiarch-on-alpine:
 
 
 ### push-on-alpine : Push apache/apisix:dev image
-.PHONY: push-multiarch-dev-on-alpine
-push-multiarch-dev-on-alpine:
+.PHONY: push-multiarch-dev-on-debian
+push-multiarch-dev-on-debian:
 	@$(call func_echo_status, "$@ -> [ Start ]")
-	$(ENV_DOCKER) buildx build --push \
+	$(ENV_DOCKER) buildx build --network=host --push \
 		-t $(IMAGE_NAME):dev \
 		--platform linux/amd64,linux/arm64 \
-		-f ./alpine-dev/Dockerfile .
+		-f ./debian-dev/Dockerfile .
 	@$(call func_echo_success_status, "$@ -> [ Done ]")
 
 
diff --git a/alpine-local/Dockerfile b/alpine-local/Dockerfile
deleted file mode 100644
index b6b6fc3..0000000
--- a/alpine-local/Dockerfile
+++ /dev/null
@@ -1,74 +0,0 @@
-#
-# 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
-
-FROM openresty/openresty:1.19.3.2-alpine-fat AS production-stage
-
-ARG ENABLE_PROXY
-ARG APISIX_PATH
-COPY $APISIX_PATH ./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 --virtual .builddeps \
-    automake \
-    autoconf \
-    libtool \
-    pkgconfig \
-    cmake \
-    git \
-    pcre \
-    pcre-dev \
-    openldap-dev \
-    && cd apisix \
-    && git config --global url.https://github.com/.insteadOf git://github.com/ \
-    && make deps \
-    && cp -v bin/apisix /usr/bin/ \
-    && mv ../apisix /usr/local/apisix \
-    && apk del .builddeps build-base make unzip
-
-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 \
-        curl \
-        libstdc++ \
-        openldap \
-        tzdata
-
-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
-
-# forward request and error logs to docker log collector
-RUN mkdir -p logs && touch logs/access.log && touch logs/error.log \
-    && ln -sf /dev/stdout /usr/local/apisix/logs/access.log \
-    && ln -sf /dev/stderr /usr/local/apisix/logs/error.log
-
-ENV PATH=$PATH:/usr/local/openresty/luajit/bin:/usr/local/openresty/nginx/sbin:/usr/local/openresty/bin
-
-EXPOSE 9080 9443
-
-CMD ["sh", "-c", "/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/debian-dev/Dockerfile b/debian-dev/Dockerfile
new file mode 100644
index 0000000..6d03668
--- /dev/null
+++ b/debian-dev/Dockerfile
@@ -0,0 +1,60 @@
+#
+# 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 api7/apisix-base:dev AS build
+
+ARG ENABLE_PROXY=false
+
+ENV DEBIAN_FRONTEND noninteractive
+
+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 \
+    && apt-get install -y curl \
+        gawk \
+        git \
+        libldap2-dev \
+        liblua5.1-0-dev \
+        lua5.1 \
+        make \
+        sudo \
+        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 \
+    && 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
+
+COPY --from=build /usr/local/apisix /usr/local/apisix
+COPY --from=build /usr/bin/apisix /usr/bin/apisix
+COPY --from=build /usr/local/openresty /usr/local/openresty
+COPY --from=build /usr/local/openresty-debug /usr/local/openresty-debug
+
+WORKDIR /usr/local/apisix
+
+ENV PATH=$PATH:/usr/local/openresty-debug/luajit/bin:/usr/local/openresty-debug/nginx/sbin:/usr/local/openresty-debug/bin
+
+EXPOSE 9080 9443
+
+CMD ["sh", "-c", "/usr/bin/apisix init && /usr/bin/apisix init_etcd && /usr/local/openresty-debug/bin/openresty -p /usr/local/apisix -g 'daemon off;'"]
+
+STOPSIGNAL SIGQUIT