This repository was archived by the owner on May 7, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathDockerfile
More file actions
64 lines (43 loc) · 1.41 KB
/
Dockerfile
File metadata and controls
64 lines (43 loc) · 1.41 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
58
59
60
61
62
63
64
# Stage 1: Build the project
FROM node:lts-alpine AS build
WORKDIR /app
COPY package.json yarn.lock ./
# install dependencies
RUN yarn install --frozen-lockfile
# Copy the application code
COPY . .
RUN yarn build
# remove development dependencies
RUN rm -rf node_modules
FROM node:lts-alpine AS dep
WORKDIR /app
COPY package.json yarn.lock ./
# install dependencies
RUN yarn install --frozen-lockfile --production
RUN rm -rf node_modules/@vscode \
&& rm -rf node_modules/vscode-languageserver-protocol \
&& rm -rf node_modules/vscode-oniguruma \
&& rm -rf node_modules/typescript \
&& rm -rf node_modules/shiki \
&& rm -rf node_modules/@types \
&& rm -rf node_modules/@esbuild \
&& rm -rf node_modules/esbuild-linux-64 \
&& rm -rf node_modules/vscode-css-languageservice \
&& rm -rf node_modules/vscode-html-languageservice \
&& rm -rf node_modules/@iconify \
&& rm -rf node_modules/@intlify \
&& rm -rf node_modules/eslint
# Stage 2: Use Google Distroless as production image
FROM gcr.io/distroless/nodejs18:nonroot AS production
WORKDIR /app
# Copy the built project from the runtime stage
COPY --from=build --chown=nonroot /app .
COPY --from=dep --chown=nonroot /app/node_modules ./node_modules
# Set NODE_ENV to production
ENV NODE_ENV=production
ENV HOST=0.0.0.0
ENV PORT=1809
USER nonroot
# Expose the port on which the application will run
EXPOSE 1809
CMD ["./.output/server/index.mjs"]