Commit ·
1411fe8
1
Parent(s): 34f0757
Revert dockerfile
Browse files- Dockerfile +16 -51
Dockerfile
CHANGED
|
@@ -1,61 +1,26 @@
|
|
| 1 |
-
#
|
|
|
|
| 2 |
|
| 3 |
-
#
|
| 4 |
-
# For more information, see https://nextjs.org/docs/pages/building-your-application/deploying#docker-image
|
| 5 |
-
|
| 6 |
-
FROM node:20 AS base
|
| 7 |
-
|
| 8 |
-
# Install dependencies only when needed
|
| 9 |
-
FROM base AS deps
|
| 10 |
WORKDIR /app
|
| 11 |
|
| 12 |
-
#
|
| 13 |
-
COPY
|
| 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 |
-
# Rebuild the source code only when needed
|
| 22 |
-
FROM base AS builder
|
| 23 |
-
WORKDIR /app
|
| 24 |
-
COPY --from=deps --link /app/node_modules ./node_modules
|
| 25 |
-
COPY --link package.json package-lock.json ./
|
| 26 |
-
COPY --link . .
|
| 27 |
|
| 28 |
-
#
|
| 29 |
-
|
| 30 |
-
# Uncomment the following line in case you want to disable telemetry during the build.
|
| 31 |
-
# ENV NEXT_TELEMETRY_DISABLED 1
|
| 32 |
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
# Production image, copy all the files and run next
|
| 36 |
-
FROM base AS runner
|
| 37 |
-
WORKDIR /app
|
| 38 |
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
# ENV NEXT_TELEMETRY_DISABLED 1
|
| 42 |
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
adduser --system --uid 1001 nextjs
|
| 46 |
-
|
| 47 |
-
COPY --from=builder --link /app/public ./public
|
| 48 |
-
|
| 49 |
-
# Automatically leverage output traces to reduce image size
|
| 50 |
-
# https://nextjs.org/docs/advanced-features/output-file-tracing
|
| 51 |
-
COPY --from=builder --link --chown=1001:1001 /app/.next/standalone ./
|
| 52 |
-
COPY --from=builder --link --chown=1001:1001 /app/.next/static ./.next/static
|
| 53 |
-
|
| 54 |
-
USER nextjs
|
| 55 |
|
|
|
|
| 56 |
EXPOSE 7860
|
| 57 |
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
CMD ["node", "server.js"]
|
|
|
|
| 1 |
+
# Use the official Node.js 18 image
|
| 2 |
+
FROM node:20-alpine
|
| 3 |
|
| 4 |
+
# Set the working directory
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
WORKDIR /app
|
| 6 |
|
| 7 |
+
# Copy package files
|
| 8 |
+
COPY package*.json ./
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
+
# Install production dependencies (TypeScript is now in production deps)
|
| 11 |
+
RUN npm ci
|
|
|
|
|
|
|
| 12 |
|
| 13 |
+
# Copy the rest of the application
|
| 14 |
+
COPY . .
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
+
# Build the Next.js application
|
| 17 |
+
RUN npx next build
|
|
|
|
| 18 |
|
| 19 |
+
# # Remove dev dependencies to reduce image size
|
| 20 |
+
# RUN npm prune --production
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
|
| 22 |
+
# Expose Hugging Face default port
|
| 23 |
EXPOSE 7860
|
| 24 |
|
| 25 |
+
# Start Next.js on port 7860
|
| 26 |
+
CMD ["npx", "next", "start", "-p", "7860"]
|
|
|
|
|
|