-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
32 lines (31 loc) · 1.1 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
# create docker image from ubuntu base with bullseye slim node runtime dependencies
# SOURCE: https://github.com/BretFisher/nodejs-rocks-in-docker
FROM node:20.2.0-bullseye-slim AS node
FROM ubuntu:focal-20230412 AS base
COPY --from=node /usr/local/include/ /usr/local/include/
COPY --from=node /usr/local/lib/ /usr/local/lib/
COPY --from=node /usr/local/bin/ /usr/local/bin/
# refresh corepack to fix simlinks for npx, yarn, & pnpm
RUN corepack disable && corepack enable
# create server group & node user, then create app directory
RUN groupadd --gid 1000 server \
&& useradd --uid 1000 --gid server --shell /bin/bash --create-home node \
&& mkdir /app \
&& chown -R node:server /app
# create prod environment
FROM base AS prod
# move to app directory, then set user as node
WORKDIR /app
USER node
# install pnpm
RUN curl https://get.pnpm.io/install.sh | env PNPM_VERSION=8.6.2 sh -
# install app dependencies
COPY pnpm-lock.yaml package.json ./
RUN pnpm install --prod
# copy app files
COPY build build
# start server
ENV HOST 0.0.0.0
ENV PORT 8080
EXPOSE 8080
ENTRYPOINT ["/usr/local/bin/node", "./build"]