akborana4 commited on
Commit
a0b5ce9
·
verified ·
1 Parent(s): 06ed0b5

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +8 -15
Dockerfile CHANGED
@@ -11,14 +11,8 @@ RUN npm run build
11
  FROM node:18-alpine AS server
12
  WORKDIR /app/server
13
 
14
- # Core packages: python, pip (for build-time), ffmpeg, curl, ca-certificates
15
  RUN apk add --no-cache python3 py3-pip ffmpeg curl ca-certificates
16
 
17
- # Try multiple build-time installation methods (preferred: apk -> binary -> pip):
18
- # 1) Try Alpine package yt-dlp
19
- # 2) Try Alpine package yt-dlp-core
20
- # 3) Download standalone binary from GitHub releases to /usr/local/bin
21
- # 4) As last resort, pip install (at build time) to system (safer than runtime pip)
22
  RUN set -eux; \
23
  if apk add --no-cache yt-dlp; then \
24
  echo "installed yt-dlp from apk"; \
@@ -31,27 +25,26 @@ RUN set -eux; \
31
  echo "falling back to pip install yt-dlp at build time"; \
32
  python3 -m pip install --no-cache-dir -U yt-dlp; \
33
  fi; \
34
- # sanity check (ignore non-zero if command absent)
35
  command -v yt-dlp >/dev/null 2>&1 && yt-dlp --version || true
36
 
37
- # Install node server deps
38
  COPY server/package.json ./
39
  RUN npm install
40
  COPY server/ ./
41
 
42
- # Bring in client build artifacts
43
  RUN mkdir -p ../client/dist
44
  COPY --from=client /app/client/dist ../client/dist
45
 
46
- # environment
47
  ENV NODE_ENV=production
48
  ENV PORT=3000
49
 
50
- # Start script:
51
- # - Try to download latest yt-dlp binary to /tmp (writable on HF). If successful use it.
52
- # - Otherwise use installed system yt-dlp (from apk/pip/binary at build time).
53
- # - If none present, log a clear message and continue (optional: exit nonzero to fail early).
54
- COPY start.sh /usr/local/bin/start.sh
 
 
 
55
  RUN chmod +x /usr/local/bin/start.sh
56
 
57
  EXPOSE 3000
 
11
  FROM node:18-alpine AS server
12
  WORKDIR /app/server
13
 
 
14
  RUN apk add --no-cache python3 py3-pip ffmpeg curl ca-certificates
15
 
 
 
 
 
 
16
  RUN set -eux; \
17
  if apk add --no-cache yt-dlp; then \
18
  echo "installed yt-dlp from apk"; \
 
25
  echo "falling back to pip install yt-dlp at build time"; \
26
  python3 -m pip install --no-cache-dir -U yt-dlp; \
27
  fi; \
 
28
  command -v yt-dlp >/dev/null 2>&1 && yt-dlp --version || true
29
 
 
30
  COPY server/package.json ./
31
  RUN npm install
32
  COPY server/ ./
33
 
 
34
  RUN mkdir -p ../client/dist
35
  COPY --from=client /app/client/dist ../client/dist
36
 
 
37
  ENV NODE_ENV=production
38
  ENV PORT=3000
39
 
40
+ # Put start script directly into image so no external COPY is required
41
+ RUN cat > /usr/local/bin/start.sh <<'SH'\n\
42
+ #!/bin/sh\n\
43
+ set -eu\n\
44
+ TMP_BIN=\"/tmp/yt-dlp\"\n\
45
+ SYS_BIN=\"$(command -v yt-dlp 2>/dev/null || true)\"\n\
46
+ echo \"startup: checking yt-dlp...\"\n\
47
+ if curl -fsSL -o \"$TMP_BIN\" \"https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp\"; then\n chmod +x \"$TMP_BIN\" || true\n YTDLP=\"$TMP_BIN\"\n echo \"Using downloaded yt-dlp from $TMP_BIN\"\nelse\n if [ -n \"$SYS_BIN\" ]; then\n YTDLP=\"$SYS_BIN\"\n echo \"Using system yt-dlp at $SYS_BIN\"\n else\n echo \"Warning: yt-dlp not found (neither system install nor /tmp download).\"\n YTDLP=\"\"\n fi\nfi\nif [ -n \"$YTDLP\" ]; then\n echo \"yt-dlp version:\"\n \"$YTDLP\" --version || true\nfi\nexport YTDLP_BIN=\"$YTDLP\"\nif [ -x \"$TMP_BIN\" ]; then\n export PATH=\"/tmp:$PATH\"\nfi\nexec npm start\nSH
48
  RUN chmod +x /usr/local/bin/start.sh
49
 
50
  EXPOSE 3000