[SIS-xxx] reducing size of bot image

This commit is contained in:
Sheldan
2025-02-04 21:34:05 +01:00
parent 80a56f4426
commit 71aaa31fa1

View File

@@ -1,8 +1,32 @@
FROM amazoncorretto:17.0.8-alpine3.18
MAINTAINER Sheldan
VOLUME /tmp
ADD config/* /config/
ADD wrapper/*.sh /
# https://careers.wolt.com/en/blog/tech/how-to-reduce-jvm-docker-image-size
FROM amazoncorretto:17.0.14-alpine3.20 AS corretto-jdk
RUN apk add --no-cache binutils
RUN $JAVA_HOME/bin/jlink \
--verbose \
--add-modules ALL-MODULE-PATH \
--strip-debug \
--no-man-pages \
--no-header-files \
--compress=2 \
--output /customjre
FROM alpine:3.21
ENV JAVA_HOME=/jre
ENV PATH="${JAVA_HOME}/bin:${PATH}"
COPY --from=corretto-jdk /customjre $JAVA_HOME
ARG APPLICATION_USER=appuser
RUN adduser --no-create-home -u 1000 -D $APPLICATION_USER
RUN mkdir /app && chown -R $APPLICATION_USER /app
COPY --chown=1000:1000 config/* /config/
COPY --chown=1000:1000 wrapper/*.sh /
RUN chmod +x /start.sh
ADD bot/app.jar /app.jar
COPY --chown=1000:1000 bot/app.jar /app.jar
CMD ["/start.sh"]