Spaces:
deepak191z
/
Runtime error

deepak191z commited on
Commit
d99f0d7
·
verified ·
1 Parent(s): b5794f9

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +50 -34
Dockerfile CHANGED
@@ -1,53 +1,69 @@
1
- # Base stage
2
- FROM oven/bun:alpine AS base
3
- WORKDIR /base
4
 
5
- # Install git to clone the repository
6
- RUN apk --no-cache add git
 
 
7
 
8
- # Clone the react-video-editor repository
9
- RUN git clone https://github.com/designcombo/react-video-editor.git ./
10
 
11
- # Install dependencies using bun
12
- RUN bun install --frozen-lockfile
 
 
13
 
14
- # Build stage
15
  FROM base AS builder
16
- WORKDIR /base
 
 
17
 
18
- # Build the application using bun
19
- RUN bun run build
20
 
21
- # Runner stage
22
- FROM builder AS runner
23
- WORKDIR /app
 
 
24
 
25
- # Set environment variables for production
 
 
 
 
 
26
  ENV NODE_ENV production
27
- ENV NEXT_TELEMETRY_DISABLED 1
28
 
29
- # Create a non-root user for better security
30
  RUN addgroup --system --gid 1001 nodejs
31
- RUN adduser --system --uid 1001 bunuser
32
 
33
- # Copy the public and build output files from the builder stage
34
- COPY --from=builder /base/public ./public
35
- COPY --from=builder /base/.next/standalone ./
36
- COPY --from=builder /base/.next/static ./.next/static
37
 
38
- # Set the correct permissions
39
- RUN mkdir .next
40
- RUN chown bunuser:nodejs .next
 
 
 
 
 
 
 
 
 
 
 
41
 
42
  # Expose the port
43
  EXPOSE 7860
44
 
45
- # Set environment variables for hostname and port
46
- ENV HOSTNAME 0.0.0.0
47
  ENV PORT 7860
48
 
49
- # Switch to the non-root user
50
- USER bunuser
51
-
52
- # Start the application with bun
53
- CMD ["bun", "dev"]
 
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
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 production build files
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
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
+ # Start the application
69
+ CMD ["pnpm", "run", "start"]