diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..5f2f874 --- /dev/null +++ b/.dockerignore @@ -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 diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..a99dd14 --- /dev/null +++ b/Dockerfile @@ -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"]