-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbackend.Dockerfile
More file actions
57 lines (37 loc) · 1.16 KB
/
backend.Dockerfile
File metadata and controls
57 lines (37 loc) · 1.16 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
48
49
50
51
52
53
54
55
56
57
# Install Dependencies
FROM node:18.12.0 AS Dependencies
WORKDIR /app
COPY package*.json ./
RUN npm ci
# End of Install Dependencies
# ---------------------------------------------------------
# Run Testing
FROM backend_testing AS Testing
WORKDIR /app
ENV JWT_SECRET exmapleForJWTSecret
ENV FORGET_PASSWORD_SECRET exmapleForFORGETPASSWORDSECRET
COPY --from=Dependencies /app/node_modules ./node_modules
COPY . .
RUN npm i mongodb-memory-server
RUN CI=true npm run test -b
#End of Tests
# ---------------------------------------------------------
# Build App
FROM node:18.12.0 AS Build
WORKDIR /app
COPY --from=Dependencies /app/node_modules ./node_modules
COPY . .
RUN npm run build
# Remove Not needed Dependencies in node_modules Folder
# RUN npm ci --omit=dev --ignore-scripts && npm cache clean --force
# End of Building
# ---------------------------------------------------------
# Move Dependencies and App To Final Image
FROM node:18.12.0 AS Final
WORKDIR /app
COPY --from=Build /app/node_modules ./node_modules
COPY --from=Build /app/dist ./dist
EXPOSE 3000
# Start the server using the production build
CMD [ "node", "dist/main.js" ]
# End of Final Image