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/08/05 06:03:36 UTC

[apisix-docker] branch master updated: feat: add multiarch debian docker image (#339)

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 588510d  feat: add multiarch debian docker image (#339)
588510d is described below

commit 588510deddbab48de366faecb58b1b593c3317d0
Author: soulbird <zh...@outlook.com>
AuthorDate: Fri Aug 5 14:03:30 2022 +0800

    feat: add multiarch debian docker image (#339)
---
 .github/workflows/apisix-docker-test.yaml     |  1 +
 .github/workflows/apisix_push_docker_hub.yaml |  1 +
 Makefile                                      | 28 +++++++++++++
 debian/Dockerfile                             | 58 +++++++++++++++++++++++++++
 debian/hooks/build                            | 22 ++++++++++
 5 files changed, 110 insertions(+)

diff --git a/.github/workflows/apisix-docker-test.yaml b/.github/workflows/apisix-docker-test.yaml
index a711523..a183fbb 100644
--- a/.github/workflows/apisix-docker-test.yaml
+++ b/.github/workflows/apisix-docker-test.yaml
@@ -16,6 +16,7 @@ jobs:
         platform:
           - alpine
           - centos
+          - debian
           - debian-dev
 
     runs-on: ubuntu-latest
diff --git a/.github/workflows/apisix_push_docker_hub.yaml b/.github/workflows/apisix_push_docker_hub.yaml
index 3096e25..35bea7a 100644
--- a/.github/workflows/apisix_push_docker_hub.yaml
+++ b/.github/workflows/apisix_push_docker_hub.yaml
@@ -24,6 +24,7 @@ jobs:
 
       - name: Push apisix image to Docker Hub
         run: |
+          make push-multiarch-on-debian
           make push-multiarch-on-alpine
           make build-on-centos
           make push-on-centos
diff --git a/Makefile b/Makefile
index a18ac4a..b1f3e5a 100644
--- a/Makefile
+++ b/Makefile
@@ -84,6 +84,14 @@ build-on-debian-dev:
 	@$(call func_echo_success_status, "$@ -> [ Done ]")
 
 
+### build-on-debian : Build apache/apisix:xx-debian image
+.PHONY: build-on-debian
+build-on-debian:
+	@$(call func_echo_status, "$@ -> [ Start ]")
+	$(ENV_DOCKER) build -t $(ENV_APISIX_IMAGE_TAG_NAME)-debian -f ./debian/Dockerfile .
+	@$(call func_echo_success_status, "$@ -> [ Done ]")
+
+
 ### push-on-centos : Push apache/apisix:xx-centos image
 # centos not support multiarch since it reply on x86 rpm package
 .PHONY: push-on-centos
@@ -117,6 +125,17 @@ push-multiarch-dev-on-debian:
 	@$(call func_echo_success_status, "$@ -> [ Done ]")
 
 
+### push-multiarch-on-debian : Push apache/apisix:xx-debian image
+.PHONY: push-multiarch-on-debian
+push-multiarch-on-debian:
+	@$(call func_echo_status, "$@ -> [ Start ]")
+	$(ENV_DOCKER) buildx build --network=host --push \
+		-t $(ENV_APISIX_IMAGE_TAG_NAME)-debian \
+		--platform linux/amd64,linux/arm64 \
+		-f ./debian/Dockerfile .
+	@$(call func_echo_success_status, "$@ -> [ Done ]")
+
+
 ### build-on-alpine-cn : Build apache/apisix:xx-alpine image (for chinese)
 .PHONY: build-on-alpine-cn
 build-on-alpine-cn:
@@ -159,6 +178,15 @@ save-alpine-tar:
 	@$(call func_echo_success_status, "$@ -> [ Done ]")
 
 
+### save-debian-tar : tar apache/apisix:xx-debian image
+.PHONY: save-debian-tar
+save-debian-tar:
+	@$(call func_echo_status, "$@ -> [ Start ]")
+	mkdir -p package
+	$(ENV_DOCKER) save -o ./package/$(ENV_APISIX_TAR_NAME)-debian.tar $(ENV_APISIX_IMAGE_TAG_NAME)-debian
+	@$(call func_echo_success_status, "$@ -> [ Done ]")
+
+
 ### build-dashboard-centos : Build apache/dashboard:tag image on centos
 .PHONY: build-dashboard-centos
 build-dashboard-centos:
diff --git a/debian/Dockerfile b/debian/Dockerfile
new file mode 100644
index 0000000..641b6fd
--- /dev/null
+++ b/debian/Dockerfile
@@ -0,0 +1,58 @@
+#
+# 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 IMAGE_BASE="debian"
+ARG IMAGE_TAG="bullseye"
+
+FROM ${IMAGE_BASE}:${IMAGE_TAG}-slim
+
+ARG TARGETARCH
+ARG APISIX_VERSION=2.15.0
+
+RUN set -ex; \
+    arch=$(dpkg --print-architecture); \
+    apt update; \
+    apt-get -y install --no-install-recommends wget gnupg ca-certificates; \
+    codename=`grep -Po 'VERSION="[0-9]+ \(\K[^)]+' /etc/os-release`; \
+    wget -O - https://openresty.org/package/pubkey.gpg | apt-key add -; \
+    case "${arch}" in \
+      amd64) \
+        echo "deb http://openresty.org/package/debian $codename openresty" | tee /etc/apt/sources.list.d/openresty.list \
+        && wget -O - http://repos.apiseven.com/pubkey.gpg | apt-key add - \
+        && echo "deb http://repos.apiseven.com/packages/debian $codename main" | tee /etc/apt/sources.list.d/apisix.list \
+        ;; \
+      arm64) \
+        echo "deb http://openresty.org/package/arm64/debian $codename openresty" | tee /etc/apt/sources.list.d/openresty.list \
+        && wget -O - http://repos.apiseven.com/pubkey.gpg | apt-key add - \
+        && echo "deb http://repos.apiseven.com/packages/arm64/debian $codename main" | tee /etc/apt/sources.list.d/apisix.list \
+        ;; \
+    esac; \
+    apt update \
+    && apt install -y apisix=${APISIX_VERSION}-0 \
+    && apt-get purge -y --auto-remove \
+    && rm -f /etc/apt/sources.list.d/openresty.list /etc/apt/sources.list.d/apisix.list \
+    && openresty -V \
+    && apisix version
+
+WORKDIR /usr/local/apisix
+
+# forward request and error logs to docker log collector
+RUN ln -sf /dev/stdout /usr/local/apisix/logs/access.log \
+    && ln -sf /dev/stderr /usr/local/apisix/logs/error.log
+
+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;'"]
diff --git a/debian/hooks/build b/debian/hooks/build
new file mode 100644
index 0000000..e229008
--- /dev/null
+++ b/debian/hooks/build
@@ -0,0 +1,22 @@
+#!/bin/bash
+# hooks/build
+# https://docs.docker.com/docker-cloud/builds/advanced/
+
+#
+# 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.
+#
+
+docker build --build-arg APISIX_VERSION=$APISIX_VERSION -t $IMAGE_NAME .