-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile
24 lines (22 loc) · 1.01 KB
/
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
# == Stage 1: Build and package the application
FROM maven:3.3-jdk-8 AS builder
WORKDIR /usr/src/work
# Workaround for sql server jdbc driver not in maven. See https://coderanch.com/t/630637/build-tools/Maven-dependency-sql-jdbc-driver. Fortunately this layer will be cached.
COPY mssqljdbc mssqljdbc
RUN mvn install:install-file -Dfile=mssqljdbc/sqljdbc42.jar \
-DgroupId=com.microsoft.sqlserver \
-DartifactId=sqljdbc4 \
-Dversion=6.0 -Dmaven.repo.local=/usr/src/repo \
-Dpackaging=jar
# Now copy POM and load dependencies. This will be cached by docker as another reusable layer.
COPY pom.xml .
RUN mvn dependency:go-offline -Dmaven.repo.local=/usr/src/repo
# Finally, copy the rest and call the package goal.
COPY . .
RUN mvn package -Dmaven.repo.local=/usr/src/repo
# == Stage 2: Copy the application into the production image
FROM tomcat:8.5-jre8-alpine
WORKDIR /usr/local/tomcat/webapps
COPY --from=builder /usr/src/work/target/myapi.war .
RUN mv myapi.war ROOT.war && rm -rf ROOT
CMD ["catalina.sh", "run"]