-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile
executable file
·59 lines (38 loc) · 1.33 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
# Step 1 - Install dependencies
FROM node:20-alpine3.17 AS deps
LABEL author="Dmitry Neverovski <dmitryneverovski@gmail.com>"
WORKDIR /app
COPY --chown=node:node package*.json ./
RUN npm ci
USER node
# Step 2 - Build the source code
FROM node:20-alpine3.17 AS build
LABEL author="Dmitry Neverovski <dmitryneverovski@gmail.com>"
WORKDIR /app
ARG NODE_ENV
ENV NODE_ENV=${NODE_ENV:-development}
COPY --chown=node:node package*.json ./
COPY --chown=node:node --from=deps /app/node_modules ./node_modules
COPY --chown=node:node . .
RUN NODE_ENV=${NODE_ENV} npm run build:api
USER node
# Step 3 - Instal dependencies without devDependencies
FROM node:20-alpine3.17 AS modules
LABEL author="Dmitry Neverovski <dmitryneverovski@gmail.com>"
WORKDIR /app
ARG NODE_ENV
ENV NODE_ENV=${NODE_ENV:-development}
COPY --chown=node:node package*.json ./
RUN npm ci --omit=dev --ignore-scripts
USER node
# Step - 5 Production image, copy all the files and run next
FROM node:20-alpine3.17 AS runner
LABEL author="Dmitry Neverovski <dmitryneverovski@gmail.com>"
ARG APP_PORT
ENV APP_PORT=${APP_PORT:-5656}
COPY --chown=node:node package*.json ./
COPY --chown=node:node templates ./templates
COPY --chown=node:node --from=modules /app/node_modules ./node_modules
COPY --chown=node:node --from=build /app/dist ./dist
EXPOSE ${APP_PORT}
CMD [ "node", "dist/main.js" ]