-
Notifications
You must be signed in to change notification settings - Fork 29
/
Dockerfile
75 lines (49 loc) · 1.71 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
FROM node:20-alpine AS node
# Builder stage
FROM node AS builder
# Use /app as the CWD
WORKDIR /app
# Copy package.json and package-lock.json to /app
COPY server/package*.json ./
# Install all dependencies
RUN npm i
# Copy the rest of the code
COPY server .
RUN npx prisma generate
# Invoke the build script to transpile code to js
RUN npm run build
FROM node AS fe_builder
# Use /app as the CWD
WORKDIR /fe_app
# Copy package.json and package-lock.json to /app
COPY client/package*.json ./
# Install all dependencies
RUN npm i
# Copy the rest of the code
COPY client .
# Invoke the build script to transpile code to js
RUN npm run build
# Final stage
FROM node AS final
# Prepare a destination directory for js files
RUN mkdir -p /app/dist
RUN mkdir -p /app/dist/public/assets
# Use /app as CWD
WORKDIR /app
# Copy package.json and package-lock.json
COPY server/package*.json server/prisma ./
# Install only production dependencies
RUN npm i --only=production
RUN npx prisma generate
# Copy transpiled js from builder stage into the final image
COPY --from=builder /app/dist ./dist
COPY --from=fe_builder /fe_app/dist_local/* ./dist/public/assets
COPY --from=fe_builder /fe_app/dist_local/index.html ./dist/public
COPY --from=fe_builder /fe_app/dist_local/*.jpg ./dist/public
COPY --from=fe_builder /fe_app/dist_local/*.png ./dist/public
COPY --from=fe_builder /fe_app/dist_local/*.webm ./dist/public
COPY --from=fe_builder /fe_app/dist_local/*.csv ./dist/public
# Open desired port
EXPOSE 3000
# Use js files to run the application
ENTRYPOINT ["node", "./dist/src/index.js"]