Commit
•
db07f7a
1
Parent(s):
633e5e5
add dockerfile
Browse files- Dockerfile +65 -0
- next.config.mjs +1 -0
Dockerfile
ADDED
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# syntax=docker/dockerfile:1.4
|
2 |
+
|
3 |
+
# Adapted from https://github.com/vercel/next.js/blob/e60a1e747c3f521fc24dfd9ee2989e13afeb0a9b/examples/with-docker/Dockerfile
|
4 |
+
# For more information, see https://nextjs.org/docs/pages/building-your-application/deploying#docker-image
|
5 |
+
|
6 |
+
FROM node:18 AS base
|
7 |
+
|
8 |
+
# Install dependencies only when needed
|
9 |
+
FROM base AS deps
|
10 |
+
WORKDIR /app
|
11 |
+
|
12 |
+
# Install dependencies based on the preferred package manager
|
13 |
+
COPY --link package.json yarn.lock* package-lock.json* pnpm-lock.yaml* ./
|
14 |
+
RUN \
|
15 |
+
if [ -f yarn.lock ]; then yarn --frozen-lockfile; \
|
16 |
+
elif [ -f package-lock.json ]; then npm ci; \
|
17 |
+
elif [ -f pnpm-lock.yaml ]; then yarn global add pnpm && pnpm i --frozen-lockfile; \
|
18 |
+
else echo "Lockfile not found." && exit 1; \
|
19 |
+
fi
|
20 |
+
|
21 |
+
|
22 |
+
# Rebuild the source code only when needed
|
23 |
+
FROM base AS builder
|
24 |
+
WORKDIR /app
|
25 |
+
COPY --from=deps --link /app/node_modules ./node_modules
|
26 |
+
COPY --link . .
|
27 |
+
|
28 |
+
# Next.js collects completely anonymous telemetry data about general usage.
|
29 |
+
# Learn more here: https://nextjs.org/telemetry
|
30 |
+
# Uncomment the following line in case you want to disable telemetry during the build.
|
31 |
+
# ENV NEXT_TELEMETRY_DISABLED 1
|
32 |
+
|
33 |
+
RUN npm run build
|
34 |
+
|
35 |
+
# If using yarn comment out above and use below instead
|
36 |
+
# RUN yarn build
|
37 |
+
|
38 |
+
# Production image, copy all the files and run next
|
39 |
+
FROM base AS runner
|
40 |
+
WORKDIR /app
|
41 |
+
|
42 |
+
|
43 |
+
ENV NODE_ENV production
|
44 |
+
# Uncomment the following line in case you want to disable telemetry during runtime.
|
45 |
+
# ENV NEXT_TELEMETRY_DISABLED 1
|
46 |
+
|
47 |
+
RUN \
|
48 |
+
addgroup --system --gid 1001 nodejs; \
|
49 |
+
adduser --system --uid 1001 nextjs
|
50 |
+
|
51 |
+
COPY --from=builder --link /app/public ./public
|
52 |
+
|
53 |
+
# Automatically leverage output traces to reduce image size
|
54 |
+
# https://nextjs.org/docs/advanced-features/output-file-tracing
|
55 |
+
COPY --from=builder --link --chown=1001:1001 /app/.next/standalone ./
|
56 |
+
COPY --from=builder --link --chown=1001:1001 /app/.next/static ./.next/static
|
57 |
+
|
58 |
+
USER nextjs
|
59 |
+
|
60 |
+
EXPOSE 3000
|
61 |
+
|
62 |
+
ENV PORT 3000
|
63 |
+
ENV HOSTNAME 0.0.0.0
|
64 |
+
|
65 |
+
CMD ["node", "server.js"]
|
next.config.mjs
CHANGED
@@ -1,5 +1,6 @@
|
|
1 |
/** @type {import('next').NextConfig} */
|
2 |
const nextConfig = {
|
|
|
3 |
reactStrictMode: true,
|
4 |
};
|
5 |
|
|
|
1 |
/** @type {import('next').NextConfig} */
|
2 |
const nextConfig = {
|
3 |
+
output: 'standalone',
|
4 |
reactStrictMode: true,
|
5 |
};
|
6 |
|