-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
82 lines (56 loc) · 1.92 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
76
77
78
79
80
81
82
FROM node:22-bookworm-slim AS base
# default environment variables
ENV \
DEBIAN_FRONTEND=noninteractive \
TZ=UTC
RUN \
# add dependencies
apt-get update \
&& apt-get install -y \
openssl \
procps \
tzdata \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* \
# create our own user and remove the node user
&& groupadd --gid 1001 app \
&& useradd --create-home --home /app --shell /bin/bash --gid 1001 --uid 1001 app \
&& userdel -r node \
# create the config directory
&& mkdir /config && chown app:app /config \
# install the latest version of npm
&& npm install -g npm@latest \
# create the node_modules directory, make it owned by app user
&& mkdir -p /app/node_modules && chown app:app /app/node_modules
USER app
WORKDIR /app
COPY --chown=app:app ./scripts/entrypoint.sh .
ENTRYPOINT [ "/app/entrypoint.sh" ]
##############################
FROM base AS development
ENV NODE_ENV=development
COPY --chown=app:app package*.json ./
COPY --chown=app:app apps/api/package*.json ./apps/api/
COPY --chown=app:app apps/client/package*.json ./apps/client/
COPY --chown=app:app packages/eslint-config-custom/package*.json ./packages/eslint-config-custom/
COPY --chown=app:app packages/types/package*.json ./packages/types/
RUN npm ci && npm cache clean --force
COPY --chown=app:app apps/api/prisma ./apps/api/prisma
RUN npm run db:generate
EXPOSE 3000
EXPOSE 3001
CMD [ "npm", "run", "dev" ]
##############################
FROM development AS build
ENV NODE_ENV=production
COPY --chown=app:app . ./
RUN npm run build
##############################
FROM base AS production
ENV NODE_ENV=production
COPY --from=build --chown=app:app /app/node_modules ./node_modules
COPY --from=build --chown=app:app /app/apps/api/dist ./dist
COPY --from=build --chown=app:app /app/apps/client/dist ./public
COPY --from=build --chown=app:app /app/apps/api/prisma ./prisma
EXPOSE 5588
CMD [ "node", "/app/dist/main.js" ]