Leon4gr45 commited on
Commit
cece1db
·
verified ·
1 Parent(s): 22d376f

Simplified Dockerfile to avoid undici assertion error

Browse files
Files changed (1) hide show
  1. Dockerfile +10 -31
Dockerfile CHANGED
@@ -1,52 +1,31 @@
1
  FROM node:22-alpine AS base
2
 
3
- # Install dependencies only when needed
4
- FROM base AS deps
5
  RUN apk add --no-cache libc6-compat
6
  WORKDIR /app
 
7
 
8
- # Install dependencies based on the preferred package manager
9
  COPY package.json pnpm-lock.yaml* ./
10
- RUN corepack enable pnpm && pnpm i --no-frozen-lockfile --ignore-scripts
11
 
12
- # Rebuild the source code only when needed
13
- FROM base AS builder
14
- WORKDIR /app
15
- COPY --from=deps /app/node_modules ./node_modules
16
  COPY . .
17
-
18
- # Disable telemetry during the build.
19
  ENV NEXT_TELEMETRY_DISABLED 1
 
20
 
21
- # Avoid corepack enable here if it's causing issues, or just use the pnpm already in the previous layer
22
- RUN corepack enable pnpm && pnpm run build
23
-
24
- # Production image, copy all the files and run next
25
  FROM base AS runner
26
  WORKDIR /app
27
-
28
  ENV NODE_ENV production
29
  ENV NEXT_TELEMETRY_DISABLED 1
30
 
31
- # HF Spaces run with UID 1000, which is the 'node' user in node:22-alpine
32
- # We ensure the 'node' user is used to avoid UID conflicts
33
-
34
- COPY --from=builder /app/public ./public
35
-
36
- # Set the correct permission for prerender cache
37
- RUN mkdir .next
38
- RUN chown node:node .next
39
-
40
- # Automatically leverage output traces to reduce image size
41
- # https://nextjs.org/docs/advanced-features/output-file-tracing
42
- COPY --from=builder --chown=node:node /app/.next/standalone ./
43
- COPY --from=builder --chown=node:node /app/.next/static ./.next/static
44
 
45
  USER node
46
-
47
  EXPOSE 7860
48
-
49
  ENV PORT 7860
50
  ENV HOSTNAME "0.0.0.0"
51
-
52
  CMD ["node", "server.js"]
 
1
  FROM node:22-alpine AS base
2
 
 
 
3
  RUN apk add --no-cache libc6-compat
4
  WORKDIR /app
5
+ RUN corepack enable pnpm
6
 
7
+ # Install dependencies
8
  COPY package.json pnpm-lock.yaml* ./
9
+ RUN pnpm i --no-frozen-lockfile --ignore-scripts
10
 
11
+ # Build
 
 
 
12
  COPY . .
 
 
13
  ENV NEXT_TELEMETRY_DISABLED 1
14
+ RUN pnpm run build
15
 
16
+ # Runner
 
 
 
17
  FROM base AS runner
18
  WORKDIR /app
 
19
  ENV NODE_ENV production
20
  ENV NEXT_TELEMETRY_DISABLED 1
21
 
22
+ COPY --from=base /app/public ./public
23
+ RUN mkdir .next && chown node:node .next
24
+ COPY --from=base --chown=node:node /app/.next/standalone ./
25
+ COPY --from=base --chown=node:node /app/.next/static ./.next/static
 
 
 
 
 
 
 
 
 
26
 
27
  USER node
 
28
  EXPOSE 7860
 
29
  ENV PORT 7860
30
  ENV HOSTNAME "0.0.0.0"
 
31
  CMD ["node", "server.js"]