Skip to content

Commit b2d02e8

Browse files
authored
feat: use docker to deploy fpm (#55)
1 parent 4062f0d commit b2d02e8

10 files changed

+152
-62
lines changed

Makefile

Lines changed: 40 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -28,88 +28,65 @@ iteration=0
2828
### build apisix:
2929
.PHONY: build-apisix-rpm
3030
build-apisix-rpm:
31-
mkdir -p ${PWD}/build/rpm
32-
docker build -t apache/apisix:$(version) --build-arg checkout_v=$(checkout) -f ./dockerfiles/Dockerfile.apisix.rpm .
33-
docker run -d --name dockerInstance --net="host" apache/apisix:$(version)
34-
docker cp dockerInstance:/tmp/build/output/ ${PWD}/build/rpm
35-
docker system prune -a -f
31+
docker build -t apache/apisix:$(version) --build-arg checkout_v=$(checkout) \
32+
-f ./dockerfiles/Dockerfile.apisix.rpm .
3633

3734
### build rpm for apisix:
3835
.PHONY: package-apisix-rpm
3936
package-apisix-rpm:
40-
fpm -f -s dir -t rpm \
41-
-n apisix \
42-
-a `uname -i` \
43-
-v $(version) \
44-
--iteration $(iteration) \
45-
-d 'openresty >= 1.17.8.2' \
46-
--description 'Apache APISIX is a distributed gateway for APIs and Microservices, focused on high performance and reliability.' \
47-
--license "ASL 2.0" \
48-
-C ${PWD}/build/rpm/output/apisix/ \
49-
-p ${PWD}/output/ \
50-
--url 'http://apisix.apache.org/' \
51-
--config-files usr/lib/systemd/system/apisix.service
52-
rm -rf ${PWD}/build
37+
docker build -t apache/apisix-packaged:$(version) \
38+
--build-arg VERSION=$(version) \
39+
--build-arg ITERATION=$(iteration) \
40+
--build-arg PACKAGE_VERSION=$(version) \
41+
-f ./dockerfiles/Dockerfile.package.apisix .
42+
docker run -d --rm --name output --net="host" apache/apisix-packaged:$(version)
43+
docker cp output:/output ${PWD}
44+
docker stop output
45+
docker system prune -a -f
5346

5447
### build dashboard:
5548
.PHONY: build-dashboard-rpm
5649
build-dashboard-rpm:
57-
mkdir -p ${PWD}/build/rpm
58-
docker build -t apache/apisix-dashboard:$(version) --build-arg checkout_v=$(checkout) -f ./dockerfiles/Dockerfile.dashboard.rpm .
59-
docker run -d --name dockerInstance --net="host" apache/apisix-dashboard:$(version)
60-
docker cp dockerInstance:/tmp/build/output/ ${PWD}/build/rpm
61-
docker system prune -a -f
50+
docker build -t apache/apisix-dashboard:$(version) --build-arg checkout_v=$(checkout) \
51+
-f ./dockerfiles/Dockerfile.dashboard.rpm .
6252

6353
### build rpm for apisix dashboard:
6454
.PHONY: package-dashboard-rpm
6555
package-dashboard-rpm:
66-
fpm -f -s dir -t rpm \
67-
-n apisix-dashboard \
68-
-a `uname -i` \
69-
-v $(version) \
70-
--iteration $(iteration) \
71-
--description 'Apache APISIX Dashboard is designed to make it as easy as possible for users to operate Apache APISIX through a frontend interface.' \
72-
--license "ASL 2.0" \
73-
-C ${PWD}/build/rpm/output/apisix/dashboard/ \
74-
-p ${PWD}/output/ \
75-
--url 'https://github.com/apache/apisix-dashboard'
76-
77-
rm -rf ${PWD}/build
56+
docker build -t apache/apisix-dashboard-packaged:$(version) \
57+
--build-arg VERSION=$(version) \
58+
--build-arg ITERATION=$(iteration) \
59+
--build-arg PACKAGE_VERSION=$(version) \
60+
-f ./dockerfiles/Dockerfile.package.apisix-dashboard .
61+
docker run -d --rm --name output --net="host" apache/apisix-dashboard-packaged:$(version)
62+
docker cp output:/output ${PWD}/output
63+
docker stop output
64+
docker system prune -a -f
7865

7966
### build apisix-openresty:
8067
.PHONY: build-apisix-openresty-rpm
8168
build-apisix-openresty-rpm:
82-
mkdir -p ${PWD}/build/rpm
8369
docker build -t apache/apisix-openresty:$(version) --build-arg version=$(version) \
8470
-f ./dockerfiles/Dockerfile.apisix-openresty.rpm .
85-
docker run -d --name dockerInstance --net="host" apache/apisix-openresty:$(version)
86-
docker cp dockerInstance:/usr/local/openresty/ ${PWD}/build/rpm
87-
docker system prune -a -f
8871

8972
### build rpm for apisix-openresty:
9073
.PHONY: package-apisix-openresty-rpm
9174
package-apisix-openresty-rpm:
92-
fpm -f -s dir -t rpm \
93-
-n apisix-openresty \
94-
-a `uname -i` \
95-
-v $(version) \
96-
--iteration $(iteration) \
97-
-x openresty/zlib \
98-
-x openresty/openssl111 \
99-
-x openresty/pcre \
100-
-d 'openresty-zlib >= 1.2.11-3' \
101-
-d 'openresty-openssl111 >= 1.1.1h-1' \
102-
-d 'openresty-pcre >= 8.44-1' \
103-
--post-install ${PWD}/post-install-apisix-openresty.sh \
104-
--description "APISIX's OpenResty distribution." \
105-
--license "ASL 2.0" \
106-
-C ${PWD}/build/rpm \
107-
-p ${PWD}/output/ \
108-
--url 'http://apisix.apache.org/' \
109-
--conflicts openresty \
110-
--config-files usr/lib/systemd/system/openresty.service \
111-
--prefix=/usr/local
112-
rm -rf ${PWD}/build
75+
docker build -t apache/apisix-openresty-packaged:$(version) \
76+
--build-arg VERSION=$(version) \
77+
--build-arg ITERATION=$(iteration) \
78+
--build-arg PACKAGE_VERSION=$(version) \
79+
-f ./dockerfiles/Dockerfile.package.apisix-openresty .
80+
docker run -d --rm --name output --net="host" apache/apisix-openresty-packaged:$(version)
81+
docker cp output:/output ${PWD}
82+
docker stop output
83+
docker system prune -a -f
84+
85+
86+
### build fpm for packaging:
87+
.PHONY: build-fpm
88+
build-fpm:
89+
docker build -t api7/fpm - < ./dockerfiles/Dockerfile.fpm
11390

11491
ifeq ($(filter $(app),apisix dashboard apisix-openresty),)
11592
$(info the app's value have to be apisix or dashboard!)
@@ -121,17 +98,20 @@ else ifeq ($(version), 0)
12198
$(info you have to input a version value!)
12299

123100
else ifeq ($(app)_$(type),apisix-openresty_rpm)
101+
package: build-fpm
124102
package: build-apisix-openresty-rpm
125103
package: package-apisix-openresty-rpm
126104

127105
else ifeq ($(checkout), 0)
128106
$(info you have to input a checkout value!)
129107

130108
else ifeq ($(app)_$(type),apisix_rpm)
109+
package: build-fpm
131110
package: build-apisix-rpm
132111
package: package-apisix-rpm
133112

134113
else ifeq ($(app)_$(type),dashboard_rpm)
114+
package: build-fpm
135115
package: build-dashboard-rpm
136116
package: package-dashboard-rpm
137117

dockerfiles/Dockerfile.apisix.rpm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
ARG image_base="centos"
22
ARG image_tag="7"
3-
ARG checkout_v="2.2"
43
ARG iteration="0"
54
ARG apisix_repo="https://github.com/apache/apisix"
5+
ARG checkout_v
66

77
FROM ${image_base}:${image_tag}
88

dockerfiles/Dockerfile.dashboard.rpm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ RUN set -x \
1010
# install dependency
1111
&& yum install -y wget curl git which gcc make \
1212
&& curl --silent --location https://dl.yarnpkg.com/rpm/yarn.repo | tee /etc/yum.repos.d/yarn.repo \
13-
&& sh -c "$(curl -fsSL https://rpm.nodesource.com/setup_10.x)" \
13+
&& sh -c "$(curl -fsSL https://rpm.nodesource.com/setup_14.x)" \
1414
&& yum install -y nodejs yarn \
1515
&& wget https://dl.google.com/go/go1.15.2.linux-amd64.tar.gz \
1616
&& tar -xzf go1.15.2.linux-amd64.tar.gz \

dockerfiles/Dockerfile.fpm

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
FROM ubuntu:focal
2+
3+
RUN DEBIAN_FRONTEND=noninteractive apt-get update \
4+
&& DEBIAN_FRONTEND=noninteractive apt-get install -y git \
5+
&& DEBIAN_FRONTEND=noninteractive apt-get install -y ruby ruby-dev rubygems build-essential rpm \
6+
&& gem install fpm \
7+
&& fpm --version
8+
9+
CMD /usr/local/bin/fpm
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
ARG VERSION
2+
3+
FROM apache/apisix:${VERSION} AS APISIX
4+
FROM api7/fpm
5+
6+
ARG ITERATION
7+
ARG PACKAGE_VERSION
8+
9+
ENV ITERATION=${ITERATION}
10+
ENV PACKAGE_VERSION=${PACKAGE_VERSION}
11+
12+
COPY --from=APISIX /tmp/build/output /tmp/build/output
13+
COPY package-apisix.sh /package-apisix.sh
14+
COPY usr /usr
15+
16+
RUN /package-apisix.sh
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
ARG VERSION
2+
3+
FROM apache/apisix-dashboard:${VERSION} AS APISIX
4+
FROM api7/fpm
5+
6+
ARG ITERATION
7+
ARG PACKAGE_VERSION
8+
9+
ENV ITERATION=${ITERATION}
10+
ENV PACKAGE_VERSION=${PACKAGE_VERSION}
11+
12+
COPY --from=APISIX /tmp/build/output /tmp/build/output
13+
COPY package-apisix-dashboard.sh /package-apisix-dashboard.sh
14+
15+
RUN /package-apisix-dashboard.sh
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
ARG VERSION
2+
3+
FROM apache/apisix-openresty:${VERSION} AS APISIX
4+
FROM api7/fpm
5+
6+
ARG ITERATION
7+
ARG PACKAGE_VERSION
8+
9+
ENV ITERATION=${ITERATION}
10+
ENV PACKAGE_VERSION=${PACKAGE_VERSION}
11+
12+
COPY --from=APISIX /usr/local/openresty /tmp/build/output/openresty
13+
COPY package-apisix-openresty.sh /package-apisix-openresty.sh
14+
COPY post-install-apisix-openresty.sh /post-install-apisix-openresty.sh
15+
COPY usr /usr
16+
17+
RUN /package-apisix-openresty.sh

package-apisix-dashboard.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
set -x
4+
fpm -f -s dir -t rpm \
5+
-n apisix-dashboard \
6+
-a "$(uname -i)" \
7+
-v "$PACKAGE_VERSION" \
8+
--iteration "$ITERATION" \
9+
--description 'Apache APISIX Dashboard is designed to make it as easy as possible for users to operate Apache APISIX through a frontend interface.' \
10+
--license "ASL 2.0" \
11+
-C /tmp/build/output/apisix/dashboard/ \
12+
-p /output \
13+
--url 'https://github.com/apache/apisix-dashboard'

package-apisix-openresty.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
set -x
4+
mkdir /output
5+
fpm -f -s dir -t rpm \
6+
-n apisix-openresty \
7+
-a "$(uname -i)" \
8+
-v "$PACKAGE_VERSION" \
9+
--iteration "$ITERATION" \
10+
-x openresty/zlib \
11+
-x openresty/openssl111 \
12+
-x openresty/pcre \
13+
-d 'openresty-zlib >= 1.2.11-3' \
14+
-d 'openresty-openssl111 >= 1.1.1h-1' \
15+
-d 'openresty-pcre >= 8.44-1' \
16+
--post-install post-install-apisix-openresty.sh \
17+
--description "APISIX's OpenResty distribution." \
18+
--license "ASL 2.0" \
19+
-C /tmp/build/output \
20+
-p /output \
21+
--url 'http://apisix.apache.org/' \
22+
--conflicts openresty \
23+
--config-files usr/lib/systemd/system/openresty.service \
24+
--prefix=/usr/local

package-apisix.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
set -x
4+
mkdir /output
5+
fpm -f -s dir -t rpm \
6+
-n apisix \
7+
-a "$(uname -i)" \
8+
-v "$PACKAGE_VERSION" \
9+
--iteration "$ITERATION" \
10+
-d 'openresty >= 1.17.8.2' \
11+
--description 'Apache APISIX is a distributed gateway for APIs and Microservices, focused on high performance and reliability.' \
12+
--license "ASL 2.0" \
13+
-C /tmp/build/output/apisix \
14+
-p /output \
15+
--url 'http://apisix.apache.org/' \
16+
--config-files usr/lib/systemd/system/apisix.service

0 commit comments

Comments
 (0)