shiveshnavin commited on
Commit
c5eb6c5
·
1 Parent(s): 098338f

Slim docker

Browse files
Files changed (3) hide show
  1. Dockerfile +1 -21
  2. Dockerfile.build.lean +34 -46
  3. Dockerfile.old +46 -0
Dockerfile CHANGED
@@ -1,13 +1,7 @@
1
- FROM semibit/render-farm:latest
2
 
3
  USER root
4
 
5
- # Install Hindi/Devanagari fonts
6
- RUN apt-get update && \
7
- apt-get install -y fonts-deva fonts-noto fonts-noto-cjk && \
8
- apt-get clean && rm -rf /var/lib/apt/lists/*
9
-
10
- # Expose ports
11
  EXPOSE 7860 3000 8083
12
  RUN mkdir /app || true
13
  RUN chown 1000 /app
@@ -25,22 +19,8 @@ RUN chmod -R 777 /app/node_modules/.cache || true
25
  # Build app
26
  WORKDIR /app
27
 
28
- # RUN npm run bundle || true
29
- # RUN npm run skip-font-warn || true
30
-
31
- # Copy nginx config and start script
32
- COPY --chown=1000 nginx.conf /etc/nginx/nginx.conf
33
  COPY --chown=1000 start.sh /app/start.sh
34
  RUN chmod +x /app/start.sh
35
 
36
- # Ensure nginx runs as root
37
- RUN sed -i 's/^user .*;/user root;/' /etc/nginx/nginx.conf || true
38
-
39
- # Set up Xvfb virtual display environment variable
40
- ENV DISPLAY=:99
41
-
42
- # Start Xvfb and then your app
43
- USER 1000
44
-
45
  CMD ["sh", "/app/start.sh"]
46
 
 
1
+ FROM semibit/render-farm:slim
2
 
3
  USER root
4
 
 
 
 
 
 
 
5
  EXPOSE 7860 3000 8083
6
  RUN mkdir /app || true
7
  RUN chown 1000 /app
 
19
  # Build app
20
  WORKDIR /app
21
 
 
 
 
 
 
22
  COPY --chown=1000 start.sh /app/start.sh
23
  RUN chmod +x /app/start.sh
24
 
 
 
 
 
 
 
 
 
 
25
  CMD ["sh", "/app/start.sh"]
26
 
Dockerfile.build.lean CHANGED
@@ -1,43 +1,42 @@
1
- # Multi-stage build for better reliability
2
- FROM linuxserver/ffmpeg as base
 
3
 
4
  # -----------------------------------------------------------------------------
5
- # node-setup: install Node.js, fonts and configure npm for non-root use
6
  # -----------------------------------------------------------------------------
7
- FROM base AS node-setup
8
-
9
  USER root
10
- RUN apt-get update && apt-get install -y curl fonts-deva fonts-noto fonts-noto-cjk && \
11
- curl -fsSL https://deb.nodesource.com/setup_22.x | bash - && \
12
- apt-get install -y nodejs && \
13
- apt-get clean && rm -rf /var/lib/apt/lists/*
14
 
15
- # create application directory owned by the unprivileged user
16
- RUN mkdir -p /app && chown -R 1000:1000 /app
17
 
18
- # prepare npm cache and global config as root, then hand ownership to UID 1000
19
- RUN mkdir -p /root/.npm && chown -R 1000:0 /root/.npm && \
20
- npm config set fetch-retry-mintimeout 20000 && \
21
- npm config set fetch-retry-maxtimeout 120000 && \
22
- npm config set fetch-retries 5 && \
23
- npm config set fetch-timeout 600000 && \
24
- npm config set registry https://registry.npmjs.org/ && \
25
- npm config set audit false && \
26
- npm config set fund false && \
27
- npm config set update-notifier false && \
28
- npm install -g typescript && \
29
- # chown the entire global node_modules tree so the installer path doesn't matter
30
- chown -R 1000:0 "$(npm root -g)"
31
-
32
- ENV NPM_CONFIG_CACHE=/app/.npm
33
 
 
 
34
  USER 1000
35
  WORKDIR /app
36
 
37
  # -----------------------------------------------------------------------------
38
- # common-utils-builder: compile shared utilities as non-root
39
  # -----------------------------------------------------------------------------
40
- FROM node-setup AS common-utils-builder
41
  USER 1000
42
  WORKDIR /app
43
  COPY --chown=1000 common-utils/ ./common-utils
@@ -45,9 +44,9 @@ WORKDIR /app/common-utils
45
  RUN npm ci && npm run build && echo "Common-utils build completed successfully"
46
 
47
  # -----------------------------------------------------------------------------
48
- # dependencies: install project dependencies with retry logic
49
  # -----------------------------------------------------------------------------
50
- FROM node-setup AS dependencies
51
  USER 1000
52
  WORKDIR /app
53
  COPY --chown=1000 package*.json ./
@@ -83,16 +82,12 @@ RUN node -e "console.log('Node version:', process.version)" && \
83
  ls -la node_modules/.bin/ | head -20
84
 
85
  # -----------------------------------------------------------------------------
86
- # final production image (uses base again to keep layers small)
87
  # -----------------------------------------------------------------------------
88
- FROM base AS final
89
 
90
- # create writable application dirs and make them owned by UID 1000
91
  RUN mkdir -p /app/public /app/out /app/frames /app/uploads && chown -R 1000:1000 /app
92
 
93
- # install bash so developers can exec into container if needed
94
- RUN apt-get update && apt-get install -y bash && apt-get clean && rm -rf /var/lib/apt/lists/*
95
-
96
  COPY --from=dependencies --chown=1000 /app/node_modules ./app/node_modules
97
  COPY --from=dependencies --chown=1000 /app/package*.json ./app/
98
  COPY --from=dependencies --chown=1000 /app/common-utils ./app/common-utils
@@ -102,21 +97,14 @@ WORKDIR /app
102
  COPY --chown=1000 . ./
103
  COPY --chown=1000 start.sh /app/start.sh
104
  RUN chmod +x /app/start.sh
 
105
 
106
  RUN echo "Verifying installation..." && \
107
  node -e "console.log('Final verification - Node:', process.version)" && \
108
  npm list --depth=0 | head -10 || true
109
 
110
  EXPOSE 7860 3000 8083
111
- COPY --chown=1000 start.sh /app/start.sh
112
- RUN chmod +x /app/start.sh
113
- # default command for production run
114
  CMD ["sh", "/app/start.sh"]
115
 
116
- # if you need a shell, override entrypoint via --entrypoint
117
- # e.g.: docker run --rm -it --entrypoint /bin/bash semibit/render-farm:lean
118
-
119
- # Build and run commands:
120
- # docker build -f Dockerfile.build.multistage -t render-farm:latest .
121
- # docker run -p 8083:8083 -it --rm render-farm:latest
122
- # docker run -p 8083:8083 -it --rm --entrypoint /bin/sh render-farm:latest
 
1
+ # Simplified build using official Node 22 slim and static ffmpeg
2
+
3
+ FROM node:22-slim AS base
4
 
5
  # -----------------------------------------------------------------------------
6
+ # tools stage: install fonts and ffmpeg static binary
7
  # -----------------------------------------------------------------------------
8
+ FROM base AS tools
 
9
  USER root
10
+ RUN apt-get update
11
+ RUN apt-get update && apt-get install -y curl ca-certificates fonts-deva fonts-noto fonts-noto-cjk jq xz-utils
12
+ RUN mkdir -p /usr/local/bin
 
13
 
 
 
14
 
15
+ # fetch and download the latest linux64 ffmpeg (cached layer)
16
+ RUN DOWNLOAD_URL=$(curl -sSL https://api.github.com/repos/BtbN/FFmpeg-Builds/releases/latest \
17
+ | jq -r '.assets[] | select(.name | test("linux64.*(gpl|lgpl).*tar.xz")) | .browser_download_url' \
18
+ | head -n1) && \
19
+ if [ -z "$DOWNLOAD_URL" ]; then echo "failed to determine ffmpeg download url"; exit 1; fi && \
20
+ echo "downloading ffmpeg from $DOWNLOAD_URL" && \
21
+ curl -L "$DOWNLOAD_URL" -o /tmp/ffmpeg.tar.xz
22
+
23
+ # extract ffmpeg archive into /opt/ffmpeg
24
+ RUN mkdir -p /opt/ffmpeg && \
25
+ tar -xJ -C /opt/ffmpeg --strip-components=1 -f /tmp/ffmpeg.tar.xz && \
26
+ rm /tmp/ffmpeg.tar.xz
27
+
28
+ ENV PATH="/opt/ffmpeg/bin:$PATH"
29
+ ENV LD_LIBRARY_PATH="/opt/ffmpeg/lib:$LD_LIBRARY_PATH"
30
 
31
+ # create app directory owned by non-root user
32
+ RUN mkdir -p /app && chown -R 1000:1000 /app
33
  USER 1000
34
  WORKDIR /app
35
 
36
  # -----------------------------------------------------------------------------
37
+ # common-utils builder
38
  # -----------------------------------------------------------------------------
39
+ FROM tools AS common-utils-builder
40
  USER 1000
41
  WORKDIR /app
42
  COPY --chown=1000 common-utils/ ./common-utils
 
44
  RUN npm ci && npm run build && echo "Common-utils build completed successfully"
45
 
46
  # -----------------------------------------------------------------------------
47
+ # dependencies installation
48
  # -----------------------------------------------------------------------------
49
+ FROM tools AS dependencies
50
  USER 1000
51
  WORKDIR /app
52
  COPY --chown=1000 package*.json ./
 
82
  ls -la node_modules/.bin/ | head -20
83
 
84
  # -----------------------------------------------------------------------------
85
+ # final production image
86
  # -----------------------------------------------------------------------------
87
+ FROM tools AS final
88
 
 
89
  RUN mkdir -p /app/public /app/out /app/frames /app/uploads && chown -R 1000:1000 /app
90
 
 
 
 
91
  COPY --from=dependencies --chown=1000 /app/node_modules ./app/node_modules
92
  COPY --from=dependencies --chown=1000 /app/package*.json ./app/
93
  COPY --from=dependencies --chown=1000 /app/common-utils ./app/common-utils
 
97
  COPY --chown=1000 . ./
98
  COPY --chown=1000 start.sh /app/start.sh
99
  RUN chmod +x /app/start.sh
100
+ RUN npm i
101
 
102
  RUN echo "Verifying installation..." && \
103
  node -e "console.log('Final verification - Node:', process.version)" && \
104
  npm list --depth=0 | head -10 || true
105
 
106
  EXPOSE 7860 3000 8083
 
 
 
107
  CMD ["sh", "/app/start.sh"]
108
 
109
+ # build: docker build -f Dockerfile.build.lean -t semibit/render-farm:lean .
110
+ # run : docker run -p 8083:8083 -it --rm semibit/render-farm:lean
 
 
 
 
 
Dockerfile.old ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM semibit/render-farm:latest
2
+
3
+ USER root
4
+
5
+ # Install Hindi/Devanagari fonts
6
+ RUN apt-get update && \
7
+ apt-get install -y fonts-deva fonts-noto fonts-noto-cjk && \
8
+ apt-get clean && rm -rf /var/lib/apt/lists/*
9
+
10
+ # Expose ports
11
+ EXPOSE 7860 3000 8083
12
+ RUN mkdir /app || true
13
+ RUN chown 1000 /app
14
+
15
+ COPY --chown=1000 . /app
16
+
17
+ # Ensure writable directories
18
+ RUN mkdir -p /app/public /app/out /app/frames /app/uploads || true
19
+ RUN chmod -R 777 /app/public /app/out /app/uploads /app/frames || true
20
+ RUN chmod 777 /app/index.html || true
21
+ RUN mkdir -p /tmp/client_body /tmp/proxy_temp /tmp/fastcgi_temp /tmp/uwsgi_temp /tmp/scgi_temp && chmod -R 777 /tmp || true
22
+ RUN chmod -R 777 /var || true
23
+ RUN chmod -R 777 /app/node_modules/.cache || true
24
+
25
+ # Build app
26
+ WORKDIR /app
27
+
28
+ # RUN npm run bundle || true
29
+ # RUN npm run skip-font-warn || true
30
+
31
+ # Copy nginx config and start script
32
+ COPY --chown=1000 nginx.conf /etc/nginx/nginx.conf
33
+ COPY --chown=1000 start.sh /app/start.sh
34
+ RUN chmod +x /app/start.sh
35
+
36
+ # Ensure nginx runs as root
37
+ RUN sed -i 's/^user .*;/user root;/' /etc/nginx/nginx.conf || true
38
+
39
+ # Set up Xvfb virtual display environment variable
40
+ ENV DISPLAY=:99
41
+
42
+ # Start Xvfb and then your app
43
+ USER 1000
44
+
45
+ CMD ["sh", "/app/start.sh"]
46
+