feat: add build for platform=redhat with ubi based image (#462)
diff --git a/.github/workflows/apisix-docker-example-test.yaml b/.github/workflows/apisix-docker-example-test.yaml
index 96b0752..db6bbc4 100644
--- a/.github/workflows/apisix-docker-example-test.yaml
+++ b/.github/workflows/apisix-docker-example-test.yaml
@@ -43,6 +43,7 @@
platform:
- centos
- debian
+ - redhat
steps:
- uses: actions/checkout@v2
diff --git a/.github/workflows/apisix_push_docker_hub.yaml b/.github/workflows/apisix_push_docker_hub.yaml
index c6ff77d..2ce3b48 100644
--- a/.github/workflows/apisix_push_docker_hub.yaml
+++ b/.github/workflows/apisix_push_docker_hub.yaml
@@ -12,6 +12,7 @@
platform:
- centos
- debian
+ - redhat
env:
APISIX_DOCKER_TAG: 3.3.0-${{ matrix.platform }}
diff --git a/Makefile b/Makefile
index b208308..a94dcfa 100644
--- a/Makefile
+++ b/Makefile
@@ -69,6 +69,12 @@
$(ENV_DOCKER) build -t $(ENV_APISIX_IMAGE_TAG_NAME)-centos -f ./centos/Dockerfile centos
@$(call func_echo_success_status, "$@ -> [ Done ]")
+### build-on-redhat : Build apache/apisix:xx-redhat image
+.PHONY: build-on-redhat
+build-on-redhat:
+ @$(call func_echo_status, "$@ -> [ Start ]")
+ $(ENV_DOCKER) build -t $(ENV_APISIX_IMAGE_TAG_NAME)-redhat -f ./redhat/Dockerfile redhat
+ @$(call func_echo_success_status, "$@ -> [ Done ]")
### build-on-debian-dev : Build apache/apisix:xx-debian-dev image
.PHONY: build-on-debian-dev
@@ -118,6 +124,15 @@
-f ./centos/Dockerfile centos
@$(call func_echo_success_status, "$@ -> [ Done ]")
+### push-multiarch-on-redhat : Push apache/apisix:xx-redhat image
+.PHONY: push-multiarch-on-redhat
+push-multiarch-on-redhat:
+ @$(call func_echo_status, "$@ -> [ Start ]")
+ $(ENV_DOCKER) buildx build --network=host --push \
+ -t $(ENV_APISIX_IMAGE_TAG_NAME)-redhat \
+ --platform linux/amd64 \
+ -f ./redhat/Dockerfile redhat
+ @$(call func_echo_success_status, "$@ -> [ Done ]")
### push-multiarch-on-latest : Push apache/apisix:latest image
.PHONY: push-multiarch-on-latest
diff --git a/redhat/Dockerfile b/redhat/Dockerfile
new file mode 100644
index 0000000..645909a
--- /dev/null
+++ b/redhat/Dockerfile
@@ -0,0 +1,46 @@
+#
+# 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 registry.access.redhat.com/ubi8/ubi:8.6
+
+ARG APISIX_VERSION=3.3.0
+LABEL apisix_version="${APISIX_VERSION}"
+COPY ./yum.repos.d/apache-apisix.repo /etc/yum.repos.d/apache-apisix.repo
+COPY ./yum.repos.d/openresty.repo /etc/yum.repos.d/openresty.repo
+
+RUN yum update -y \
+ && yum install -y apisix-${APISIX_VERSION} \
+ && yum clean all \
+ && sed -i 's/PASS_MAX_DAYS\t99999/PASS_MAX_DAYS\t60/g' /etc/login.defs
+
+WORKDIR /usr/local/apisix
+
+ENV PATH=$PATH:/usr/local/openresty/luajit/bin:/usr/local/openresty/nginx/sbin:/usr/local/openresty/bin
+
+# 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
+
+COPY ./docker-entrypoint.sh /docker-entrypoint.sh
+
+ENTRYPOINT ["/docker-entrypoint.sh"]
+
+CMD ["docker-start"]
+
+STOPSIGNAL SIGQUIT
diff --git a/redhat/docker-entrypoint.sh b/redhat/docker-entrypoint.sh
new file mode 100755
index 0000000..3b6802b
--- /dev/null
+++ b/redhat/docker-entrypoint.sh
@@ -0,0 +1,46 @@
+#!/usr/bin/env bash
+#
+# 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.
+#
+
+set -eo pipefail
+
+PREFIX=${APISIX_PREFIX:=/usr/local/apisix}
+
+if [[ "$1" == "docker-start" ]]; then
+ if [ "$APISIX_STAND_ALONE" = "true" ]; then
+ cat > ${PREFIX}/conf/config.yaml << _EOC_
+deployment:
+ role: data_plane
+ role_data_plane:
+ config_provider: yaml
+_EOC_
+
+ cat > ${PREFIX}/conf/apisix.yaml << _EOC_
+routes:
+ -
+#END
+_EOC_
+ /usr/bin/apisix init
+ else
+ /usr/bin/apisix init
+ /usr/bin/apisix init_etcd
+ fi
+
+ exec /usr/local/openresty/bin/openresty -p /usr/local/apisix -g 'daemon off;'
+fi
+
+exec "$@"
diff --git a/redhat/yum.repos.d/apache-apisix.repo b/redhat/yum.repos.d/apache-apisix.repo
new file mode 100644
index 0000000..2108627
--- /dev/null
+++ b/redhat/yum.repos.d/apache-apisix.repo
@@ -0,0 +1,9 @@
+[release]
+name=Apache APISIX Repository for Redhat
+baseurl=https://repos.apiseven.com/packages/redhat/$releasever/$basearch
+skip_if_unavailable=False
+gpgcheck=1
+repo_gpgcheck=1
+gpgkey=https://repos.apiseven.com/KEYS
+enabled=1
+enabled_metadata=1
diff --git a/redhat/yum.repos.d/openresty.repo b/redhat/yum.repos.d/openresty.repo
new file mode 100644
index 0000000..942aa7c
--- /dev/null
+++ b/redhat/yum.repos.d/openresty.repo
@@ -0,0 +1,9 @@
+[openresty]
+name=Official OpenResty Open Source Repository for CentOS
+baseurl=https://openresty.org/package/centos/$releasever/$basearch
+skip_if_unavailable=False
+gpgcheck=1
+repo_gpgcheck=0
+gpgkey=https://openresty.org/package/pubkey.gpg
+enabled=1
+enabled_metadata=1