Skip to content

Commit 504cf4b

Browse files
authored
feat: improve apisix-base build (#152)
1 parent 15596cd commit 504cf4b

File tree

2 files changed

+40
-27
lines changed

2 files changed

+40
-27
lines changed

.github/workflows/push-apisix-base-image.yml

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,22 @@ jobs:
2727
run: |
2828
echo "##[set-output name=version;]$(echo ${GITHUB_REF#refs/tags/})"
2929
30+
- name: Set up QEMU
31+
uses: docker/setup-qemu-action@v1
32+
33+
- name: Set up Docker Buildx
34+
uses: docker/setup-buildx-action@v1
35+
3036
- name: Login to Docker Hub
3137
if: ${{ startsWith(steps.tag_type.outputs.version, 'apisix-base/') }}
3238
uses: docker/login-action@v1
3339
with:
3440
username: ${{ secrets.DOCKERHUB_USERNAME }}
3541
password: ${{ secrets.DOCKERHUB_TOKEN }}
3642

37-
- name: Build Docker Image
38-
if: ${{ startsWith(steps.tag_type.outputs.version, 'apisix-base/') }}
39-
run: |
40-
docker build -t api7/apisix-base:${{ steps.tag_env.outputs.version }} \
41-
--build-arg VERSION=${{ steps.tag_env.outputs.version }} -f ./dockerfiles/Dockerfile.apisix-base.apk .
42-
43-
- name: Push docker image
43+
- name: Build and Push Docker Image
4444
if: ${{ startsWith(steps.tag_type.outputs.version, 'apisix-base/') }}
4545
run: |
46-
docker push api7/apisix-base:${{ steps.tag_env.outputs.version }}
46+
docker buildx build -t api7/apisix-base:${{ steps.tag_env.outputs.version }} --push \
47+
--build-arg VERSION=${{ steps.tag_env.outputs.version }} --platform linux/amd64,linux/arm64 \
48+
-f ./dockerfiles/Dockerfile.apisix-base.apk .

dockerfiles/Dockerfile.apisix-base.apk

Lines changed: 30 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
ARG IMAGE_BASE="alpine"
2-
ARG IMAGE_TAG="3.12"
2+
ARG IMAGE_TAG="3.14"
33

4-
FROM ${IMAGE_BASE}:${IMAGE_TAG}
4+
FROM ${IMAGE_BASE}:${IMAGE_TAG} as build
55

6-
COPY ./utils/build-common.sh /tmp/build-common.sh
7-
COPY ./utils/install-common.sh /tmp/install-common.sh
8-
COPY build-apisix-base.sh /tmp/build-apisix-base.sh
9-
COPY ./utils/determine-dist.sh /tmp/determine-dist.sh
6+
COPY ./utils/build-common.sh \
7+
./utils/install-common.sh \
8+
build-apisix-base.sh \
9+
./utils/determine-dist.sh \
10+
/tmp/
1011

1112

1213
ARG RESTY_OPENSSL_VERSION="1.1.1g"
@@ -28,36 +29,30 @@ LABEL resty_eval_pre_configure="${RESTY_EVAL_PRE_CONFIGURE}"
2829

2930
ENV PATH=$PATH:/usr/local/openresty/luajit/bin:/usr/local/openresty/nginx/sbin:/usr/local/openresty/bin
3031

31-
RUN apk add --no-cache --virtual .build-deps \
32+
RUN apk add --no-cache \
3233
build-base \
3334
coreutils \
3435
curl \
36+
gd \
3537
gd-dev \
38+
geoip \
3639
geoip-dev \
40+
libxslt \
3741
libxslt-dev \
3842
linux-headers \
3943
make \
4044
perl-dev \
4145
readline-dev \
46+
zlib \
4247
zlib-dev \
4348
unzip \
44-
&& apk add --no-cache \
45-
gd \
46-
geoip \
47-
libxslt \
48-
zlib \
49-
bash \
5049
git \
5150
sudo \
52-
curl \
53-
build-base \
51+
bash \
5452
libstdc++
5553

5654
# install latest Rust to build wasmtime
57-
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs > rust-installer.sh \
58-
&& chmod +x ./rust-installer.sh \
59-
&& ./rust-installer.sh -y \
60-
&& rm rust-installer.sh
55+
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
6156

6257
RUN cd /tmp \
6358
&& if [ -n "${RESTY_EVAL_PRE_CONFIGURE}" ]; then eval $(echo ${RESTY_EVAL_PRE_CONFIGURE}); fi \
@@ -98,4 +93,20 @@ RUN cd /tmp \
9893
&& ./install-common.sh install_luarocks \
9994
&& /usr/local/openresty/bin/openresty -V
10095

96+
97+
FROM ${IMAGE_BASE}:${IMAGE_TAG} as prod
98+
99+
COPY --from=build /usr/local/openresty /usr/local/openresty
100+
101+
RUN apk add --no-cache \
102+
gd \
103+
geoip \
104+
libxslt \
105+
zlib \
106+
libstdc++ \
107+
&& rm /usr/local/openresty/wasmtime-c-api/lib/libwasmtime.a \
108+
&& rm /usr/local/openresty/wasmtime-c-api/lib/libwasmtime.d
109+
110+
ENV PATH=$PATH:/usr/local/openresty/luajit/bin:/usr/local/openresty/nginx/sbin:/usr/local/openresty/bin
111+
101112
CMD /bin/sh

0 commit comments

Comments
 (0)