forked from moqui/moqui-framework
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
86 lines (65 loc) · 2.83 KB
/
Dockerfile
File metadata and controls
86 lines (65 loc) · 2.83 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
76
77
78
79
80
81
82
83
84
85
86
# Moqui Framework Production Dockerfile
# Multi-stage build for optimized image size
# Uses Java 21 LTS with Eclipse Temurin
# ============================================================================
# Build Stage - Compiles the application and creates the WAR
# ============================================================================
FROM eclipse-temurin:21-jdk-alpine AS builder
# Install build dependencies
RUN apk add --no-cache bash git
WORKDIR /build
# Copy Gradle wrapper and build files first (for better caching)
COPY gradlew gradlew.bat gradle.properties settings.gradle build.gradle ./
COPY gradle/ gradle/
# Copy source code
COPY framework/ framework/
COPY runtime/ runtime/
# Build the WAR file with runtime included
RUN chmod +x gradlew && \
./gradlew --no-daemon addRuntime && \
# Unzip the WAR for faster startup
mkdir -p /app && \
cd /app && \
unzip /build/moqui-plus-runtime.war
# ============================================================================
# Runtime Stage - Minimal production image
# ============================================================================
FROM eclipse-temurin:21-jre-alpine
LABEL maintainer="Moqui Framework <moqui@googlegroups.com>" \
version="3.0.0" \
description="Moqui Framework - Enterprise Application Development" \
org.opencontainers.image.source="https://github.com/moqui/moqui-framework"
# Install runtime dependencies
RUN apk add --no-cache \
curl \
tzdata \
&& rm -rf /var/cache/apk/*
# Create non-root user for security
RUN addgroup -g 1000 -S moqui && \
adduser -u 1000 -S moqui -G moqui
WORKDIR /opt/moqui
# Copy application from builder
COPY --from=builder --chown=moqui:moqui /app/ .
# Create necessary directories with correct permissions
RUN mkdir -p runtime/log runtime/txlog runtime/sessions runtime/db && \
chown -R moqui:moqui runtime/
# Switch to non-root user
USER moqui
# Configuration volumes
VOLUME ["/opt/moqui/runtime/conf", "/opt/moqui/runtime/lib", "/opt/moqui/runtime/classes", "/opt/moqui/runtime/ecomponent"]
# Data persistence volumes
VOLUME ["/opt/moqui/runtime/log", "/opt/moqui/runtime/txlog", "/opt/moqui/runtime/sessions", "/opt/moqui/runtime/db"]
# Main application port
EXPOSE 8080
# Environment variables with sensible defaults
ENV JAVA_TOOL_OPTIONS="-Xms512m -Xmx1024m -XX:+UseG1GC -XX:MaxGCPauseMillis=100" \
MOQUI_RUNTIME_CONF="conf/MoquiProductionConf.xml" \
TZ="UTC"
# Health check using the /health/ready endpoint
# start-period allows for slow startup (loading data, etc.)
HEALTHCHECK --interval=30s --timeout=10s --start-period=120s --retries=3 \
CMD curl -f http://localhost:8080/health/ready || exit 1
# Start Moqui using the MoquiStart class
ENTRYPOINT ["java", "-cp", ".", "MoquiStart"]
# Default command (can be overridden)
CMD ["port=8080", "conf=conf/MoquiProductionConf.xml"]