Spaces:
Paused
Paused
| # Use Python 3.12-alpine as the base image | |
| FROM python:3.12-alpine | |
| # Set timezone (optional, but included for consistency) | |
| ENV TZ=Asia/Kolkata | |
| RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone | |
| # Install system dependencies | |
| RUN apk update && \ | |
| apk add --no-cache \ | |
| alpine-sdk \ | |
| python3-dev \ | |
| musl-dev \ | |
| linux-headers \ | |
| git \ | |
| curl \ | |
| wget \ | |
| jq \ | |
| xz \ | |
| mediainfo | |
| # Manual FFmpeg installation (preserved as requested) | |
| RUN wget -q https://johnvansickle.com/ffmpeg/builds/ffmpeg-git-amd64-static.tar.xz \ | |
| && wget -q https://johnvansickle.com/ffmpeg/builds/ffmpeg-git-amd64-static.tar.xz.md5 \ | |
| && md5sum -c ffmpeg-git-amd64-static.tar.xz.md5 \ | |
| && tar xf ffmpeg-git-amd64-static.tar.xz \ | |
| && mv ffmpeg-git-*-amd64-static/ffmpeg ffmpeg-git-*-amd64-static/ffprobe /usr/local/bin/ \ | |
| && rm -rf ffmpeg-git-* ffmpeg-git-amd64-static.tar.xz* | |
| # Install aria2c static binary | |
| RUN wget -q https://github.com/P3TERX/Aria2-Pro-Core/releases/download/1.36.0_2021.08.22/aria2-1.36.0-static-linux-amd64.tar.gz \ | |
| && tar -xf aria2-1.36.0-static-linux-amd64.tar.gz \ | |
| && mv aria2c /usr/local/bin/ \ | |
| && rm -rf aria2-1.36.0-static-linux-amd64.tar.gz aria2c | |
| # Create user with UID 1000 (Hugging Face requirement) | |
| RUN adduser -D -u 1000 user | |
| # Set environment variables for the non-root user | |
| ENV HOME=/home/user \ | |
| PATH=/home/user/.local/bin:$PATH | |
| # Set working directory (creates /home/user/app automatically) | |
| WORKDIR $HOME/app | |
| # (Optional) If you want to disable pip caching entirely, you can skip creating the cache directory. | |
| # Otherwise, you could fix its permissions—but here we opt to disable caching. | |
| RUN mkdir -p $HOME/.cache | |
| # Adjust ownership/permissions for the app directory (and /usr if needed) | |
| RUN chown -R 1000:0 $HOME/app $HOME/.cache /usr && \ | |
| chmod -R 777 $HOME/app /usr $HOME/.cache | |
| # Install PDM and project dependencies | |
| COPY pyproject.toml pdm.lock requirements.txt ./ | |
| RUN pip install --no-cache-dir --upgrade pip setuptools \ | |
| && pip install --no-cache-dir pdm \ | |
| && pip install --no-cache-dir -r requirements.txt | |
| # Copy application code | |
| COPY src . | |
| # Adjust ownership/permissions for the app directory | |
| RUN chown -R 1000:0 $HOME/app $HOME/.cache /usr && \ | |
| chmod -R 777 $HOME/app /usr $HOME/.cache | |
| # Expose port (if needed) | |
| EXPOSE 7860 | |
| # Command to run the application | |
| CMD ["sh", "-c", "python server.py & python main.py"] |