Spaces:
Runtime error
Runtime error
Update Dockerfile
Browse files- Dockerfile +50 -34
Dockerfile
CHANGED
@@ -1,53 +1,69 @@
|
|
1 |
-
# Base stage
|
2 |
-
FROM
|
3 |
-
WORKDIR /base
|
4 |
|
5 |
-
#
|
6 |
-
|
|
|
|
|
7 |
|
8 |
-
|
9 |
-
RUN git clone https://github.com/designcombo/react-video-editor.git ./
|
10 |
|
11 |
-
# Install dependencies
|
12 |
-
|
|
|
|
|
13 |
|
14 |
-
#
|
15 |
FROM base AS builder
|
16 |
-
|
|
|
|
|
17 |
|
18 |
-
#
|
19 |
-
RUN
|
20 |
|
21 |
-
#
|
22 |
-
|
23 |
-
|
|
|
|
|
24 |
|
25 |
-
#
|
|
|
|
|
|
|
|
|
|
|
26 |
ENV NODE_ENV production
|
27 |
-
ENV NEXT_TELEMETRY_DISABLED 1
|
28 |
|
29 |
-
# Create
|
30 |
RUN addgroup --system --gid 1001 nodejs
|
31 |
-
RUN adduser --system --uid 1001
|
32 |
|
33 |
-
# Copy the public
|
34 |
-
COPY --from=builder /
|
35 |
-
COPY --from=builder /base/.next/standalone ./
|
36 |
-
COPY --from=builder /base/.next/static ./.next/static
|
37 |
|
38 |
-
# Set
|
39 |
-
RUN mkdir .next
|
40 |
-
RUN chown
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
|
42 |
# Expose the port
|
43 |
EXPOSE 7860
|
44 |
|
45 |
-
# Set environment variables
|
46 |
-
ENV HOSTNAME 0.0.0.0
|
47 |
ENV PORT 7860
|
48 |
|
49 |
-
#
|
50 |
-
|
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"]
|
|
|
|
|
|