This repository was archived by the owner on Aug 18, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
35 lines (25 loc) · 1.3 KB
/
Dockerfile
File metadata and controls
35 lines (25 loc) · 1.3 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
#This is a two-stage build image for a java project.
#The actual build step happens in the maven container, and the final jar is
#deployed to a more lightweight container. Maven should not download all the
#dependencies if pom.xml is not modified. Modifying only the source code should
#trigger only the compile step
#The build container
FROM maven:3.5.3-jdk-8-slim as BUILD
RUN mkdir -p /usr/src/app
#Copy pom.xml file and download dependencies. This stage will be cached if the pom.xml file is not changed
COPY pom.xml /usr/src/app
RUN mvn -f /usr/src/app/pom.xml dependency:resolve-plugins dependency:resolve clean package
#Run tests
RUN mvn -f /usr/src/app/pom.xml test
#Build the project
COPY src /usr/src/app/src
RUN mvn -f /usr/src/app/pom.xml clean package
#The container that actually runs our application.
#TODO: switch to Alpine when it becomes available
FROM openjdk:8-jre-slim
#Install curl for health check
RUN apt-get update && apt-get install -y --no-install-recommends curl
#This container can access the build artifacts inside the BUILD container.
#Everything that is not copied is discarded
COPY --from=BUILD /usr/src/app/target/transitdata-rail-alert-source-jar-with-dependencies.jar /usr/app/transitdata-rail-alert-source.jar
ENTRYPOINT ["java", "-jar", "/usr/app/transitdata-rail-alert-source.jar"]