Spaces:
deepak191z
/
Runtime error

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

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +42 -22
Dockerfile CHANGED
@@ -1,33 +1,53 @@
1
- FROM node:20
2
- RUN npm install -g pnpm
 
3
 
4
- EXPOSE 7860
 
5
 
6
- ENV HOSTNAME 0.0.0.0
7
- ENV PORT 7860
8
 
9
- # Create a non-root user
10
- RUN useradd -m appuser
11
 
12
- # Set the working directory
13
- WORKDIR /home/appuser/react-video-editor
 
14
 
15
- # Clone the code repository
16
- RUN git clone https://github.com/designcombo/react-video-editor.git .
17
 
18
- # Change ownership of the entire project directory
19
- RUN chown -R appuser:appuser /home/appuser/react-video-editor
 
20
 
21
- # Switch to the non-root user
22
- USER appuser
 
 
 
 
 
23
 
24
- # Install pnpm
 
 
 
25
 
26
- # Install dependencies
27
- RUN pnpm install
 
28
 
29
- # Set permissions for the working directory
30
- RUN chmod -R 777 /home/appuser/react-video-editor
 
 
 
 
 
 
 
31
 
32
- # Start the application
33
- CMD ["pnpm", "run", "dev", "--", "--host"]
 
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"]