-
Notifications
You must be signed in to change notification settings - Fork 36
Expand file tree
/
Copy pathDockerfile
More file actions
56 lines (40 loc) · 1.61 KB
/
Dockerfile
File metadata and controls
56 lines (40 loc) · 1.61 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
FROM node:18-alpine AS base
FROM base AS builder
WORKDIR /server
# Copy the entire app source tree
COPY package.json package-lock.json tsconfig.json tsconfig.proto.json .npmrc ./
COPY src ./src
COPY prisma ./prisma
RUN npm ci
# Compile the application source code
RUN npm run build
FROM base AS runner
# Install OS dependencies
RUN apk add --no-cache openssl
WORKDIR /home/node
# This ensures we only install production dependencies, without the installing the build tools such as tsc, ts-node, etc
ENV NODE_ENV=production
COPY package.json package-lock.json .npmrc ./
COPY prisma ./prisma
# This subshell avoids the need of downloading an unnecessary json parser such as jq
# This also ensures we always get the currently used version of prisma, coming directly from the lock file
# This will be accurate no matter how many times we update the package-lock.json file
RUN npm ci && \
npm i -g prisma@$(node -e 'console.log(require("./package-lock.json").packages["node_modules/prisma"].version)') && \
prisma generate
# Also, good job prisma for bringing a cringe build step in the middle of the runner stage
# prisma will not be uninstalled, in case we need to run `prisma migrate deploy` from within the container
# Finally copy dist files into the runner stage
COPY --from=builder /server/dist /home/node/dist
# Copy game configuration file and certificate
COPY server_wangan.key server_wangan.crt config.json ./
# This ensures that the final dist files are readonly to this node user when running the application.
USER node
# Entrypoint
CMD ["node", "dist"]
# ALLnet
EXPOSE 80
# Mucha
EXPOSE 10082
# Service
EXPOSE 9002