-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathDockerfile
35 lines (24 loc) · 918 Bytes
/
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
# Use Node.js base image
FROM node:18-alpine
# Set working directory for backend
WORKDIR /app
# Copy backend package files and install dependencies
COPY backend/package.json backend/package-lock.json /app/backend/
RUN cd backend && npm install
# Copy frontend package files and install dependencies
COPY frontend/package.json frontend/package-lock.json /app/frontend/
RUN cd frontend && npm install
# Copy the rest of the code to the container
COPY . /app
RUN cd backend && npm run build
# Build frontend (SPA)
RUN cd frontend && npm run build
# Copy the built frontend into the backend's build directory (Express will serve it)
RUN cp -r frontend/dist /app/backend/dist
RUN mv /app/backend/dist/dist /app/backend/dist/build
# Expose the port that Express will listen on
EXPOSE 3000
# Set the working directory to the backend
WORKDIR /app/backend
# Command to run Express server
CMD ["npm", "run", "start"]