-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
54 lines (39 loc) · 1.25 KB
/
Dockerfile
File metadata and controls
54 lines (39 loc) · 1.25 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
# Build frontend
FROM node:20-alpine AS frontend-build
WORKDIR /app/frontend
# Build args for Vite env vars (must be available at build time)
ARG VITE_GA_MEASUREMENT_ID
ENV VITE_GA_MEASUREMENT_ID=$VITE_GA_MEASUREMENT_ID
COPY frontend/package*.json ./
RUN npm ci
COPY frontend/ ./
RUN npm run build
# Build backend
FROM eclipse-temurin:21-jdk-alpine AS backend-build
WORKDIR /app
# Copy maven wrapper and pom
COPY backend/.mvn/ .mvn/
COPY backend/mvnw backend/pom.xml ./
# Download dependencies (cached layer)
RUN ./mvnw dependency:go-offline -B
# Copy source
COPY backend/src/ src/
# Copy frontend build to static resources
COPY --from=frontend-build /app/frontend/dist/ src/main/resources/static/
# Build
RUN ./mvnw package -DskipTests -B
# Runtime stage
FROM eclipse-temurin:21-jre-alpine
WORKDIR /app
# Create non-root user
RUN addgroup -g 1001 appgroup && adduser -u 1001 -G appgroup -D appuser
# Copy built artifact
COPY --from=backend-build /app/target/*.jar app.jar
# Set ownership
RUN chown -R appuser:appgroup /app
USER appuser
# Health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=60s --retries=3 \
CMD wget --no-verbose --tries=1 --spider http://localhost:8080/actuator/health || exit 1
EXPOSE 8080
ENTRYPOINT ["java", "-jar", "app.jar"]