forked from iemafzalhassan/retail-store-sample-app
-
Notifications
You must be signed in to change notification settings - Fork 552
Expand file tree
/
Copy pathDockerfile
More file actions
70 lines (53 loc) · 1.57 KB
/
Dockerfile
File metadata and controls
70 lines (53 loc) · 1.57 KB
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# Build Stage
FROM public.ecr.aws/amazonlinux/amazonlinux:2023 AS build-env
# We tell DNF not to install Recommends and Suggests packages, keeping our
# installed set of packages as minimal as possible.
RUN dnf --setopt=install_weak_deps=False install -q -y \
maven \
java-21-amazon-corretto-headless \
which \
tar \
gzip \
&& \
dnf clean all
ARG JAR_PATH
VOLUME /tmp
WORKDIR /
COPY .mvn .mvn
COPY mvnw .
COPY pom.xml .
RUN ./mvnw dependency:go-offline -B -q
COPY ./src ./src
RUN ./mvnw -DskipTests package -q && \
mv /target/orders-0.0.1-SNAPSHOT.jar /app.jar
# Package Stage
FROM public.ecr.aws/amazonlinux/amazonlinux:2023
# We tell DNF not to install Recommends and Suggests packages, which are
# weak dependencies in DNF terminology, thus keeping our installed set of
# packages as minimal as possible.
RUN dnf --setopt=install_weak_deps=False install -q -y \
java-21-amazon-corretto-headless \
shadow-utils \
&& \
dnf clean all
# use curl-full to use "telnet://" scheme
# https://docs.aws.amazon.com/linux/al2023/ug/curl-minimal.html
RUN dnf -q -y swap libcurl-minimal libcurl-full \
&& dnf -q -y swap curl-minimal curl-full
ENV APPUSER=appuser
ENV APPUID=1000
ENV APPGID=1000
RUN useradd \
--home "/app" \
--create-home \
--user-group \
--uid "$APPUID" \
"$APPUSER"
ENV JAVA_TOOL_OPTIONS=
ENV SPRING_PROFILES_ACTIVE=prod
WORKDIR /app
USER appuser
# COPY ./ATTRIBUTION.md ./LICENSES.md
COPY --chown=appuser:appuser --from=build-env /app.jar .
EXPOSE 8080
ENTRYPOINT ["sh", "-c", "java $JAVA_OPTS -jar /app/app.jar"]