-
Notifications
You must be signed in to change notification settings - Fork 0
/
dockerfile
51 lines (36 loc) · 1.07 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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# Use a base image for Node.js
FROM node:18 AS builder
# Set the working directory for frontend
WORKDIR /app/frontend
# Set the environment for production
ENV VITE_API_URL=/api
# Copy frontend package.json and install dependencies
COPY frontend/package*.json ./
RUN npm install
# Build the frontend
COPY frontend .
RUN npm run build
# Set the working directory for backend
WORKDIR /app/backend
# Set the environment for backend
ENV NODE_ENV=production
ENV PORT=3000
ENV DEFAULT_ADMIN_NAME=admin
ENV DEFAULT_ADMIN_PASSWORD=admin
# Copy backend package.json and install dependencies
COPY backend/package*.json ./
RUN npm install
# Copy the frontend build output into the backend directory
RUN cp -r /app/frontend/dist /app/backend/frontend
# Copy the rest of the backend source code
COPY backend .
# Use a lightweight Node.js image for production
FROM node:18-alpine AS production
# Set the working directory
WORKDIR /app
# Copy backend files from the builder stage
COPY --from=builder /app/backend .
# Expose the application port
EXPOSE 3000
# Start the server
CMD ["npm", "start"]