-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.template
More file actions
64 lines (49 loc) · 1.72 KB
/
Dockerfile.template
File metadata and controls
64 lines (49 loc) · 1.72 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
# syntax=docker/dockerfile:1
# Kiket Extension Dockerfile Template - Java SDK
# This template is used by Cloud Build to generate Dockerfiles for extensions
# that declare `sdk: java` in their manifest.
# Build stage
FROM eclipse-temurin:21-jdk-jammy AS builder
WORKDIR /app
# Install build dependencies
RUN apt-get update -qq && \
apt-get install -y --no-install-recommends git curl && \
rm -rf /var/lib/apt/lists/*
# Copy dependency files first for better caching
COPY pom.xml ./
# Download dependencies (uses Maven wrapper if present, otherwise install maven)
RUN if [ -f mvnw ]; then chmod +x mvnw; fi
COPY . .
RUN if [ -f mvnw ]; then \
./mvnw dependency:go-offline -B; \
else \
apt-get update -qq && apt-get install -y --no-install-recommends maven && \
mvn dependency:go-offline -B; \
fi
# Build the application
RUN if [ -f mvnw ]; then \
./mvnw package -DskipTests -B; \
else \
mvn package -DskipTests -B; \
fi
# Runtime stage
FROM eclipse-temurin:21-jre-jammy
WORKDIR /app
# Install curl for health checks
RUN apt-get update -qq && \
apt-get install -y --no-install-recommends curl && \
rm -rf /var/lib/apt/lists/*
# Copy built JAR from builder stage
COPY --from=builder /app/target/*.jar app.jar
# Create non-root user for security
RUN useradd -m -s /bin/bash kiket && \
chown -R kiket:kiket /app
USER kiket
# Port configured via deployments.yml, default 9292
ENV PORT=${PORT}
EXPOSE ${PORT}
# Health check endpoint
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
CMD curl -f http://localhost:${PORT}/health || exit 1
# SDK handles server via run()
CMD ["java", "-jar", "app.jar"]