forked from aeharding/voyager
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
54 lines (34 loc) · 1.09 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
# stage 0: set base image w/common customizations
FROM docker.io/library/node:lts-alpine AS base
# Prepare work directory
WORKDIR /voyager
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
# enable corepack & set network-timeout
RUN corepack enable &&\
pnpm config set network-timeout 300000
# stage 1: build
FROM base AS builder
# Prepare deps
RUN apk add --no-cache git
# Prepare build deps ( ignore postinstall scripts for now )
COPY package.json pnpm-lock.yaml ./
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile --ignore-scripts
# Copy all source files
COPY . ./
# Build
RUN pnpm build
# stage 2: runtime
FROM base AS runner
ARG UID=911 GID=911
COPY package.json pnpm-lock.yaml server.mjs ./
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --prod --frozen-lockfile --ignore-scripts
# Create a dedicated user and group
RUN set -eux; \
addgroup -g "${GID}" voyager; \
adduser -u "${UID}" -D -G voyager voyager
USER voyager
ENV NODE_ENV=production PORT=5314
COPY --from=builder /voyager/dist ./dist
EXPOSE 5314/tcp
CMD ["node","./server.mjs"]