-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
37 lines (29 loc) · 1.15 KB
/
Dockerfile
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
# Use a single stage to build both the frontend and backend
FROM maven:3.9-eclipse-temurin-21-alpine AS build
WORKDIR /app
# Install Node.js and npm
RUN apk add --update nodejs npm
# Copy backend source code
COPY websocket-spring-back/pom.xml ./backend/pom.xml
COPY websocket-spring-back/src ./backend/src
# Copy frontend source code
COPY websocket-vue-front/package*.json ./frontend/
WORKDIR /app/frontend
RUN npm install
COPY websocket-vue-front/ ./
# Modify the output directory for the frontend build
RUN sed -i 's|../websocket-spring-back/src/main/resources/static|/app/backend/src/main/resources/static|g' vite.config.ts
# Ensure static directory exists
RUN mkdir -p /app/backend/src/main/resources/static
# Clean the static directory
RUN rm -rf /app/backend/src/main/resources/static/*
# Build the frontend (will output directly to the backend's static resources folder)
RUN npm run build:spring
# Build the backend
WORKDIR /app/backend
RUN mvn clean package -DskipTests
FROM eclipse-temurin:21-jre-alpine
WORKDIR /app
COPY --from=build /app/backend/target/*.jar app.jar
EXPOSE 8080
ENTRYPOINT ["sh", "-c", "java -Dspring.profiles.active=docker -jar app.jar"]