-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
66 lines (49 loc) · 2.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
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
65
66
FROM node:18-alpine AS base
ENV NEXT_TELEMETRY_DISABLED=1
# Install dependencies only when needed
FROM base AS deps
# SEE: https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine
RUN apk add --no-cache libc6-compat
WORKDIR /app
# Package json is needed in subsequent steps, so copy it over. Lockfile is bound in run step
COPY package.json .
# Install dependencies based on the preferred package manager
RUN --mount=type=bind,source=package-lock.json,target=package-lock.json \
--mount=type=cache,target=/root/.npm \
npm ci --omit=dev
# Rebuild the source code only when needed
FROM base AS builder
WORKDIR /app
COPY . .
ARG DEFAULT_SERVER_ADDR=""
ENV NEXT_PUBLIC_DEFAULT_SERVER_ADDR=$DEFAULT_SERVER_ADDR
RUN --mount=type=bind,from=deps,source=/app/node_modules,target=./node_modules \
npm run build
# Production image, copy all the files and run next
FROM base AS runner
WORKDIR /app
LABEL org.opencontainers.image.authors="Iron-E <code.iron.e@gmail.com>"
LABEL org.opencontainers.image.description="winvoice-gui docker image"
LABEL org.opencontainers.image.documentation="https://github.com/Iron-E/winvoice-gui"
LABEL org.opencontainers.image.license="GPL-3.0-only"
LABEL org.opencontainers.image.source="https://github.com/Iron-E/winvoice-gui"
LABEL org.opencontainers.image.title="winvoice-gui"
LABEL org.opencontainers.image.url="https://github.com/Iron-E/winvoice-gui"
LABEL org.opencontainers.image.vendor="Iron-E <code.iron.e@gmail.com>"
LABEL org.opencontainers.image.version="0.2.0"
# for healthchecks
RUN apk add --no-cache curl
ENV NODE_ENV=production
ARG GID=1001
ARG UID=$GID
RUN addgroup --system --gid "${GID}" nodejs && \
adduser --system --uid "${UID}" nextjs
# Set the correct permission for prerender cache
RUN mkdir .next && \
chown nextjs:nodejs .next
# Automatically leverage output traces to reduce image size
# https://nextjs.org/docs/advanced-features/output-file-tracing
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
USER nextjs
CMD ["node", "server.js"]