-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
34 lines (28 loc) · 1.09 KB
/
Dockerfile
File metadata and controls
34 lines (28 loc) · 1.09 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
# Stage 1: Build the Angular application
FROM node:25-alpine AS frontend-build
WORKDIR /app
COPY frontend/package*.json ./frontend/
RUN cd frontend && npm install
COPY frontend ./frontend
RUN cd frontend && npm run build --prod
# Stage 2: Build the Spring Boot application
FROM maven:4.0.0-rc-5-eclipse-temurin-25 AS backend-build
WORKDIR /app
COPY backend/pom.xml ./backend/
RUN cd backend && mvn dependency:go-offline
COPY backend ./backend
# Copy Angular build output directly to static directory
COPY --from=frontend-build /app/frontend/dist/network-simulator-frontend/* ./backend/src/main/resources/static/
RUN cd backend && mvn package -DskipTests
# Stage 3: Create the final image
FROM eclipse-temurin:25.0.2_10-jre-noble
WORKDIR /app
# Create a non-root user
RUN groupadd -r appgroup && useradd -r -g appgroup appuser
# Copy the application JAR
COPY --from=backend-build /app/backend/target/*.jar app.jar
# Set permissions and switch to non-root user
RUN chown appuser:appgroup app.jar
USER appuser
EXPOSE 9898
ENTRYPOINT ["java", "-Dspring.profiles.active=${SPRING_PROFILES_ACTIVE:h2}", "-jar", "app.jar"]