-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile-ubi
28 lines (22 loc) · 947 Bytes
/
Dockerfile-ubi
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
# https://github.com/GoogleContainerTools/distroless/blob/master/examples/java/Dockerfile
FROM adoptopenjdk:8-jdk-hotspot AS build-env
ARG MAVEN_VERSION=3.6.3
ARG USER_HOME_DIR="/root"
ARG BASE_URL=https://apache.osuosl.org/maven/maven-3/${MAVEN_VERSION}/binaries
RUN mkdir -p /app /usr/share/maven /usr/share/maven/ref \
&& curl -fsSL -o /tmp/apache-maven.tar.gz ${BASE_URL}/apache-maven-${MAVEN_VERSION}-bin.tar.gz \
&& tar -xzf /tmp/apache-maven.tar.gz -C /usr/share/maven --strip-components=1 \
&& rm -f /tmp/apache-maven.tar.gz \
&& ln -s /usr/share/maven/bin/mvn /usr/bin/mvn
ENV MAVEN_HOME /usr/share/maven
ENV MAVEN_CONFIG "$USER_HOME_DIR/.m2"
ADD ./sample-app/ /app
WORKDIR /app
RUN mvn compile
RUN jar cfe main.jar com.redhat.rahmed.demo.Main -C target/classes .
RUN jar tf main.jar
RUN pwd
FROM registry.redhat.io/ubi8/openjdk-8
COPY --from=build-env /app/main.jar /app/main.jar
WORKDIR /app
CMD ["java", "-jar", "main.jar"]