-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
42 lines (34 loc) · 1.01 KB
/
Copy pathDockerfile
File metadata and controls
42 lines (34 loc) · 1.01 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
# Development
FROM node:18-alpine AS development
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
EXPOSE 3001
CMD ["npm", "run", "dev"]
# Production Build
FROM node:18-alpine AS build
WORKDIR /app
# Install backend dependencies and build
COPY backend/package*.json ./backend/
RUN cd backend && npm ci --only=production
# Install frontend dependencies and build
COPY frontend/package*.json ./frontend/
RUN cd frontend && npm ci
COPY frontend/ ./frontend/
RUN cd frontend && npm run build
# Copy backend source and build
COPY backend/ ./backend/
RUN cd backend && npm run build
# Production
FROM node:18-alpine AS production
WORKDIR /app
# Copy built backend
COPY --from=build /app/backend/dist ./backend/dist
COPY --from=build /app/backend/package*.json ./backend/
COPY --from=build /app/backend/node_modules ./backend/node_modules
COPY --from=build /app/backend/prisma ./backend/prisma
# Copy built frontend
COPY --from=build /app/frontend/dist ./frontend/dist
EXPOSE 3001
CMD ["node", "backend/dist/index.js"]