Skip to content

Commit 462a7f3

Browse files
authored
feat: Add dist support for packaging (openresty#67)
1 parent b81154d commit 462a7f3

20 files changed

+248
-58
lines changed

.github/workflows/package-apisix-dashboard.yml renamed to .github/workflows/package-apisix-dashboard-el7.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: package apisix-dashabord
1+
name: package apisix-dashabord rpm for el7
22

33
on:
44
push:
@@ -32,15 +32,15 @@ jobs:
3232
3333
- name: run apisix-dashboard packaging test
3434
run: |
35-
make package type=rpm app=dashboard version=${DASHBOARD_VERSION} checkout=release/${DASHBOARD_VERSION}
35+
make package type=rpm app=dashboard version=${DASHBOARD_VERSION} checkout=release/${DASHBOARD_VERSION} image_base=centos image_tag=7
3636
3737
- name: Run centos7 docker and mapping rpm into container
3838
run: |
3939
docker run -itd -v $PWD/output:/apisix-dashboard --name centos7Instance --net="host" docker.io/centos:7 /bin/bash
4040
4141
- name: Install rpm package
4242
run: |
43-
docker exec centos7Instance bash -c "yum install -y /apisix-dashboard/apisix-dashboard-${DASHBOARD_VERSION}-0.x86_64.rpm"
43+
docker exec centos7Instance bash -c "yum install -y /apisix-dashboard/apisix-dashboard-${DASHBOARD_VERSION}-0.el7.x86_64.rpm"
4444
docker logs centos7Instance
4545
docker exec centos7Instance bash -c "cd /usr/local/apisix/dashboard/ && nohup ./manager-api &"
4646
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: package apisix-dashabord rpm for el8
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
branches: [ master ]
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
env:
13+
DASHBOARD_VERSION: 2.7
14+
services:
15+
etcd:
16+
image: bitnami/etcd:3.4.0
17+
ports:
18+
- 2379:2379
19+
- 2380:2380
20+
env:
21+
ALLOW_NONE_AUTHENTICATION: yes
22+
ETCD_ADVERTISE_CLIENT_URLS: http://0.0.0.0:2379
23+
24+
steps:
25+
- uses: actions/checkout@v2
26+
27+
- name: install dependencies
28+
run: |
29+
sudo apt-get install -y make ruby ruby-dev rubygems build-essential
30+
sudo gem install --no-document fpm
31+
sudo apt-get install -y rpm
32+
33+
- name: run apisix-dashboard packaging test
34+
run: |
35+
make package type=rpm app=dashboard version=${DASHBOARD_VERSION} checkout=release/${DASHBOARD_VERSION} image_base=centos image_tag=8
36+
37+
- name: Run centos8 docker and mapping rpm into container
38+
run: |
39+
docker run -itd -v $PWD/output:/apisix-dashboard --name centos8Instance --net="host" docker.io/centos:8 /bin/bash
40+
41+
- name: Install rpm package
42+
run: |
43+
docker exec centos8Instance bash -c "yum install -y /apisix-dashboard/apisix-dashboard-${DASHBOARD_VERSION}-0.el8.x86_64.rpm"
44+
docker logs centos8Instance
45+
docker exec centos8Instance bash -c "cd /usr/local/apisix/dashboard/ && nohup ./manager-api &"
46+
47+
- name: Run test cases
48+
run: |
49+
code=$(curl -k -i -m 20 -o /dev/null -s -w %{http_code} http://127.0.0.1:9000)
50+
if [ ! $code -eq 200 ]; then
51+
echo "failed: failed to install Apache APISIX Dashboard by rpm"
52+
exit 1
53+
fi
54+

.github/workflows/package-apisix-deb.yml renamed to .github/workflows/package-apisix-deb-default.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: package apisix deb
1+
name: package apisix deb for the default image ubuntu 20.04(Focal Fossa)
22

33
on:
44
push:
@@ -28,7 +28,7 @@ jobs:
2828
2929
- name: install apisix deb into container
3030
run: |
31-
docker build -t apache/apisix:${PACKAGE_APISIX_VERSION}-deb-test --build-arg APISIX_VERSION=${PACKAGE_APISIX_VERSION} -f test/apisix/Dockerfile.test.apisix.deb .
31+
docker build -t apache/apisix:${PACKAGE_APISIX_VERSION}-deb-test --build-arg APISIX_VERSION=${PACKAGE_APISIX_VERSION} -f test/apisix/Dockerfile.test.apisix.deb.ubuntu20.04 .
3232
3333
- name: start apisix and test
3434
run: |
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: package apisix deb for ubuntu 20.04(Focal Fossa)
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
branches: [ master ]
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
env:
13+
PACKAGE_APISIX_VERSION: 2.7
14+
15+
steps:
16+
- uses: actions/checkout@v2
17+
18+
- name: install dependencies
19+
run: |
20+
sudo apt-get install -y make
21+
22+
- name: run apisix packaging
23+
run: |
24+
make package type=deb app=apisix version=2.3 checkout=2.3 image_base=ubuntu image_tag=20.04
25+
make package type=deb app=apisix version=2.2 checkout=v2.2 image_base=ubuntu image_tag=20.04
26+
make package type=deb app=apisix version=master checkout=master image_base=ubuntu image_tag=20.04
27+
make package type=deb app=apisix version=${PACKAGE_APISIX_VERSION} checkout=${PACKAGE_APISIX_VERSION} image_base=ubuntu image_tag=20.04
28+
29+
- name: install apisix deb into container
30+
run: |
31+
docker build -t apache/apisix:${PACKAGE_APISIX_VERSION}-deb-test --build-arg APISIX_VERSION=${PACKAGE_APISIX_VERSION} -f test/apisix/Dockerfile.test.apisix.deb.ubuntu20.04 .
32+
33+
- name: start apisix and test
34+
run: |
35+
docker run -d --rm --name apisix-${PACKAGE_APISIX_VERSION}-deb-test -v $(pwd)/test/apisix/config.yaml:/usr/local/apisix/conf/config.yaml -p 9080:9080 -p 9443:9443 apache/apisix:${PACKAGE_APISIX_VERSION}-deb-test
36+
sleep 20
37+
curl http://127.0.0.1:9080/apisix/admin/routes/1 \
38+
-H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
39+
{
40+
"uri": "/get",
41+
"upstream": {
42+
"type": "roundrobin",
43+
"nodes": {
44+
"httpbin.org:80": 1
45+
}
46+
}
47+
}'
48+
result_code=`curl -I -m 10 -o /dev/null -s -w %{http_code} http://127.0.0.1:9080/get`
49+
if [[ $result_code -ne 200 ]]; then
50+
printf "result_code: %s\n" "$result_code"
51+
exit 125
52+
fi

.github/workflows/package-apisix-openresty.yml renamed to .github/workflows/package-apisix-openresty-el7.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: package apisix-openresty
1+
name: package apisix-openresty rpm for el7
22

33
on:
44
push:
@@ -22,7 +22,7 @@ jobs:
2222
2323
- name: build apisix-openresty rpm
2424
run: |
25-
make package type=rpm app=apisix-openresty version=${BUILD_APISIX_OR_VERSION}
25+
make package type=rpm app=apisix-openresty version=${BUILD_APISIX_OR_VERSION} image_base=centos image_tag=7
2626
2727
- name: run centos7 docker and mapping apisix-openresty rpm into container
2828
run: |
@@ -35,7 +35,7 @@ jobs:
3535
3636
- name: install rpm in container
3737
run: |
38-
docker exec centos7Instance bash -c "yum -y localinstall /output/apisix-openresty-${BUILD_APISIX_OR_VERSION}-0.x86_64.rpm"
38+
docker exec centos7Instance bash -c "yum -y localinstall /output/apisix-openresty-${BUILD_APISIX_OR_VERSION}-0.el7.x86_64.rpm"
3939
4040
- name: check and ensure openresty is installed
4141
run: |

.github/workflows/package-apisix-rpm.yml renamed to .github/workflows/package-apisix-rpm-el7.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: package apisix rpm
1+
name: package apisix rpm for el7
22

33
on:
44
push:
@@ -30,8 +30,8 @@ jobs:
3030
3131
- name: packaging APISIX
3232
run: |
33-
make package type=rpm app=apisix version=2.7 checkout=release/2.7
34-
make package type=rpm app=apisix version=master checkout=master
33+
make package type=rpm app=apisix version=2.7 checkout=release/2.7 image_base=centos image_tag=7
34+
make package type=rpm app=apisix version=master checkout=master image_base=centos image_tag=7
3535
3636
- name: run centos7 docker and mapping rpm into container
3737
run: |
@@ -44,7 +44,7 @@ jobs:
4444
4545
- name: install APISIX by rpm in container
4646
run: |
47-
docker exec centos7Instance bash -c "yum -y localinstall /output/apisix-master-0.x86_64.rpm"
47+
docker exec centos7Instance bash -c "yum -y localinstall /output/apisix-master-0.el7.x86_64.rpm"
4848
docker exec centos7Instance bash -c "apisix start"
4949
5050
- name: check and ensure APISIX is installed

Makefile

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,21 @@ image_base="centos"
2323
image_tag="7"
2424
iteration=0
2525

26+
### set the default image for deb package
27+
ifeq ($(type), deb)
28+
image_base="ubuntu"
29+
image_tag="20.04"
30+
endif
31+
2632
### function for building
2733
### $(1) is name
2834
### $(2) is dockerfile filename
2935
### $(3) is package type
3036
define build
31-
docker build -t apache/$(1)-$(3):$(version) --build-arg checkout_v=$(checkout) \
37+
docker build -t apache/$(1)-$(3):$(version) \
38+
--build-arg checkout_v=$(checkout) \
39+
--build-arg IMAGE_BASE=$(image_base) \
40+
--build-arg IMAGE_TAG=$(image_tag) \
3241
-f ./dockerfiles/Dockerfile.$(2).$(3) .
3342
endef
3443

@@ -79,7 +88,10 @@ package-dashboard-rpm:
7988
### build apisix-openresty:
8089
.PHONY: build-apisix-openresty-rpm
8190
build-apisix-openresty-rpm:
82-
docker build -t apache/apisix-openresty-rpm:$(version) --build-arg version=$(version) \
91+
docker build -t apache/apisix-openresty-rpm:$(version) \
92+
--build-arg version=$(version) \
93+
--build-arg IMAGE_BASE=$(image_base) \
94+
--build-arg IMAGE_TAG=$(image_tag) \
8395
-f ./dockerfiles/Dockerfile.apisix-openresty.rpm .
8496

8597
### build rpm for apisix-openresty:

README.md

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,28 +13,41 @@
1313
|checkout |True |the code branch or tag of the app which you want to package|checkout=2.1 or checkout=v2.1|
1414
|version |True |the version of the package|version=10.10|
1515
|image_base|False |the environment for packaging, if type is `rpm` the default image_base is `centos`, if type is `deb` the default image_base is `ubuntu`|image_base=centos|
16-
|image_tag|False |the environment for packaging, it's value can be `xenial\|bionic\|focal\|6\|7\|8`, if type is `rpm` the default image_tag is `7`, if type is `deb` the default image_tag is `bionic`|image_tag=7|
16+
|image_tag|False |the environment for packaging, it's value can be `16.04\|18.04\|20.04\|6\|7\|8`, if type is `rpm` the default image_tag is `7`, if type is `deb` the default image_tag is `20.04`|image_tag=7|
1717

1818
## Example
1919
Packaging a Centos 7 package of Apache APISIX
2020
```sh
21+
make package type=rpm app=apisix version=2.2 checkout=2.2 image_base=centos image_tag=7
22+
ls output/
23+
apisix-2.2-0.el7.x86_64.rpm
24+
```
25+
or just leave `image_base` and `image_tag` as the default values.
26+
```
2127
make package type=rpm app=apisix version=2.2 checkout=2.2
2228
ls output/
23-
apisix-2.2-0.x86_64.rpm
29+
apisix-2.2-0.el7.x86_64.rpm
30+
```
31+
32+
Packaging a Centos 8 package of Apache APISIX
33+
```sh
34+
make package type=rpm app=apisix version=2.2 checkout=2.2 image_base=centos image_tag=8
35+
ls output/
36+
apisix-2.2-0.el8.x86_64.rpm
2437
```
2538

2639
Packaging a Centos 7 package of Apache APISIX Dashboard
2740
```sh
28-
make package type=rpm app=dashboard version=2.4 checkout=v2.4
41+
make package type=rpm app=dashboard version=2.4 checkout=v2.4 image_base=centos image_tag=7
2942
ls output/
30-
apisix-dashboard-2.4-0.x86_64.rpm
43+
apisix-dashboard-2.4-0.el7.x86_64.rpm
3144
```
3245

3346
Packaging a Centos 7 package of APISIX's OpenResty distribution
3447
```sh
35-
make package type=rpm app=apisix-openresty version=1.0.0
48+
make package type=rpm app=apisix-openresty version=1.0.0 image_base=centos image_tag=7
3649
ls output/
37-
apisix-openresty-1.0.0-0.x86_64.rpm
50+
apisix-openresty-1.0.0-0.el7.x86_64.rpm
3851
```
3952

4053
## Details
Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,21 @@
1-
ARG image_base="centos"
2-
ARG image_tag="7"
1+
ARG IMAGE_BASE="centos"
2+
ARG IMAGE_TAG="7"
33

4-
FROM ${image_base}:${image_tag}
4+
FROM ${IMAGE_BASE}:${IMAGE_TAG}
55

66
COPY build-apisix-openresty-centos7.sh /tmp/build-apisix-openresty-centos7.sh
77
COPY build-apisix-openresty.sh /tmp/build-apisix-openresty.sh
8+
COPY ./utils/determine-dist.sh /tmp/determine-dist.sh
89

910
WORKDIR /tmp
1011

1112
ARG version
12-
RUN version=${version} ./build-apisix-openresty-centos7.sh
13+
ARG IMAGE_BASE
14+
ARG IMAGE_TAG
15+
16+
ENV IMAGE_BASE=${IMAGE_BASE}
17+
ENV IMAGE_TAG=${IMAGE_TAG}
18+
19+
RUN version=${version} ./build-apisix-openresty-centos7.sh \
20+
# determine dist and write it into /tmp/dist file
21+
&& /tmp/determine-dist.sh

dockerfiles/Dockerfile.apisix.deb

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,27 @@
1-
ARG image_base="ubuntu"
2-
ARG image_tag="20.04"
3-
ARG iteration="0"
4-
ARG apisix_repo="https://github.com/apache/apisix"
5-
ARG checkout_v
1+
ARG IMAGE_BASE="ubuntu"
2+
ARG IMAGE_TAG="20.04"
63

7-
FROM ${image_base}:${image_tag}
4+
FROM ${IMAGE_BASE}:${IMAGE_TAG}
85

96
COPY ./utils/install-common.sh /install-common.sh
7+
COPY ./utils/determine-dist.sh /determine-dist.sh
8+
9+
ARG iteration="0"
10+
ARG apisix_repo="https://github.com/apache/apisix"
11+
ARG checkout_v
12+
ARG IMAGE_BASE
13+
ARG IMAGE_TAG
1014

1115
# install dependencies
1216
RUN /install-common.sh install_apisix_dependencies_deb
1317

14-
ARG checkout_v
15-
ARG iteration
16-
ARG apisix_repo
17-
1818
ENV checkout_v=${checkout_v}
1919
ENV iteration=${iteration}
2020
ENV apisix_repo=${apisix_repo}
21+
ENV IMAGE_BASE=${IMAGE_BASE}
22+
ENV IMAGE_TAG=${IMAGE_TAG}
2123

2224
# install apisix
23-
RUN /install-common.sh install_apisix
25+
RUN /install-common.sh install_apisix \
26+
# determine dist and write it into /tmp/dist file
27+
&& /determine-dist.sh

dockerfiles/Dockerfile.apisix.rpm

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,27 @@
1-
ARG image_base="centos"
2-
ARG image_tag="7"
3-
ARG iteration="0"
4-
ARG apisix_repo="https://github.com/apache/apisix"
5-
ARG checkout_v
1+
ARG IMAGE_BASE="centos"
2+
ARG IMAGE_TAG="7"
63

7-
FROM ${image_base}:${image_tag}
4+
FROM ${IMAGE_BASE}:${IMAGE_TAG}
85

96
COPY ./utils/install-common.sh /install-common.sh
7+
COPY ./utils/determine-dist.sh /determine-dist.sh
8+
9+
ARG iteration="0"
10+
ARG apisix_repo="https://github.com/apache/apisix"
11+
ARG checkout_v
12+
ARG IMAGE_BASE
13+
ARG IMAGE_TAG
1014

1115
# install dependencies
1216
RUN /install-common.sh install_apisix_dependencies_rpm
1317

14-
ARG checkout_v
15-
ARG iteration
16-
ARG apisix_repo
17-
1818
ENV checkout_v=${checkout_v}
1919
ENV iteration=${iteration}
2020
ENV apisix_repo=${apisix_repo}
21+
ENV IMAGE_BASE=${IMAGE_BASE}
22+
ENV IMAGE_TAG=${IMAGE_TAG}
2123

2224
# install apisix
23-
RUN /install-common.sh install_apisix
25+
RUN /install-common.sh install_apisix \
26+
# determine dist and write it into /tmp/dist file
27+
&& /determine-dist.sh

0 commit comments

Comments
 (0)