forked from OHDSI/WebAPI
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile
67 lines (52 loc) · 2.27 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
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
FROM maven:3.6-jdk-11 as builder
WORKDIR /code
ARG MAVEN_PROFILE=webapi-docker
ARG MAVEN_PARAMS="" # can use maven options, e.g. -DskipTests=true -DskipUnitTests=true
ARG OPENTELEMETRY_JAVA_AGENT_VERSION=1.17.0
RUN curl -LSsO https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/download/v${OPENTELEMETRY_JAVA_AGENT_VERSION}/opentelemetry-javaagent.jar
# Download dependencies
COPY pom.xml /code/
RUN mkdir .git \
&& mvn package \
-P${MAVEN_PROFILE}
ARG GIT_BRANCH=unknown
ARG GIT_COMMIT_ID_ABBREV=unknown
# Compile code and repackage it
COPY src /code/src
RUN mvn package ${MAVEN_PARAMS} \
-Dgit.branch=${GIT_BRANCH} \
-Dgit.commit.id.abbrev=${GIT_COMMIT_ID_ABBREV} \
-P${MAVEN_PROFILE} \
&& mkdir war \
&& mv target/WebAPI.war war \
&& cd war \
&& jar -xf WebAPI.war \
&& rm WebAPI.war
# OHDSI WebAPI and ATLAS web application running as a Spring Boot application with Java 8
FROM index.docker.io/library/eclipse-temurin:8-jre
MAINTAINER Lee Evans - www.ltscomputingllc.com
# Any Java options to pass along, e.g. memory, garbage collection, etc.
ENV JAVA_OPTS=""
# Additional classpath parameters to pass along. If provided, start with colon ":"
ENV CLASSPATH=""
# Default Java options. The first entry is a fix for when java reads secure random numbers:
# in a containerized system using /dev/random may reduce entropy too much, causing slowdowns.
# https://ruleoftech.com/2016/avoiding-jvm-delays-caused-by-random-number-generation
ENV DEFAULT_JAVA_OPTS="-Djava.security.egd=file:///dev/./urandom"
# set working directory to a fixed WebAPI directory
WORKDIR /var/lib/ohdsi/webapi
COPY --from=builder /code/opentelemetry-javaagent.jar .
# deploy the just built OHDSI WebAPI war file
# copy resources in order of fewest changes to most changes.
# This way, the libraries step is not duplicated if the dependencies
# do not change.
COPY --from=builder /code/war/WEB-INF/lib*/* WEB-INF/lib/
COPY --from=builder /code/war/org org
COPY --from=builder /code/war/WEB-INF/classes WEB-INF/classes
COPY --from=builder /code/war/META-INF META-INF
EXPOSE 8080
USER 101
# Directly run the code as a WAR.
CMD exec java ${DEFAULT_JAVA_OPTS} ${JAVA_OPTS} \
-cp ".:WebAPI.jar:WEB-INF/lib/*.jar${CLASSPATH}" \
org.springframework.boot.loader.WarLauncher