fix(docker): make image smaller (#1523)

* Replace mkdir with WORKDIR

* Remove unnecessary package list

* Remove graalvm removal in the base image

This could speed up local builds since we don't need to download it
every time

* Remove package information

* Remove the downloaded apk

* Add a changelog entry

* Revert WORKDIR changes
This commit is contained in:
KARASZI István 2023-03-21 23:45:25 +01:00 committed by GitHub
parent 57ebb524b0
commit 43e7b4af0b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 10 additions and 4 deletions

View file

@ -7,6 +7,10 @@ A preview of the next release can be installed from
[Babashka](https://github.com/babashka/babashka): Native, fast starting Clojure interpreter for scripting [Babashka](https://github.com/babashka/babashka): Native, fast starting Clojure interpreter for scripting
## Unreleased
- [#1523](https://github.com/babashka/babashka/pull/1523): Reduce the size of the Docker images ([@raszi](https://github.com/raszi))
## 1.3.176 (2023-03-18) ## 1.3.176 (2023-03-18)
- Upgrade http-client to 0.1.8, fixes binary file uploads (which messed up the previous release) - Upgrade http-client to 0.1.8, fixes binary file uploads (which messed up the previous release)

View file

@ -17,8 +17,7 @@ RUN if [ "${TARGETARCH}" = "" ] || [ "${TARGETARCH}" = "amd64" ]; then \
fi && \ fi && \
echo "Installing GraalVM for ${GRAALVM_ARCH}" && \ echo "Installing GraalVM for ${GRAALVM_ARCH}" && \
curl -sLO https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-${GRAALVM_VERSION}/graalvm-ce-java19-linux-${GRAALVM_ARCH}-${GRAALVM_VERSION}.tar.gz && \ curl -sLO https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-${GRAALVM_VERSION}/graalvm-ce-java19-linux-${GRAALVM_ARCH}-${GRAALVM_VERSION}.tar.gz && \
tar -xzf graalvm-ce-java19-linux-${GRAALVM_ARCH}-${GRAALVM_VERSION}.tar.gz && \ tar -xzf graalvm-ce-java19-linux-${GRAALVM_ARCH}-${GRAALVM_VERSION}.tar.gz
rm graalvm-ce-java19-linux-${GRAALVM_ARCH}-${GRAALVM_VERSION}.tar.gz
ARG BABASHKA_XMX="-J-Xmx4500m" ARG BABASHKA_XMX="-J-Xmx4500m"
@ -73,7 +72,9 @@ RUN ./script/compile
FROM ubuntu:latest FROM ubuntu:latest
RUN apt-get update && apt-get install -y curl \ RUN apt-get update && apt-get install -y curl \
&& mkdir -p /usr/local/bin && rm -rf /var/lib/apt/lists/* \
&& mkdir -p /usr/local/bin
COPY --from=BASE /opt/target/metabom.jar /opt/babashka-metabom.jar COPY --from=BASE /opt/target/metabom.jar /opt/babashka-metabom.jar
COPY --from=BASE /opt/bb /usr/local/bin/bb COPY --from=BASE /opt/bb /usr/local/bin/bb
CMD ["bb"] CMD ["bb"]

View file

@ -23,7 +23,7 @@ FROM alpine:3
RUN apk --no-cache add curl ca-certificates tar && \ RUN apk --no-cache add curl ca-certificates tar && \
curl -Ls https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.28-r0/glibc-2.28-r0.apk > /tmp/glibc-2.28-r0.apk && \ curl -Ls https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.28-r0/glibc-2.28-r0.apk > /tmp/glibc-2.28-r0.apk && \
apk add --allow-untrusted --force-overwrite /tmp/glibc-2.28-r0.apk apk add --allow-untrusted --force-overwrite /tmp/glibc-2.28-r0.apk && rm /tmp/glibc-2.28-r0.apk
RUN echo 'hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4' >> /etc/nsswitch.conf RUN echo 'hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4' >> /etc/nsswitch.conf
COPY metabom.jar /opt/babashka-metabom.jar COPY metabom.jar /opt/babashka-metabom.jar

View file

@ -2,6 +2,7 @@ FROM ubuntu:latest
RUN apt-get update \ RUN apt-get update \
&& apt-get install -y curl \ && apt-get install -y curl \
&& rm -rf /var/lib/apt/lists/* \
&& mkdir -p /usr/local/bin && mkdir -p /usr/local/bin
ARG TARGETARCH ARG TARGETARCH