shiveshnavin commited on
Commit
7e81bd7
·
1 Parent(s): 2e29670

Update dockerfile

Browse files
Files changed (5) hide show
  1. Dockerfile +1 -25
  2. Dockerfile.build.multistage +6 -11
  3. nginx.conf +15 -0
  4. proxy-renderer.js +4 -4
  5. routes.js +7 -0
Dockerfile CHANGED
@@ -1,31 +1,7 @@
1
  FROM semibit/render-farm:latest
2
 
3
- # Install required packages including Xvfb and xz-utils
4
  USER root
5
- RUN apt-get update && \
6
- apt-get install -y \
7
- bash \
8
- git git-lfs \
9
- wget curl procps \
10
- htop vim nano \
11
- xz-utils \
12
- xvfb x11-utils && \
13
- rm -rf /var/lib/apt/lists/*
14
-
15
- # Install FFmpeg 8 from static build
16
- RUN wget https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-amd64-static.tar.xz && \
17
- tar -xf ffmpeg-release-amd64-static.tar.xz && \
18
- mv ffmpeg-*-amd64-static/ffmpeg /usr/local/bin/ffmpeg && \
19
- mv ffmpeg-*-amd64-static/ffprobe /usr/local/bin/ffprobe && \
20
- chmod +x /usr/local/bin/ffmpeg /usr/local/bin/ffprobe && \
21
- rm -rf ffmpeg-* && \
22
- ln -sf /usr/local/bin/ffmpeg /usr/bin/ffmpeg && \
23
- ln -sf /usr/local/bin/ffprobe /usr/bin/ffprobe && \
24
- ffmpeg -version
25
-
26
-
27
- # Install nginx
28
- RUN apt-get update && apt-get install -y nginx wget && apt-get clean && rm -rf /var/lib/apt/lists/*
29
 
30
  # Expose ports
31
  EXPOSE 7860 3000 8083
 
1
  FROM semibit/render-farm:latest
2
 
3
+ # All system packages (xvfb, nginx, git-lfs, etc.) and FFmpeg are now installed in the base image
4
  USER root
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
 
6
  # Expose ports
7
  EXPOSE 7860 3000 8083
Dockerfile.build.multistage CHANGED
@@ -17,14 +17,13 @@ RUN apt-get update && apt-get install -y \
17
  libpango-1.0-0 \
18
  libcairo2 \
19
  libcups2 \
20
- wget \
21
- procps \
22
- htop \
23
- vim \
24
- nano \
25
- curl \
26
  xz-utils \
27
- git-lfs \
 
28
  ca-certificates \
29
  && rm -rf /var/lib/apt/lists/* \
30
  && apt-get clean
@@ -101,10 +100,6 @@ RUN node -e "console.log('Node version:', process.version)" && \
101
  # Final production stage
102
  FROM base as final
103
 
104
- # Install nginx for the final image
105
- RUN apt-get update && apt-get install -y nginx && \
106
- apt-get clean && rm -rf /var/lib/apt/lists/*
107
-
108
  # Create app directory and set permissions
109
  RUN mkdir -p /app /app/public /app/out /app/frames /app/uploads && chown -R 1000:1000 /app
110
 
 
17
  libpango-1.0-0 \
18
  libcairo2 \
19
  libcups2 \
20
+ bash \
21
+ git git-lfs \
22
+ wget curl procps \
23
+ htop vim nano \
 
 
24
  xz-utils \
25
+ xvfb x11-utils \
26
+ nginx \
27
  ca-certificates \
28
  && rm -rf /var/lib/apt/lists/* \
29
  && apt-get clean
 
100
  # Final production stage
101
  FROM base as final
102
 
 
 
 
 
103
  # Create app directory and set permissions
104
  RUN mkdir -p /app /app/public /app/out /app/frames /app/uploads && chown -R 1000:1000 /app
105
 
nginx.conf CHANGED
@@ -61,6 +61,21 @@ http {
61
  proxy_buffering off;
62
  }
63
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
64
 
65
  #/api/jobs and /api/jobs/** -> internal 8083
66
  location ^~ /api/jobs {
 
61
  proxy_buffering off;
62
  }
63
 
64
+ #/api/jobs and /api/jobs/** -> internal 8083
65
+ location ^~ /api/v2 {
66
+ proxy_pass http://renderer$request_uri;
67
+ proxy_http_version 1.1;
68
+ proxy_set_header Host $host;
69
+ proxy_set_header X-Real-IP $remote_addr;
70
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
71
+ proxy_set_header X-Forwarded-Proto $scheme;
72
+
73
+ # WebSocket headers
74
+ proxy_set_header Upgrade $http_upgrade;
75
+ proxy_set_header Connection $connection_upgrade;
76
+
77
+ proxy_buffering off;
78
+ }
79
 
80
  #/api/jobs and /api/jobs/** -> internal 8083
81
  location ^~ /api/jobs {
proxy-renderer.js CHANGED
@@ -15,7 +15,7 @@ let cmd = `npm run preview`;
15
  let childProcess = null;
16
  var ffmpegLocation = os.platform() === 'win32' ? 'ffmpeg.exe' : 'ffmpeg';
17
 
18
- function startChildProcess() {
19
  if (childProcess && !childProcess.killed) {
20
  return childProcess;
21
  }
@@ -85,7 +85,7 @@ export const renderProxy = async (outFile, jobId, options, controller) => {
85
  controller);
86
  break;
87
  } catch (error) {
88
- console.error(`Render chunk failed. Retrying... (${retryAttemptsLeft - 1} attempts left)`);
89
  if (controller._proxy_stopped) {
90
  retryAttemptsLeft = 0
91
  }
@@ -255,10 +255,10 @@ function renderChunk(
255
  const cleanupHandlers = (() => {
256
  try {
257
  if (proc && proc.stdout && stdoutHandler) proc.stdout.removeListener('data', stdoutHandler);
258
- } catch (e) { }
259
  try {
260
  if (proc && proc.stderr && stderrHandler) proc.stderr.removeListener('data', stderrHandler);
261
- } catch (e) { }
262
  }).bind(this);
263
 
264
  const stdoutHandler = ((chunk) => {
 
15
  let childProcess = null;
16
  var ffmpegLocation = os.platform() === 'win32' ? 'ffmpeg.exe' : 'ffmpeg';
17
 
18
+ export function startChildProcess() {
19
  if (childProcess && !childProcess.killed) {
20
  return childProcess;
21
  }
 
85
  controller);
86
  break;
87
  } catch (error) {
88
+ console.error(`Render chunk failed. Retrying... (${retryAttemptsLeft - 1} attempts left)`);
89
  if (controller._proxy_stopped) {
90
  retryAttemptsLeft = 0
91
  }
 
255
  const cleanupHandlers = (() => {
256
  try {
257
  if (proc && proc.stdout && stdoutHandler) proc.stdout.removeListener('data', stdoutHandler);
258
+ } catch (e) { }
259
  try {
260
  if (proc && proc.stderr && stderrHandler) proc.stderr.removeListener('data', stderrHandler);
261
+ } catch (e) { }
262
  }).bind(this);
263
 
264
  const stdoutHandler = ((chunk) => {
routes.js CHANGED
@@ -15,6 +15,7 @@ const { Utils, PerformanceRecorder, FileUploader, Vault } = pkg;
15
  import bodyParser from 'body-parser';
16
  import { existsSync } from 'fs';
17
  import { applyPluginsPostrender, applyPluginsPrerender } from './server-plugins/apply.js';
 
18
 
19
  const RenderRouter = Router();
20
  const __filename = fileURLToPath(import.meta.url);
@@ -109,6 +110,12 @@ RenderRouter.get('/api/jobs/:jobId', async (req, res) => {
109
  }
110
  });
111
 
 
 
 
 
 
 
112
  RenderRouter.post('/api/render-sync', async (req, res) => {
113
  const jobId = req.body.jobId || Utils.generateUID(req.body.fileUrl);
114
  // delete all jobs that finished more than 24 hours ago
 
15
  import bodyParser from 'body-parser';
16
  import { existsSync } from 'fs';
17
  import { applyPluginsPostrender, applyPluginsPrerender } from './server-plugins/apply.js';
18
+ import { startChildProcess } from './proxy-renderer.js';
19
 
20
  const RenderRouter = Router();
21
  const __filename = fileURLToPath(import.meta.url);
 
110
  }
111
  });
112
 
113
+
114
+ RenderRouter.post('/api/v1/start-preview', async (req, res) => {
115
+ startChildProcess()
116
+ res.status(200).json({ message: 'Starting...' });
117
+ });
118
+
119
  RenderRouter.post('/api/render-sync', async (req, res) => {
120
  const jobId = req.body.jobId || Utils.generateUID(req.body.fileUrl);
121
  // delete all jobs that finished more than 24 hours ago