CI: add apisix-docker test (#133)

* feat: add apisix-docker test ci & modify centos dockerfile to solve openssl dependency

* fix: CI

* fix: network

* fix: mount error

* doc: modify apisix to APISIX

* revert apisix image

* fix: ci failed

* fix: ci failed

* fix: docker volumes

* add working-directory in alpine CI

* fix: docker path

* fix: test CI

* fix: CI failed

* fix: docker log container name

* add makefile & upload image tar

* fix: docker image tar path error

* add package path

* fix: upload with name

* fix: upload

* fix: upload name

* change test case

* fix: vars error
diff --git a/.github/workflows/apisix-alpine-docker-test.yaml b/.github/workflows/apisix-alpine-docker-test.yaml
new file mode 100644
index 0000000..74d2c1a
--- /dev/null
+++ b/.github/workflows/apisix-alpine-docker-test.yaml
@@ -0,0 +1,51 @@
+name: APISIX Alpine docker Test
+
+on:
+  push:
+    branches:
+      - master
+  pull_request:
+    branches:
+      - master
+
+jobs:
+  build:
+    runs-on: ubuntu-latest
+    steps:
+      - uses: actions/checkout@v2
+      - name: Build and run
+        run: |
+          make build-on-alpine
+          docker-compose -f ./alpine/docker-compose.yaml up -d
+          sleep 30
+          docker logs alpine_apisix_1
+
+      - name: Test
+        run: |
+          curl http://127.0.0.1:9080/apisix/admin/routes/1 \
+          -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
+            {
+            "uri": "/get",
+            "upstream": {
+                "type": "roundrobin",
+                "nodes": {
+                    "httpbin.org:80": 1
+                }
+            }
+          }'
+
+          result_code=`curl -I -m 10 -o /dev/null -s -w %{http_code} http://127.0.0.1:9080/get`
+          if [[ $result_code -ne 200 ]];then
+                  printf "result_code: %s\n" "$result_code"
+                  exit 125
+          fi
+
+      - name: Tar Image
+        run: |
+          make save-alpine-tar
+
+      - name: Upload Image
+        uses: actions/upload-artifact@v2
+        with:
+          path: ./package
+        
diff --git a/.github/workflows/apisix-centos-docker-test.yaml b/.github/workflows/apisix-centos-docker-test.yaml
new file mode 100644
index 0000000..4e5cd8a
--- /dev/null
+++ b/.github/workflows/apisix-centos-docker-test.yaml
@@ -0,0 +1,51 @@
+name: APISIX Centos docker Test
+
+on:
+  push:
+    branches:
+      - master
+  pull_request:
+    branches:
+      - master
+
+jobs:
+  build:
+    runs-on: ubuntu-latest
+    steps:
+      - uses: actions/checkout@v2
+
+      - name: Build and run
+        run: |
+          make build-on-centos
+          docker-compose -f ./centos/docker-compose.yaml up -d
+          sleep 30
+          docker logs centos_apisix_1
+
+      - name: Test
+        run: |
+          curl http://127.0.0.1:9080/apisix/admin/routes/1 \
+          -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
+            {
+            "uri": "/get",
+            "upstream": {
+                "type": "roundrobin",
+                "nodes": {
+                    "httpbin.org:80": 1
+                }
+            }
+          }'
+
+          result_code=`curl -I -m 10 -o /dev/null -s -w %{http_code} http://127.0.0.1:9080/get`
+          if [[ $result_code -ne 200 ]];then
+                  printf "result_code: %s\n" "$result_code"
+                  exit 125
+          fi
+
+      - name: Tar Image
+        run: |
+          make save-centos-tar
+
+      - name: Upload Image
+        uses: actions/upload-artifact@v2
+        with:
+          path: ./package
diff --git a/.gitignore b/.gitignore
index 090a1f0..e1f0889 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,3 @@
 .idea
 .DS_Store
+./package
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..26bb14a
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,45 @@
+#
+# 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.
+#
+default: help
+
+APISIX_VERSION ?= 2.3
+IMAGE_NAME = apache/apisix
+IMAGE_TAR_NAME = apache_apisix
+
+### build-on-centos:      Build apaceh/apisix:xx-centos image
+build-on-centos:
+	docker build -t $(IMAGE_NAME):$(APISIX_VERSION)-centos -f ./centos/Dockerfile .
+
+### build-on-alpine:      Build apaceh/apisix:xx-alpine image
+build-on-alpine:
+	docker build -t $(IMAGE_NAME):$(APISIX_VERSION)-alpine -f ./alpine/Dockerfile .
+
+### save-centos-tar:      tar apaceh/apisix:xx-centos image
+save-centos-tar:
+	mkdir -p package
+	docker save -o ./package/$(IMAGE_TAR_NAME)_$(APISIX_VERSION)-centos.tar $(IMAGE_NAME):$(APISIX_VERSION)-centos
+
+### save-alpine-tar:      tar apaceh/apisix:xx-alpine image
+save-alpine-tar:
+	mkdir -p package
+	docker save -o ./package/$(IMAGE_TAR_NAME)_$(APISIX_VERSION)-alpine.tar $(IMAGE_NAME):$(APISIX_VERSION)-alpine
+
+### help:             	  Show Makefile rules
+help:
+	@echo Makefile rules:
+	@echo
+	@grep -E '^### [-A-Za-z0-9_]+:' Makefile | sed 's/###/   /'
diff --git a/alpine/docker-compose.yaml b/alpine/docker-compose.yaml
new file mode 100644
index 0000000..9850ea4
--- /dev/null
+++ b/alpine/docker-compose.yaml
@@ -0,0 +1,38 @@
+version: "3"
+
+services:
+  apisix:
+    image: apache/apisix:2.3-alpine
+    restart: always
+    volumes:
+      - ../example/apisix_log:/usr/local/apisix/logs
+      - ../example/apisix_conf/config.yaml:/usr/local/apisix/conf/config.yaml:ro
+    depends_on:
+      - etcd
+    ports:
+      - "9080:9080/tcp"
+      - "9443:9443/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/centos/Dockerfile b/centos/Dockerfile
index bfc7562..3c26392 100644
--- a/centos/Dockerfile
+++ b/centos/Dockerfile
@@ -5,7 +5,7 @@
 
 RUN yum -y install yum-utils\
 	&& yum-config-manager --add-repo https://openresty.org/package/centos/openresty.repo \
-	&& yum install -y openresty \
+	&& yum install -y openresty which \
 	&& yum install -y https://github.com/apache/apisix/releases/download/$APISIX_VERSION/apisix-$APISIX_VERSION-0.x86_64.rpm \
 	&& yum clean all \
 	&& sed -i 's/PASS_MAX_DAYS\t99999/PASS_MAX_DAYS\t60/g' /etc/login.defs
diff --git a/centos/docker-compose.yaml b/centos/docker-compose.yaml
new file mode 100644
index 0000000..76c09b2
--- /dev/null
+++ b/centos/docker-compose.yaml
@@ -0,0 +1,37 @@
+version: "3"
+
+services:
+  apisix:
+    image: apache/apisix:2.3-centos
+    restart: always
+    volumes:
+      - ../example/apisix_log:/usr/local/apisix/logs
+      - ../example/apisix_conf/config.yaml:/usr/local/apisix/conf/config.yaml:ro
+    depends_on:
+      - etcd
+    ports:
+      - "9080:9080/tcp"
+      - "9443:9443/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/example/apisix_conf/config.yaml b/example/apisix_conf/config.yaml
index 73ba6a9..fc22e1b 100644
--- a/example/apisix_conf/config.yaml
+++ b/example/apisix_conf/config.yaml
@@ -16,7 +16,7 @@
 
 etcd:
   host:                           # it's possible to define multiple etcd hosts addresses of the same etcd cluster.
-    - "http://172.18.5.10:2379"     # multiple etcd address
+    - "http://etcd:2379"     # multiple etcd address
   prefix: "/apisix"               # apisix configurations prefix
   timeout: 30                     # 30 seconds