-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.build
More file actions
77 lines (56 loc) · 2.28 KB
/
Dockerfile.build
File metadata and controls
77 lines (56 loc) · 2.28 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
# Multi-stage build Dockerfile for building from source (SPI-474)
# This is the traditional build-from-source Dockerfile for local builds
# The main Dockerfile is optimized for CI with pre-built artifacts
# Stage 1: Build with JDK
FROM eclipse-temurin:21-jdk AS builder
WORKDIR /app
# Install required tools for better caching
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# Copy gradle wrapper and properties first (changes least frequently)
COPY gradlew gradlew
COPY gradle.properties gradle.properties
COPY gradle/ gradle/
# Make gradlew executable
RUN chmod +x gradlew
# Copy only dependency-related files first for better layer caching
COPY settings.gradle.kts settings.gradle.kts
COPY gradle/libs.versions.toml gradle/libs.versions.toml
COPY build.gradle.kts build.gradle.kts
# Download and cache dependencies (this layer will be cached unless dependencies change)
RUN ./gradlew dependencies --no-daemon --build-cache
# Copy configuration files
COPY config/ config/
# Copy source code (changes most frequently, so placed last)
COPY src/ src/
# Build fat JAR with comprehensive caching
RUN ./gradlew buildFatJar --no-daemon --build-cache --configuration-cache
# Stage 2: Runtime image with JRE
FROM eclipse-temurin:21-jre-alpine
# Install required libraries
RUN apk add --no-cache \
ca-certificates \
wget
# Create non-root user
RUN addgroup -g 1000 cycletime && \
adduser -D -u 1000 -G cycletime cycletime
WORKDIR /app
# Copy the JAR file from builder stage
COPY --from=builder --chown=cycletime:cycletime /app/build/libs/cycletime-server.jar /app/cycletime-server.jar
# Create directory for H2 database
RUN mkdir -p /app/data && chown -R cycletime:cycletime /app/data
# Switch to non-root user
USER cycletime
# Environment variables
# Note: DB_CLOSE_DELAY=-1 removed - not needed for file-based H2 databases
ENV DATABASE_URL="jdbc:h2:file:/app/data/cycletime;MODE=PostgreSQL;DATABASE_TO_LOWER=TRUE"
ENV PORT=8080
ENV HOST=0.0.0.0
# Expose MCP server port
EXPOSE 8080
# Health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD wget --no-verbose --tries=1 --spider http://localhost:8080/health || exit 1
# Run the JAR file
ENTRYPOINT ["java", "-jar", "/app/cycletime-server.jar"]