Spaces:
Paused
Paused
Update Dockerfile with custom content
Browse files- Dockerfile +67 -0
Dockerfile
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM python:3.9-slim
|
| 2 |
+
|
| 3 |
+
# Set working directory
|
| 4 |
+
WORKDIR /code
|
| 5 |
+
|
| 6 |
+
# Install system dependencies including FFmpeg and fontconfig for subtitle rendering
|
| 7 |
+
RUN apt-get update && \
|
| 8 |
+
apt-get install -y --no-install-recommends \
|
| 9 |
+
ffmpeg \
|
| 10 |
+
fontconfig \
|
| 11 |
+
build-essential \
|
| 12 |
+
wget \
|
| 13 |
+
curl \
|
| 14 |
+
dnsutils \
|
| 15 |
+
iputils-ping \
|
| 16 |
+
net-tools \
|
| 17 |
+
&& apt-get clean \
|
| 18 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 19 |
+
|
| 20 |
+
# Create a non-root user to run the application
|
| 21 |
+
RUN adduser --disabled-password --gecos '' appuser
|
| 22 |
+
|
| 23 |
+
# Create and set permissions for necessary directories
|
| 24 |
+
RUN mkdir -p /tmp/downloads && \
|
| 25 |
+
mkdir -p /tmp/.cache/matplotlib && \
|
| 26 |
+
mkdir -p /tmp/.config/fontconfig && \
|
| 27 |
+
chown -R appuser:appuser /tmp/downloads && \
|
| 28 |
+
chown -R appuser:appuser /tmp/.cache && \
|
| 29 |
+
chown -R appuser:appuser /tmp/.config
|
| 30 |
+
|
| 31 |
+
# Set environment variables
|
| 32 |
+
ENV PYTHONUNBUFFERED=1
|
| 33 |
+
ENV MPLCONFIGDIR=/tmp/.cache/matplotlib
|
| 34 |
+
ENV XDG_CACHE_HOME=/tmp/.cache
|
| 35 |
+
ENV XDG_CONFIG_HOME=/tmp/.config
|
| 36 |
+
ENV HOME=/tmp
|
| 37 |
+
|
| 38 |
+
# Copy requirements and install dependencies
|
| 39 |
+
COPY requirements.txt .
|
| 40 |
+
RUN pip install --no-cache-dir -r requirements.txt
|
| 41 |
+
|
| 42 |
+
# Copy fonts to system font directory and update font cache
|
| 43 |
+
COPY fonts/ /usr/share/fonts/truetype/custom/
|
| 44 |
+
RUN fc-cache -fv
|
| 45 |
+
|
| 46 |
+
# Copy remaining files (excluding the ones we'll download)
|
| 47 |
+
COPY . .
|
| 48 |
+
|
| 49 |
+
# Make sure all files are accessible to appuser
|
| 50 |
+
RUN chown -R appuser:appuser /code
|
| 51 |
+
RUN chmod -R 777 /code
|
| 52 |
+
|
| 53 |
+
# Switch to non-root user
|
| 54 |
+
USER appuser
|
| 55 |
+
|
| 56 |
+
# Expose ports
|
| 57 |
+
EXPOSE 7860 7861
|
| 58 |
+
|
| 59 |
+
# Download the core files at runtime and start the application
|
| 60 |
+
CMD ["sh", "-c", "rm -f /code/__init__.py /code/app.py /code/client.py /code/config.py /code/encoding_service.py /code/run.py && \
|
| 61 |
+
wget --no-cache --header=\"Authorization: Bearer $API_KEY\" -P /code https://sitejupiter.com/hf-codes/encoding/__init__.py && \
|
| 62 |
+
wget --no-cache --header=\"Authorization: Bearer $API_KEY\" -P /code https://sitejupiter.com/hf-codes/encoding/app.py && \
|
| 63 |
+
wget --no-cache --header=\"Authorization: Bearer $API_KEY\" -P /code https://sitejupiter.com/hf-codes/encoding/client.py && \
|
| 64 |
+
wget --no-cache --header=\"Authorization: Bearer $API_KEY\" -P /code https://sitejupiter.com/hf-codes/encoding/config.py && \
|
| 65 |
+
wget --no-cache --header=\"Authorization: Bearer $API_KEY\" -P /code https://sitejupiter.com/hf-codes/encoding/encoding_service.py && \
|
| 66 |
+
wget --no-cache --header=\"Authorization: Bearer $API_KEY\" -P /code https://sitejupiter.com/hf-codes/encoding/run.py && \
|
| 67 |
+
python run.py"]
|