| # ============================================================ | |
| # Stage 1: Build / Prepare Executable Fat JAR | |
| # ============================================================ | |
| FROM maven:3.9-eclipse-temurin-17 AS builder | |
| WORKDIR /app | |
| # Copy pom.xml, source code, and target directory | |
| COPY pom.xml . | |
| COPY src ./src | |
| COPY target ./target | |
| # If pre-compiled target JAR exists (built using host ~/.m2 cache), reuse instantly! | |
| RUN if [ -f target/*.jar ]; then \ | |
| echo "--> Using pre-compiled JAR file built with host ~/.m2 cache!"; \ | |
| else \ | |
| mvn clean package -DskipTests -B -T 4C; \ | |
| fi | |
| # ============================================================ | |
| # Stage 2: Minimal JRE Runtime Image | |
| # ============================================================ | |
| FROM eclipse-temurin:17-jre-jammy AS runtime | |
| # Install curl for container health checks | |
| RUN apt-get update && apt-get install -y curl && rm -rf /var/lib/apt/lists/* | |
| # Security: Run as non-root user | |
| RUN groupadd --system appgroup \ | |
| && useradd --system --gid appgroup --home /app --no-create-home appuser | |
| WORKDIR /app | |
| # Copy compiled FAT JAR from builder stage | |
| COPY --from=builder /app/target/*.jar app.jar | |
| # Persistent directories | |
| RUN mkdir -p /app/uploads /app/data /app/logs \ | |
| && chown -R appuser:appgroup /app | |
| USER appuser | |
| # 9092 = REST API, 9093 = WebSocket | |
| EXPOSE 9092 9093 | |
| # JVM flags tuned for container execution | |
| ENV JAVA_OPTS="-XX:+UseContainerSupport \ | |
| -XX:MaxRAMPercentage=75.0 \ | |
| -XX:InitialRAMPercentage=50.0 \ | |
| -Djava.security.egd=file:/dev/./urandom" | |
| # Container health check | |
| HEALTHCHECK --interval=30s --timeout=10s --start-period=90s --retries=5 \ | |
| CMD curl -f http://localhost:9092/actuator/health || exit 1 | |
| ENTRYPOINT ["sh", "-c", "java $JAVA_OPTS -jar /app/app.jar"] | |
Xet Storage Details
- Size:
- 1.8 kB
- Xet hash:
- 5a64b5e42069bf4ba57926c169a5240ad0139d3bbfaca462ba4477fa2d2ee933
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.