-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathDockerfile
More file actions
75 lines (59 loc) · 2.67 KB
/
Dockerfile
File metadata and controls
75 lines (59 loc) · 2.67 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
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
68
69
70
71
72
73
74
75
# Multi-stage Dockerfile for TreeBASE web application
# Stage 1: Build the application
FROM maven:3.9-eclipse-temurin-17 AS builder
WORKDIR /build
# Copy Maven project files
COPY pom.xml .
COPY treebase-core/pom.xml treebase-core/
COPY treebase-web/pom.xml treebase-web/
COPY oai-pmh_data_provider/pom.xml oai-pmh_data_provider/
COPY oai-pmh_data_provider/data_provider_web/pom.xml oai-pmh_data_provider/data_provider_web/
# Download dependencies (cached layer)
RUN mvn dependency:go-offline -B || true
# Copy source code
COPY treebase-core/src treebase-core/src
COPY treebase-core/lib treebase-core/lib
COPY treebase-web/src treebase-web/src
COPY treebase-web/lib treebase-web/lib
COPY oai-pmh_data_provider oai-pmh_data_provider
# Copy configuration examples and create actual config files
COPY treebase-core/src/main/resources/jdbc.properties.example treebase-core/src/main/resources/jdbc.properties
COPY treebase-web/src/main/webapp/META-INF/context.xml.example treebase-web/src/main/webapp/META-INF/context.xml
# Build the WAR file
RUN mvn clean package -Dmaven.test.skip=true -B
# Stage 2: Runtime with Tomcat
FROM tomcat:9-jdk17
# Install PostgreSQL client utilities (optional, for debugging)
RUN apt-get update && \
apt-get install -y postgresql-client && \
rm -rf /var/lib/apt/lists/*
# Remove default Tomcat webapps
RUN rm -rf /usr/local/tomcat/webapps/*
# Copy the built WAR file from builder stage
COPY --from=builder /build/treebase-web/target/treebase-web.war /usr/local/tomcat/webapps/treebase-web.war
# Download and install PostgreSQL JDBC driver
RUN curl -o /usr/local/tomcat/lib/postgresql.jar \
https://jdbc.postgresql.org/download/postgresql-42.7.7.jar
# Create a directory for Mesquite and copy the headless Mesquite library
# The treebase-core/lib folder contains the headless Mesquite distribution with:
# - mesquite/ - Mesquite core classes
# - headless/ - Headless AWT implementation
# - com/apple/ - Apple API stubs (required by Mesquite even on non-Mac platforms)
# - Other supporting libraries
COPY --from=builder /build/treebase-core/lib /usr/local/mesquite
# Set environment variables for Tomcat
# Java 17 compatibility flags based on GitHub Actions workflow
ENV CATALINA_OPTS="-Djava.awt.headless=true \
-Xmx512m \
-XX:+UseG1GC \
-Dorg.apache.el.parser.SKIP_IDENTIFIER_CHECK=true \
--add-opens java.base/java.lang=ALL-UNNAMED \
--add-opens java.base/java.util=ALL-UNNAMED \
--add-opens java.base/java.lang.reflect=ALL-UNNAMED"
# Expose Tomcat port
EXPOSE 8080
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
CMD curl -f http://localhost:8080/treebase-web/ || exit 1
# Start Tomcat
CMD ["catalina.sh", "run"]