feat(scaffold): add Dockerfile [skip ci]
This commit is contained in:
30
Dockerfile
Normal file
30
Dockerfile
Normal file
@@ -0,0 +1,30 @@
|
||||
# ---- Build stage ----
|
||||
FROM maven:3.9-eclipse-temurin-17-alpine AS build
|
||||
WORKDIR /workspace
|
||||
|
||||
COPY pom.xml .
|
||||
RUN mvn dependency:go-offline -q
|
||||
|
||||
COPY src ./src
|
||||
RUN mvn package -DskipTests -q
|
||||
|
||||
# ---- Runtime stage ----
|
||||
FROM eclipse-temurin:17-jre-alpine
|
||||
WORKDIR /app
|
||||
|
||||
# Download OTel Java agent for zero-code auto-instrumentation
|
||||
RUN wget -q -O /app/otel-agent.jar \
|
||||
"https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/download/v2.5.0/opentelemetry-javaagent.jar"
|
||||
|
||||
# Non-root user
|
||||
RUN addgroup -S appgroup && adduser -S appuser -G appgroup
|
||||
USER appuser
|
||||
|
||||
COPY --from=build /workspace/target/*.jar app.jar
|
||||
|
||||
EXPOSE 8080
|
||||
|
||||
HEALTHCHECK --interval=30s --timeout=5s --start-period=30s --retries=3 \
|
||||
CMD wget -qO- http://localhost:8080/actuator/health | grep -q '"status":"UP"' || exit 1
|
||||
|
||||
ENTRYPOINT ["java", "-javaagent:/app/otel-agent.jar", "-jar", "app.jar"]
|
||||
Reference in New Issue
Block a user