From 42b42c69f842fa2f0255507fbf17056cf3dcb14d Mon Sep 17 00:00:00 2001 From: Maciej Urbanski Date: Sat, 25 Nov 2023 11:02:08 +0100 Subject: [PATCH 1/2] remove b2.tar from final docker image --- Dockerfile.template | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile.template b/Dockerfile.template index 99febb0d7..3e77ec986 100644 --- a/Dockerfile.template +++ b/Dockerfile.template @@ -11,8 +11,8 @@ LABEL build-date-iso8601="${build_date}" WORKDIR /root -COPY ${tar_path}/${tar_name} . -RUN ["pip", "install", "${tar_name}[full]"] +RUN --mount=type=bind,source=${tar_path}/${tar_name},target=/tmp/${tar_name} \ + pip install --no-cache-dir /tmp/${tar_name}[full] ENTRYPOINT ["b2"] CMD ["--help"] From 845c1e47e6660db62c4822078c83b0753e517002 Mon Sep 17 00:00:00 2001 From: Maciej Urbanski Date: Sat, 25 Nov 2023 11:02:37 +0100 Subject: [PATCH 2/2] use alpine for official docker image --- Dockerfile.template | 2 +- changelog.d/+docker_optimization.changed.md | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 changelog.d/+docker_optimization.changed.md diff --git a/Dockerfile.template b/Dockerfile.template index 3e77ec986..e6de2bb4d 100644 --- a/Dockerfile.template +++ b/Dockerfile.template @@ -1,4 +1,4 @@ -FROM python:${python_version}-slim as base +FROM python:${python_version}-alpine as base LABEL vendor=${vendor} LABEL name="${name}" diff --git a/changelog.d/+docker_optimization.changed.md b/changelog.d/+docker_optimization.changed.md new file mode 100644 index 000000000..e5dcdabfa --- /dev/null +++ b/changelog.d/+docker_optimization.changed.md @@ -0,0 +1 @@ +Reduce docker image size, from 170MB to 87MB by using alpine and other build optimizations