Download Dockerfile from cairan/j: direct link, hf CLI and curl.
- Browser
- Download file 3.31 kB
-
https://huggingface.co/spaces/cairan/j/resolve/main/Dockerfile
- Command line
-
hf download hf://spaces/cairan/j/Dockerfile
-
curl -L -o Dockerfile https://huggingface.co/spaces/cairan/j/resolve/main/Dockerfile
3.31 kB
| FROM jellyfin/jellyfin:latest | |
| USER root | |
| RUN apt-get update \ | |
| && apt-get install --yes --no-install-recommends nginx sqlite3 \ | |
| && rm -rf /var/lib/apt/lists/* \ | |
| && mkdir -p /cache /config /config-backup /data /tmp/nginx-client-body | |
| RUN cat >/etc/nginx/nginx.conf <<'EOF' | |
| events {} | |
| http { | |
| client_max_body_size 0; | |
| access_log /dev/stdout; | |
| error_log /dev/stderr warn; | |
| map $http_upgrade $connection_upgrade { | |
| default upgrade; | |
| '' close; | |
| } | |
| server { | |
| listen 7860; | |
| location / { | |
| proxy_pass http://127.0.0.1:8096; | |
| proxy_buffering off; | |
| proxy_connect_timeout 300s; | |
| proxy_http_version 1.1; | |
| proxy_read_timeout 300s; | |
| proxy_request_buffering off; | |
| proxy_send_timeout 300s; | |
| send_timeout 300s; | |
| proxy_set_header Connection $connection_upgrade; | |
| proxy_set_header Host $host; | |
| proxy_set_header Upgrade $http_upgrade; | |
| proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
| proxy_set_header X-Forwarded-Host $host; | |
| proxy_set_header X-Forwarded-Port 443; | |
| proxy_set_header X-Forwarded-Proto https; | |
| proxy_set_header X-Real-IP $remote_addr; | |
| } | |
| } | |
| } | |
| EOF | |
| RUN cat >/start.sh <<'EOF' | |
| #!/bin/sh | |
| set -eu | |
| backup_config() { | |
| echo "[backup] starting config backup" | |
| if [ ! -f /config/data/jellyfin.db ]; then | |
| echo "[backup] skip: database not found yet" | |
| return 0 | |
| fi | |
| TS="$(date -u +%Y%m%d-%H%M%S)" | |
| STAGE="/tmp/jellyfin-config-backup-$TS" | |
| OUT="/config-backup/jellyfin-config-$TS.tar.gz" | |
| rm -rf "$STAGE" | |
| mkdir -p "$STAGE" | |
| cp -a /config/. "$STAGE/" 2>/dev/null || true | |
| if [ -d /config/data ]; then | |
| find /config/data -type f -name "*.db" | while read -r DB; do | |
| REL="${DB#/config/}" | |
| mkdir -p "$STAGE/$(dirname "$REL")" | |
| echo "[backup] sqlite backup: $REL" | |
| sqlite3 "$DB" ".backup '$STAGE/$REL'" || echo "[backup] warning: failed to backup $DB" | |
| done | |
| fi | |
| tar -czf "$OUT" -C "$STAGE" . | |
| cp "$OUT" /config-backup/latest.tar.gz | |
| rm -rf "$STAGE" | |
| echo "[backup] done: $OUT" | |
| ls -1t /config-backup/jellyfin-config-*.tar.gz 2>/dev/null | tail -n +8 | xargs -r rm -f | |
| } | |
| restore_config() { | |
| if [ ! -f /config/data/jellyfin.db ] && [ -f /config-backup/latest.tar.gz ]; then | |
| echo "[restore] restoring config from /config-backup/latest.tar.gz" | |
| mkdir -p /config | |
| tar -xzf /config-backup/latest.tar.gz -C /config | |
| echo "[restore] done" | |
| else | |
| echo "[restore] no restore needed" | |
| fi | |
| } | |
| backup_loop() { | |
| sleep 600 | |
| while true; do | |
| backup_config || echo "[backup] backup failed" | |
| sleep 3600 | |
| done | |
| } | |
| restore_config | |
| /jellyfin/jellyfin \ | |
| --datadir /config \ | |
| --cachedir /cache \ | |
| --ffmpeg /usr/lib/jellyfin-ffmpeg/ffmpeg \ | |
| --service & | |
| JELLYFIN_PID=$! | |
| nginx -g 'daemon off;' & | |
| NGINX_PID=$! | |
| backup_loop & | |
| BACKUP_PID=$! | |
| trap 'echo "[shutdown] stopping"; backup_config || true; kill $JELLYFIN_PID $NGINX_PID $BACKUP_PID 2>/dev/null || true' TERM INT | |
| while kill -0 $JELLYFIN_PID 2>/dev/null && kill -0 $NGINX_PID 2>/dev/null; do | |
| sleep 2 | |
| done | |
| kill $JELLYFIN_PID $NGINX_PID $BACKUP_PID 2>/dev/null || true | |
| wait | |
| EOF | |
| RUN chmod +x /start.sh | |
| EXPOSE 7860 | |
| ENTRYPOINT [] | |
| CMD ["/start.sh"] |