Spaces:
deepak191z
/
Runtime error

deepak191z commited on
Commit
0cdf744
·
verified ·
1 Parent(s): 229b3b8

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +43 -45
Dockerfile CHANGED
@@ -1,69 +1,67 @@
1
- # Base stage with Node.js
2
- FROM node:20-slim AS base
3
-
4
- # Setup environment for pnpm
5
- ENV PNPM_HOME="/pnpm"
6
- ENV PATH="$PNPM_HOME:$PATH"
7
- RUN corepack enable
8
 
 
 
 
 
9
  WORKDIR /app
10
 
11
- # Install sharp dependencies in a separate stage
12
- FROM base AS sharp
13
- # Install sharp for production
14
- RUN pnpm add sharp
15
-
16
- # Install dependencies and build the project
 
 
 
 
 
 
 
 
 
17
  FROM base AS builder
18
- ENV PNPM_HOME="/pnpm"
19
- ENV PATH="$PNPM_HOME:$PATH"
20
- RUN corepack enable
21
-
22
- # Install Git to clone the repository
23
- RUN apt update && apt-get install git -y
24
 
25
- # Clone the repository (you can replace this with a COPY if local)
26
- RUN git clone https://github.com/designcombo/react-video-editor.git .
 
 
27
 
28
- # Install the project's dependencies
29
- RUN pnpm install
30
 
31
- # Build the application in standalone mode
32
- RUN pnpm run build
33
 
34
- # Production stage
35
  FROM base AS runner
36
  WORKDIR /app
 
37
  ENV NODE_ENV production
 
 
38
 
39
- # Create non-root user for security
40
  RUN addgroup --system --gid 1001 nodejs
41
  RUN adduser --system --uid 1001 nextjs
42
 
43
- # Copy the public folder from the builder stage
44
  COPY --from=builder /app/public ./public
45
 
46
- # Set correct permissions for prerender cache
47
- RUN mkdir -p .next/cache
48
- RUN chown -R nextjs:nodejs .next
49
- RUN chmod -R 777 .next/cache
50
-
51
- # Copy the standalone build files from the builder stage
52
  COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
53
  COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
 
 
54
 
55
- # Copy node_modules from the sharp stage (optional)
56
- COPY --from=sharp /app/node_modules ./node_modules
57
-
58
- # Switch to non-root user
59
  USER nextjs
60
 
61
- # Expose the port
62
- EXPOSE 7860
63
-
64
- # Set environment variables
65
- ENV HOSTNAME "0.0.0.0"
66
- ENV PORT 7860
67
 
 
68
 
69
- CMD ["pnpm", "dev"]
 
 
 
1
+ FROM node:20-alpine AS base
 
 
 
 
 
 
2
 
3
+ # Install dependencies only when needed
4
+ FROM base AS deps
5
+ # Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
6
+ RUN apk add --no-cache libc6-compat
7
  WORKDIR /app
8
 
9
+ # Install dependencies based on the preferred package manager
10
+ COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* ./
11
+ RUN \
12
+ if [ -f yarn.lock ]; then yarn --frozen-lockfile; \
13
+ elif [ -f package-lock.json ]; then npm ci --force; \
14
+ elif [ -f pnpm-lock.yaml ]; then yarn global add pnpm && pnpm i --frozen-lockfile; \
15
+ else echo "Lockfile not found." && exit 1; \
16
+ fi
17
+
18
+ # Uncomment the following lines if you want to use a secret at buildtime,
19
+ # for example to access your private npm packages
20
+ # RUN --mount=type=secret,id=HF_EXAMPLE_SECRET,mode=0444,required=true \
21
+ # $(cat /run/secrets/HF_EXAMPLE_SECRET)
22
+
23
+ # Rebuild the source code only when needed
24
  FROM base AS builder
25
+ WORKDIR /app
26
+ COPY --from=deps /app/node_modules ./node_modules
27
+ COPY . .
 
 
 
28
 
29
+ # Next.js collects completely anonymous telemetry data about general usage.
30
+ # Learn more here: https://nextjs.org/telemetry
31
+ # Uncomment the following line in case you want to disable telemetry during the build.
32
+ # ENV NEXT_TELEMETRY_DISABLED 1
33
 
34
+ # RUN yarn build
 
35
 
36
+ # If you use yarn, comment out this line and use the line above
37
+ RUN npm run build
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
+ # Automatically leverage output traces to reduce image size
53
+ # https://nextjs.org/docs/advanced-features/output-file-tracing
 
 
 
 
54
  COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
55
  COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
56
+ COPY --from=builder --chown=nextjs:nodejs /app/.next/cache ./.next/cache
57
+ # COPY --from=builder --chown=nextjs:nodejs /app/.next/cache/fetch-cache ./.next/cache/fetch-cache
58
 
 
 
 
 
59
  USER nextjs
60
 
61
+ EXPOSE 3000
 
 
 
 
 
62
 
63
+ ENV PORT 3000
64
 
65
+ CMD ["node", "server.js"]
66
+ SquareX Safe File Viewer
67
+