-
Notifications
You must be signed in to change notification settings - Fork 19
/
Dockerfile-slimmed
50 lines (39 loc) · 1.63 KB
/
Dockerfile-slimmed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
FROM azul/zulu-openjdk-alpine:17 AS builder
LABEL maintainer="dlmcpaul@gmail.com"
ENV JAVA_MINIMAL=/opt/jre
# Generate a minimal java runtime using the latest azul/zulu-openjdk-alpine
ARG JAR_FILE
COPY ${JAR_FILE} /app.jar
# Explode Uber jar into lib jars and classes
RUN "$JAVA_HOME/bin/jar" -xf app.jar && \
MODULES=$("$JAVA_HOME/bin/jdeps" --ignore-missing-deps -q -recursive --multi-release 17 --print-module-deps --class-path "./BOOT-INF/lib/*" /app.jar) \
&& echo modules identified = "$MODULES" \
&& "$JAVA_HOME/bin/jlink" \
--verbose \
--add-modules "$MODULES" \
--compress 2 \
--strip-java-debug-attributes \
--no-header-files \
--no-man-pages \
--output "$JAVA_MINIMAL"
# Start with fresh copy of alpine linux
FROM alpine:3
LABEL maintainer="dlmcpaul@gmail.com"
# copy our minimal runtime
ENV JAVA_MINIMAL=/opt/jre
ENV PATH="$PATH:$JAVA_MINIMAL/bin"
COPY --from=builder "$JAVA_MINIMAL" "$JAVA_MINIMAL"
# copy our application
COPY --from=builder "./BOOT-INF/lib" /app/lib
COPY --from=builder "./META-INF" /app/META-INF
COPY --from=builder "./BOOT-INF/classes" /app
# Override these for your timezone and language
ENV TZ="Australia/Sydney" \
LANG="en_AU.UTF-8"
ENV SPRING_DATASOURCE_URL=jdbc:h2:/internal_db/solar_stats_db_v2
RUN mkdir "/properties" && \
touch "/properties/application.properties"
# expose the internal endpoint
EXPOSE 8080
VOLUME /internal_db /properties
ENTRYPOINT ["java", "-cp", "app:app/lib/*", "-Djava.security.egd=file:/dev/./urandom", "-Dspring.jmx.enabled=false", "com.hz.EnphaseCollectorApplication", "--spring.config.additional-location=file:/properties/application.properties"]