-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
51 lines (38 loc) · 1.47 KB
/
Copy pathDockerfile
File metadata and controls
51 lines (38 loc) · 1.47 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
# Simple single-stage build for Cloud Build
# Using official openjdk image available on Docker Hub
FROM openjdk:17.0.2-jdk-slim
# Install required packages
RUN apt-get update && apt-get install -y \
curl \
&& rm -rf /var/lib/apt/lists/*
# Set working directory
WORKDIR /app
# Copy gradle wrapper and build files
COPY gradlew .
COPY gradle gradle
COPY build.gradle .
COPY settings.gradle .
# Make gradlew executable
RUN chmod +x gradlew
# Copy source code
COPY src src
# Build the application (only bootJar)
RUN ./gradlew bootJar -x test --no-daemon
# Create app user for security
RUN useradd -r -s /bin/false app
# Create data directory
RUN mkdir -p /app/data && chown -R app:app /app
# Switch to app user
USER app
# Expose port
EXPOSE 8080
# Environment variables optimized for Cloud Run
ENV JAVA_OPTS="-Xmx768m -Xms256m -XX:+UseG1GC -XX:MaxGCPauseMillis=200 -Djava.security.egd=file:/dev/./urandom -Djava.awt.headless=true -Dfile.encoding=UTF-8" \
SPRING_PROFILES_ACTIVE=prod \
SERVER_PORT=8080
# Health check with extended startup period for Cloud Run (Cloud Run has separate health checks)
# Increased start-period to 120s to give the application more time to start
HEALTHCHECK --interval=30s --timeout=10s --start-period=120s --retries=3 \
CMD curl -f http://localhost:8080/actuator/health || exit 1
# Run the application
ENTRYPOINT ["sh", "-c", "echo 'Starting application...' && ls -la build/libs/ && java $JAVA_OPTS -jar build/libs/exch_sim-0.0.1-SNAPSHOT.jar"]