-
Notifications
You must be signed in to change notification settings - Fork 5
/
Dockerfile
35 lines (27 loc) · 1002 Bytes
/
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
ARG NODE_VERSION=18.17.0
ARG NODE_VERSION_SHORT=18
FROM node:${NODE_VERSION}-bullseye-slim AS builder
# Build
WORKDIR /usr/src/app
COPY . .
RUN yarn && yarn build
# Clear cache and install production dependencies
RUN rm -rf node_modules && yarn workspaces focus --production
FROM gcr.io/distroless/nodejs${NODE_VERSION_SHORT}-debian11
WORKDIR /usr/src/app
# Add shell
COPY --from=busybox:1.35.0-uclibc /bin/sh /bin/sh
COPY --from=busybox:1.35.0-uclibc /bin/addgroup /bin/addgroup
COPY --from=busybox:1.35.0-uclibc /bin/adduser /bin/adduser
COPY --from=busybox:1.35.0-uclibc /bin/chown /bin/chown
# Create user
RUN addgroup -g 1000 node \
&& adduser -u 1000 -G node -s /bin/sh -D node
RUN chown -R node ./
USER node
# Copy build files
COPY --from=builder --chown=node /usr/src/app/lib ./lib
COPY --from=builder --chown=node /usr/src/app/node_modules ./node_modules
COPY --from=builder --chown=node /usr/src/app/docs ./docs
EXPOSE 3000
CMD ["./lib/index.js"]