-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
41 lines (30 loc) · 975 Bytes
/
Dockerfile
File metadata and controls
41 lines (30 loc) · 975 Bytes
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
# Build stage
FROM maven:3.9.6-eclipse-temurin-21-jammy AS build
WORKDIR /workspace/app
# Copy maven executable to the image
COPY mvnw .
COPY .mvn .mvn
# Copy the project files
COPY pom.xml .
COPY src src
# Build a release artifact
RUN --mount=type=cache,target=/root/.m2 ./mvnw clean package -DskipTests
# Runtime stage
FROM eclipse-temurin:21-jre-jammy
# Set working directory
WORKDIR /app
# Copy the jar file from the build stage
COPY --from=build /workspace/app/target/*.jar app.jar
# Add wait-for-it script for database readiness check
ADD https://raw.githubusercontent.com/vishnubob/wait-for-it/master/wait-for-it.sh wait-for-it.sh
RUN chmod +x wait-for-it.sh
# Create volume for logs
VOLUME /app/logs
# Environment variables
ENV SPRING_OUTPUT_ANSI_ENABLED=ALWAYS \
JAVA_OPTS="-Xmx512m -Xms256m" \
SPRING_PROFILES_ACTIVE=prod
# Expose the application port
EXPOSE 8443
# Start the application
ENTRYPOINT ["sh", "-c", "java ${JAVA_OPTS} -jar app.jar"]