aboutsummaryrefslogtreecommitdiffstats
path: root/Dockerfile
diff options
context:
space:
mode:
Diffstat (limited to 'Dockerfile')
-rw-r--r--Dockerfile59
1 files changed, 59 insertions, 0 deletions
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 0000000..f68a80a
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,59 @@
1FROM node:18-alpine AS base
2
3# Install dependencies only when needed
4FROM base AS deps
5# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
6RUN apk add --no-cache libc6-compat
7WORKDIR /app
8
9# Install dependencies based on the preferred package manager
10COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* ./
11RUN \
12 if [ -f yarn.lock ]; then yarn --frozen-lockfile; \
13 elif [ -f package-lock.json ]; then npm ci; \
14 elif [ -f pnpm-lock.yaml ]; then yarn global add pnpm && pnpm i --frozen-lockfile; \
15 else echo "Lockfile not found." && exit 1; \
16 fi
17
18
19# Rebuild the source code only when needed
20FROM base AS builder
21WORKDIR /app
22COPY --from=deps /app/node_modules ./node_modules
23COPY . .
24
25# Next.js collects completely anonymous telemetry data about general usage.
26# Learn more here: https://nextjs.org/telemetry
27# Uncomment the following line in case you want to disable telemetry during the build.
28# ENV NEXT_TELEMETRY_DISABLED 1
29
30RUN yarn build
31
32# If using npm comment out above and use below instead
33# RUN npm run build
34
35# Production image, copy all the files and run next
36FROM base AS runner
37WORKDIR /app
38
39ENV NODE_ENV production
40# Uncomment the following line in case you want to disable telemetry during runtime.
41# ENV NEXT_TELEMETRY_DISABLED 1
42
43RUN addgroup --system --gid 1001 nodejs
44RUN adduser --system --uid 1001 nextjs
45
46COPY --from=builder /app/public ./public
47
48# Automatically leverage output traces to reduce image size
49# https://nextjs.org/docs/advanced-features/output-file-tracing
50COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
51COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
52
53USER nextjs
54
55EXPOSE 3000
56
57ENV PORT 3000
58
59CMD ["node", "server.js"]