-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile
53 lines (40 loc) · 1.99 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
ARG OVERWRITE_VERSION
### Stage 1: build UI
FROM node:18 AS BUILD_UI_STAGE
WORKDIR /agr_curation
COPY src/main/cliapp ./cliapp
WORKDIR /agr_curation/cliapp
RUN make all build
### Stage 2: build API (and include UI components)
FROM maven:3.8-eclipse-temurin-17 as BUILD_API_STAGE
ARG OVERWRITE_VERSION
# copy the src code to the container
COPY ./ ./
# Use default properties file
COPY ./src/main/resources/application.properties.defaults ./src/main/resources/application.properties
# copy the UI build artifacts to the container
COPY --from=BUILD_UI_STAGE /agr_curation/cliapp/build/index.html ./src/main/resources/META-INF/resources/index.html
COPY --from=BUILD_UI_STAGE /agr_curation/cliapp/build/favicon.ico ./src/main/resources/META-INF/resources/favicon.ico
COPY --from=BUILD_UI_STAGE /agr_curation/cliapp/build/assets/ ./src/main/resources/META-INF/resources/assets/
COPY --from=BUILD_UI_STAGE /agr_curation/cliapp/build/static/ ./src/main/resources/META-INF/resources/static/
# Optionally overwrite the application version stored in the pom.xml
RUN if [ "${OVERWRITE_VERSION}" != "" ]; then \
mvn versions:set -ntp -DnewVersion=$OVERWRITE_VERSION; \
fi;
# build the api jar
RUN mvn -T 8 clean package -Dquarkus.package.type=uber-jar -ntp
### Stage 3: build final application image
FROM eclipse-temurin:17-jre-alpine
WORKDIR /agr_curation
# copy only the artifacts we need from the first stage and discard the rest
COPY --from=BUILD_API_STAGE /target/agr_curation_api-runner.jar .
# Expose necessary ports
EXPOSE 8080
# Set default env variables for local docker application execution
ENV QUARKUS_DATASOURCE_JDBC_URL jdbc:postgresql://postgres:5432/curation
ENV QUARKUS_DATASOURCE_USERNAME postgres
ENV QUARKUS_DATASOURCE_PASSWORD postgres
ENV QUARKUS_HIBERNATE_SEARCH_ORM_ELASTICSEARCH_HOSTS opensearch:9200
ENV QUARKUS_HIBERNATE_SEARCH_ORM_ELASTICSEARCH_PROTOCOL http
# Start the application
CMD ["java", "-XX:InitialRAMPercentage=50", "-XX:MaxRAMPercentage=90", "-jar", "agr_curation_api-runner.jar"]