Spaces:
deepak191z
/
Runtime error

File size: 1,615 Bytes
d99f0d7
 
e5e68b3
d99f0d7
 
 
 
e5e68b3
d99f0d7
d7b824b
d99f0d7
 
 
 
7510967
d99f0d7
b5794f9
d99f0d7
 
 
7510967
d99f0d7
 
7510967
d99f0d7
 
 
 
 
7510967
d99f0d7
 
 
 
 
 
b5794f9
 
d99f0d7
b5794f9
d99f0d7
7510967
d99f0d7
 
b29824e
d99f0d7
 
 
 
 
 
 
 
 
 
 
 
 
 
7510967
b5794f9
 
 
d99f0d7
 
b5794f9
 
d99f0d7
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# Base stage with Node.js
FROM node:20-slim AS base

# Setup environment for pnpm
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN corepack enable

WORKDIR /app

# Install sharp dependencies in a separate stage
FROM base AS sharp
# Install sharp for production
RUN pnpm add sharp

# Install dependencies and build the project
FROM base AS builder
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN corepack enable

# Install Git to clone the repository
RUN apt update && apt-get install git -y

# Clone the repository (you can replace this with a COPY if local)
RUN git clone https://github.com/designcombo/react-video-editor.git .

# Install the project's dependencies
RUN pnpm install

# Build the application
RUN pnpm run build

# Production stage
FROM base AS runner
WORKDIR /app
ENV NODE_ENV production

# Create non-root user for security
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs

# Copy the public folder from the builder stage
COPY --from=builder /app/public ./public

# Set correct permissions for prerender cache
RUN mkdir -p .next/cache
RUN chown -R nextjs:nodejs .next
RUN chmod -R 777 .next/cache

# Copy the production build files
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static

# Copy node_modules from the sharp stage
COPY --from=sharp /app/node_modules ./node_modules

# Switch to non-root user
USER nextjs

# Expose the port
EXPOSE 7860

# Set environment variables
ENV HOSTNAME "0.0.0.0"
ENV PORT 7860

# Start the application
CMD ["pnpm", "run", "start"]