-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
49 lines (43 loc) · 1.66 KB
/
Copy pathDockerfile
File metadata and controls
49 lines (43 loc) · 1.66 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
# syntax=docker/dockerfile:1
# deps: install production and build dependencies from the lockfile
FROM node:22-alpine AS deps
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm ci
# builder: produce the Next.js standalone output (.next/standalone, .next/static)
FROM node:22-alpine AS builder
WORKDIR /app
ARG VERSION=0.0.0
ARG NEXT_PUBLIC_SITE_URL=https://blobflow.com
# Umami website id. Next inlines NEXT_PUBLIC_ values into the client bundle at
# build time, so an id supplied only at run time never reaches the browser and
# the tracker is never loaded. Empty (the default) ships no tracker at all.
ARG NEXT_PUBLIC_UMAMI_WEBSITE_ID=
ENV NEXT_TELEMETRY_DISABLED=1 \
APP_VERSION=$VERSION \
NEXT_PUBLIC_SITE_URL=$NEXT_PUBLIC_SITE_URL \
NEXT_PUBLIC_UMAMI_WEBSITE_ID=$NEXT_PUBLIC_UMAMI_WEBSITE_ID
COPY --from=deps /app/node_modules ./node_modules
COPY . .
RUN npm run build
# runner: minimal runtime image serving the standalone server
FROM node:22-alpine AS runner
WORKDIR /app
ARG NEXT_PUBLIC_SITE_URL=https://blobflow.com
ARG NEXT_PUBLIC_UMAMI_WEBSITE_ID=
ENV NODE_ENV=production \
NEXT_TELEMETRY_DISABLED=1 \
NEXT_PUBLIC_SITE_URL=$NEXT_PUBLIC_SITE_URL \
NEXT_PUBLIC_UMAMI_WEBSITE_ID=$NEXT_PUBLIC_UMAMI_WEBSITE_ID \
HOSTNAME=0.0.0.0 \
PORT=3000
# Run as a non-root user
RUN addgroup -g 1001 -S nodejs \
&& adduser -u 1001 -S nextjs -G nodejs
# The standalone output already bundles a trimmed node_modules and server.js.
COPY --from=builder /app/public ./public
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
USER nextjs
EXPOSE 3000
CMD ["node", "server.js"]