Skip to content

Commit 0e70c70

Browse files
authored
fix: use debian slim as base image (#209)
* fix: use debain slim as base image * fix CI * reducing the size of the build product * fix typo * reduce * reduce * reduce * reduce * reduce * reduce * reduce * reduce * reduce * reduce * feat: use debian as base image and reduce images size Signed-off-by: tzssangglass <[email protected]> * fix COPY Signed-off-by: tzssangglass <[email protected]> * rm ENV Signed-off-by: tzssangglass <[email protected]> * fix COPY Signed-off-by: tzssangglass <[email protected]>
1 parent 812e3aa commit 0e70c70

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

dockerfiles/Dockerfile.apisix-base.deb

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
ARG IMAGE_BASE="ubuntu"
2-
ARG IMAGE_TAG="20.04"
1+
ARG IMAGE_BASE="debian"
2+
ARG IMAGE_TAG="bullseye-slim"
33

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

66
COPY ./utils/build-common.sh /tmp/build-common.sh
77
COPY build-apisix-base.sh /tmp/build-apisix-base.sh
@@ -22,3 +22,8 @@ ENV build_latest=${BUILD_LATEST:-}
2222
RUN ./build-common.sh build_apisix_base_deb ${build_latest} \
2323
# determine dist and write it into /tmp/dist file
2424
&& /tmp/determine-dist.sh
25+
26+
FROM ${IMAGE_BASE}:${IMAGE_TAG} as prod
27+
28+
COPY --from=build /usr/local /usr/local
29+
COPY --from=build /tmp/dist /tmp/dist

utils/build-common.sh

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,19 @@ build_apisix_base_deb() {
3939
DEBIAN_FRONTEND=noninteractive apt-get install -y sudo git libreadline-dev lsb-release libssl-dev perl build-essential
4040
DEBIAN_FRONTEND=noninteractive apt-get -y install --no-install-recommends wget gnupg ca-certificates
4141
wget -O - https://openresty.org/package/pubkey.gpg | apt-key add -
42-
echo "deb http://openresty.org/package/${arch_path}ubuntu $(lsb_release -sc) main" | tee /etc/apt/sources.list.d/openresty.list
42+
43+
if [[ $IMAGE_BASE == "ubuntu" ]]; then
44+
echo "deb http://openresty.org/package/${arch_path}ubuntu $(lsb_release -sc) main" | tee /etc/apt/sources.list.d/openresty.list
45+
fi
46+
47+
if [[ $IMAGE_BASE == "debian" ]]; then
48+
echo "deb http://openresty.org/package/${arch_path}debian $(lsb_release -sc) openresty" | tee /etc/apt/sources.list.d/openresty.list
49+
fi
50+
4351
DEBIAN_FRONTEND=noninteractive apt-get update
4452
DEBIAN_FRONTEND=noninteractive apt-get install -y openresty-openssl111-dev openresty-pcre-dev openresty-zlib-dev
4553

4654
export_openresty_variables
47-
4855
# fix OR_PREFIX
4956
if [[ $build_latest == "latest" ]]; then
5057
unset OR_PREFIX

0 commit comments

Comments
 (0)