-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathContainerfile
42 lines (31 loc) · 1.08 KB
/
Containerfile
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
FROM amazoncorretto:23-alpine as corretto-jdk
LABEL org.opencontainers.image.authors="tero.paloheimo@iki.fi"
# Required for strip-debug to work
RUN apk add --no-cache binutils
# Build small JRE image
RUN $JAVA_HOME/bin/jlink \
--verbose \
--add-modules ALL-MODULE-PATH \
--strip-debug \
--no-man-pages \
--no-header-files \
--output /customjre
# Main app image
FROM alpine:latest
ENV JAVA_HOME=/jre
ENV PATH="${JAVA_HOME}/bin:${PATH}"
COPY --from=corretto-jdk /customjre ${JAVA_HOME}
RUN apk update && apk upgrade
RUN apk add --no-cache dumb-init
# Add user to run the app
ARG APPLICATION_USER=appuser
RUN adduser --no-create-home -u 1000 -D ${APPLICATION_USER}
RUN mkdir /app && chown -R ${APPLICATION_USER} /app
USER ${APPLICATION_USER}
COPY --chown=${APPLICATION_USER}:${APPLICATION_USER} \
./target/env-logger.jar /app/env-logger.jar
COPY --chown=${APPLICATION_USER}:${APPLICATION_USER} \
./resources/prod/config.edn /etc/config.edn
WORKDIR /app
EXPOSE 8080
ENTRYPOINT ["dumb-init", "/jre/bin/java", "-Dconfig=/etc/config.edn", "-jar", "/app/env-logger.jar"]