Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files1234567891011121314151617181920212223242526272829303132333435363738# syntax=docker/dockerfile:1FROM node:22-slim# git để clone repo, pnpm qua corepackRUN apt-get update \&& apt-get install -y --no-install-recommends git ca-certificates \&& rm -rf /var/lib/apt/lists/* \&& corepack enable# HF Space chạy container bằng user id 1000 (user "node" trong image này là 1000)RUN mkdir -p /app && chown node:node /appUSER nodeWORKDIR /app# Lấy source và cài dependencies (bỏ qua script như husky)RUN git clone --depth 1 https://github.com/awerks/stremio-double-subtitles.git . \&& pnpm install --prod --ignore-scripts# Script khởi động: chạy app ở 53100 và proxy 7860 -> 53100RUN cat <<'EOF' > /app/hf-start.sh#!/bin/shPORT=53100 pnpm start &exec node -e "const net = require('net');net.createServer((c) => {const s = net.connect(53100, '127.0.0.1');c.pipe(s).pipe(c);s.on('error', () => c.destroy());c.on('error', () => s.destroy());}).listen(7860, '0.0.0.0');"EOFRUN chmod +x /app/hf-start.shENV NODE_ENV=productionEXPOSE 7860CMD ["/app/hf-start.sh"]123456789101112131415161718192021222324252627282930# Sử dụng Python 3.11 slim nhẹ và ổn địnhFROM python:3.11-slim# Thiết lập biến môi trường tối ưu cho PythonENV PYTHONDONTWRITEBYTECODE=1 \PYTHONUNBUFFERED=1 \PORT=7860# Tạo người dùng non-root với UID 1000 theo yêu cầu bắt buộc của Hugging Face SpacesRUN useradd -m -u 1000 user# Chuyển sang thư mục làm việc của userWORKDIR /home/user/app# Cài đặt các thư viện phụ thuộc trước để tận dụng Docker Layer CacheCOPY --chown=user:user requirements.txt .RUN pip install --no-cache-dir --upgrade pip && \pip install --no-cache-dir -r requirements.txt# Sao chép toàn bộ mã nguồn vào container với quyền sở hữu của user (UID 1000)COPY --chown=user:user . .# Chuyển sang người dùng non-rootUSER user# Mở cổng 7860 mặc định của Hugging Face SpacesEXPOSE 7860# Khởi chạy FastAPI Proxy Server bằng Uvicorn trên cổng 7860CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
Dockerfile+28-36