Update Dockerfile
Browse files- Dockerfile +20 -47
Dockerfile
CHANGED
@@ -10,57 +10,30 @@ WORKDIR /app
|
|
10 |
|
11 |
# Install dependencies based on the preferred package manager
|
12 |
COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* .npmrc* ./
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
# Rebuild the source code only when needed
|
22 |
-
FROM base AS builder
|
23 |
-
WORKDIR /app
|
24 |
-
COPY --from=deps /app/node_modules ./node_modules
|
25 |
-
COPY . .
|
26 |
-
|
27 |
-
# Next.js collects completely anonymous telemetry data about general usage.
|
28 |
-
# Learn more here: https://nextjs.org/telemetry
|
29 |
-
# Uncomment the following line in case you want to disable telemetry during the build.
|
30 |
-
# ENV NEXT_TELEMETRY_DISABLED=1
|
31 |
-
|
32 |
-
RUN \
|
33 |
-
if [ -f yarn.lock ]; then yarn run build; \
|
34 |
-
elif [ -f package-lock.json ]; then npm run build; \
|
35 |
-
elif [ -f pnpm-lock.yaml ]; then corepack enable pnpm && pnpm run build; \
|
36 |
-
else echo "Lockfile not found." && exit 1; \
|
37 |
-
fi
|
38 |
-
|
39 |
-
# Production image, copy all the files and run next
|
40 |
-
FROM base AS runner
|
41 |
-
WORKDIR /app
|
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 addgroup --system --gid 1001 nodejs
|
48 |
-
RUN adduser --system --uid 1001 nextjs
|
49 |
-
|
50 |
COPY --from=builder /app/public ./public
|
|
|
|
|
|
|
51 |
|
52 |
-
#
|
53 |
-
#
|
54 |
-
|
55 |
-
|
|
|
|
|
56 |
|
57 |
-
USER nextjs
|
58 |
|
|
|
59 |
EXPOSE 3000
|
60 |
|
61 |
-
|
|
|
62 |
|
63 |
-
#
|
64 |
-
|
65 |
-
ENV HOSTNAME="0.0.0.0"
|
66 |
-
CMD ["node", "server.js"]
|
|
|
10 |
|
11 |
# Install dependencies based on the preferred package manager
|
12 |
COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* .npmrc* ./
|
13 |
+
# Copy necessary files from the builder stage
|
14 |
+
# Copy production dependencies
|
15 |
+
COPY --from=builder /app/node_modules ./node_modules
|
16 |
+
# Copy the build output (.next folder)
|
17 |
+
COPY --from=builder /app/.next ./.next
|
18 |
+
# Copy public assets
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
COPY --from=builder /app/public ./public
|
20 |
+
# Copy next.config.js if it exists
|
21 |
+
COPY --from=builder /app/next.config.js ./next.config.js
|
22 |
+
|
23 |
|
24 |
+
# Set the environment variable for the Next.js port (default is 3000)
|
25 |
+
# Hugging Face Spaces typically exposes port 7860 for Gradio/Streamlit/etc,
|
26 |
+
# but for general web apps (like Next.js via the static host option or if you set up a custom server),
|
27 |
+
# it might expose port 3000 by default when detecting a standard Next.js app.
|
28 |
+
# It's good practice to set this, but Spaces often handles port mapping.
|
29 |
+
ENV PORT 3000
|
30 |
|
|
|
31 |
|
32 |
+
# Expose the port the application will run on
|
33 |
EXPOSE 3000
|
34 |
|
35 |
+
# Disable Next.js telemetry at runtime
|
36 |
+
ENV NEXT_TELEMETRY_DISABLED 1
|
37 |
|
38 |
+
# Command to run the production Next.js server
|
39 |
+
CMD ["npm", "start"]
|
|
|
|