Shih-hungg commited on
Commit
1411fe8
·
1 Parent(s): 34f0757

Revert dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +16 -51
Dockerfile CHANGED
@@ -1,61 +1,26 @@
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:20 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
- # 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
- # 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
- # Production image, copy all the files and run next
36
- FROM base AS runner
37
- WORKDIR /app
38
 
39
- ENV NODE_ENV production
40
- # Uncomment the following line in case you want to disable telemetry during runtime.
41
- # ENV NEXT_TELEMETRY_DISABLED 1
42
 
43
- RUN \
44
- addgroup --system --gid 1001 nodejs; \
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
- ENV PORT 7860
59
- ENV HOSTNAME 0.0.0.0
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"]