feat(01-03): create Dockerfile for containerization
- Add multi-stage Dockerfile (JDK build, JRE runtime) - Use Eclipse Temurin 21 base images - Configure health check on /health endpoint - Add .dockerignore for efficient builds - Environment variables for config override
This commit is contained in:
30
.dockerignore
Normal file
30
.dockerignore
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
# Build artifacts
|
||||||
|
out/
|
||||||
|
.bsp/
|
||||||
|
|
||||||
|
# Git
|
||||||
|
.git/
|
||||||
|
.gitignore
|
||||||
|
|
||||||
|
# IDE
|
||||||
|
.idea/
|
||||||
|
*.iml
|
||||||
|
.vscode/
|
||||||
|
|
||||||
|
# Reference implementation
|
||||||
|
golem15-wintercms-starter/
|
||||||
|
|
||||||
|
# Documentation
|
||||||
|
*.md
|
||||||
|
!README.md
|
||||||
|
|
||||||
|
# Planning files
|
||||||
|
.planning/
|
||||||
|
|
||||||
|
# Infra (not needed in app container)
|
||||||
|
infra/
|
||||||
|
|
||||||
|
# Local environment
|
||||||
|
.env
|
||||||
|
.env.local
|
||||||
|
*.log
|
||||||
51
Dockerfile
Normal file
51
Dockerfile
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
# SummerCMS Docker Build
|
||||||
|
# Multi-stage build: JDK for building, JRE for runtime
|
||||||
|
|
||||||
|
# Stage 1: Build
|
||||||
|
FROM eclipse-temurin:21-jdk AS builder
|
||||||
|
|
||||||
|
# Install Mill build tool
|
||||||
|
# Using ./mill launcher pattern - download specific version
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Copy mill launcher and version first for caching
|
||||||
|
COPY .mill-version ./
|
||||||
|
COPY mill ./
|
||||||
|
|
||||||
|
# Copy build files
|
||||||
|
COPY build.mill ./
|
||||||
|
|
||||||
|
# Copy source code
|
||||||
|
COPY summercms ./summercms
|
||||||
|
|
||||||
|
# Build fat JAR using local mill launcher
|
||||||
|
RUN chmod +x ./mill && ./mill summercms.assembly
|
||||||
|
|
||||||
|
# Stage 2: Runtime
|
||||||
|
FROM eclipse-temurin:21-jre
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Install curl for health check
|
||||||
|
RUN apt-get update && \
|
||||||
|
apt-get install -y --no-install-recommends curl && \
|
||||||
|
rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
# Copy the fat JAR from builder
|
||||||
|
COPY --from=builder /app/out/summercms/assembly.dest/out.jar /app/summercms.jar
|
||||||
|
|
||||||
|
# Health check using /health endpoint
|
||||||
|
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
|
||||||
|
CMD curl -f http://localhost:8080/health || exit 1
|
||||||
|
|
||||||
|
EXPOSE 8080
|
||||||
|
|
||||||
|
# Environment variables for configuration override
|
||||||
|
# These can be overridden at runtime with -e flags
|
||||||
|
ENV DB_HOST=localhost
|
||||||
|
ENV DB_PORT=5432
|
||||||
|
ENV DB_NAME=summercms
|
||||||
|
ENV DB_USER=summercms
|
||||||
|
|
||||||
|
# Run the application
|
||||||
|
ENTRYPOINT ["java", "-jar", "/app/summercms.jar"]
|
||||||
Reference in New Issue
Block a user