techprotrade commited on
Commit
4124924
·
verified ·
1 Parent(s): 7d81f6a

Fix Dockerfile: reuse node uid 1000 (GID conflict)

Browse files
Files changed (1) hide show
  1. Dockerfile +5 -11
Dockerfile CHANGED
@@ -16,7 +16,6 @@ ENV NEXT_TELEMETRY_DISABLED=1 \
16
  NODE_OPTIONS=--max-old-space-size=4096
17
  COPY --from=deps /app/node_modules ./node_modules
18
  COPY . .
19
- # Public API URL can be set as HF Space secret/variable at build or runtime rewrites
20
  ARG NEXT_PUBLIC_API_URL=
21
  ENV NEXT_PUBLIC_API_URL=${NEXT_PUBLIC_API_URL}
22
  RUN npm run build
@@ -28,16 +27,11 @@ ENV NODE_ENV=production \
28
  PORT=7860 \
29
  HOSTNAME=0.0.0.0
30
 
31
- RUN groupadd --gid 1000 nodejs \
32
- && useradd --uid 1000 --gid nodejs --create-home nextjs
 
 
33
 
34
- # Standalone output (Next.js output: 'standalone')
35
- COPY --from=builder --chown=nextjs:nodejs /app/public ./public
36
- COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
37
- COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
38
-
39
- USER nextjs
40
  EXPOSE 7860
41
-
42
- # server.js is produced by Next standalone build
43
  CMD ["node", "server.js"]
 
16
  NODE_OPTIONS=--max-old-space-size=4096
17
  COPY --from=deps /app/node_modules ./node_modules
18
  COPY . .
 
19
  ARG NEXT_PUBLIC_API_URL=
20
  ENV NEXT_PUBLIC_API_URL=${NEXT_PUBLIC_API_URL}
21
  RUN npm run build
 
27
  PORT=7860 \
28
  HOSTNAME=0.0.0.0
29
 
30
+ # node:20 image already has uid/gid 1000 (user "node") — reuse it for HF Spaces
31
+ COPY --from=builder --chown=node:node /app/public ./public
32
+ COPY --from=builder --chown=node:node /app/.next/standalone ./
33
+ COPY --from=builder --chown=node:node /app/.next/static ./.next/static
34
 
35
+ USER node
 
 
 
 
 
36
  EXPOSE 7860
 
 
37
  CMD ["node", "server.js"]