forked from OctopusSamples/RandomQuotes-Java
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Dockerfile
30 lines (24 loc) · 831 Bytes
/
Dockerfile
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
ARG VERSION=0.0.1
FROM maven:3.6.3-jdk-8 AS build-env
WORKDIR /app
# Copy pom and get dependencies as seperate layers
COPY pom.xml ./
RUN mvn dependency:resolve
RUN mvn dependency:tree --no-transfer-progress
# Copy everything else
COPY . ./
# Update the package version
RUN mvn versions:set -DnewVersion=$VERSION
# Now build
RUN mvn package -DfinalName=app
# Build runtime image
FROM openjdk:8-jre-alpine
EXPOSE 80
WORKDIR /app
COPY --from=build-env /app/target/app.jar ./app.jar
# Use an external config file
COPY src/main/resources/docker-application.yml /app/docker-application.yml
COPY src/main/resources/postgres-application.yml /app/postgres-application.yml
ENV SPRING_CONFIG_NAME=docker-application
# The environment variable used by spring to reference the external file
CMD ["/usr/bin/java", "-jar", "/app/app.jar"]