-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.webapp
More file actions
44 lines (30 loc) · 947 Bytes
/
Copy pathDockerfile.webapp
File metadata and controls
44 lines (30 loc) · 947 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
42
43
44
# Dockerfile for Accordion Web Application
# Multi-stage build for smaller image size
# Stage 1: Build
FROM maven:3.9-eclipse-temurin-17-alpine AS build
WORKDIR /app
# Copy all webapp files
COPY webapp/pom.xml .
COPY webapp/src ./src
# Build the application
RUN mvn clean package -DskipTests
# Stage 2: Runtime
FROM eclipse-temurin:17-jre-alpine
WORKDIR /app
# Install wget for health checks
RUN apk add --no-cache wget
# Create a non-root user
RUN addgroup -S spring && adduser -S spring -G spring
# Copy the built artifact from build stage
COPY --from=build /app/target/*.jar app.jar
# Change ownership
RUN chown spring:spring app.jar
# Switch to non-root user
USER spring:spring
# Expose port
EXPOSE 3000
# Health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=40s --retries=3 \
CMD wget --no-verbose --tries=1 --spider http://localhost:3000/ || exit 1
# Run the application
ENTRYPOINT ["java", "-jar", "app.jar"]