-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
47 lines (35 loc) · 1.1 KB
/
Dockerfile
File metadata and controls
47 lines (35 loc) · 1.1 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
# Multi-stage build for both frontend and backend
# Stage 1: Build frontend
FROM node:18-alpine AS frontend-build
WORKDIR /app/frontend
# Copy package files first for better caching
COPY frontend/package*.json ./
RUN npm ci
# Copy frontend source
COPY frontend/src ./src
COPY frontend/public ./public
COPY frontend/tsconfig.json ./
# Build the frontend
RUN npm run build
# List contents for debugging
RUN ls -la /app/frontend/build || echo "Build directory not found"
# Stage 2: Build backend
FROM maven:3.8.4-openjdk-17 AS backend-build
WORKDIR /app
COPY backend/pom.xml backend/pom.xml
COPY backend/src backend/src
WORKDIR /app/backend
RUN mvn clean package -DskipTests
# Stage 3: Runtime
FROM openjdk:17-jdk-slim
WORKDIR /app
# Copy the built JAR file from backend build stage
COPY --from=backend-build /app/backend/target/simulator-backend-0.0.1-SNAPSHOT.jar app.jar
# Copy the built frontend from frontend build stage
COPY --from=frontend-build /app/frontend/build ./static
# Expose the port
EXPOSE 8080
# Set environment variable for port
ENV PORT=8080
# Run the application
CMD ["java", "-jar", "app.jar"]