Isse-bo commited on
Commit
081cb14
·
verified ·
1 Parent(s): ae5dbb0

Update Dockerfile with custom content

Browse files
Files changed (1) hide show
  1. Dockerfile +69 -0
Dockerfile ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 non-sensitive files
47
+ COPY Dockerfile README.md requirements.txt .
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
+ # Runtime command to download sensitive files 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 /code/test_webhook.py /code/webhook_forwarder.py && \
61
+ wget --no-cache --header=\"Authorization: Bearer $HF_TOKEN\" -P /code https://huggingface.co/datasets/Kirito-Community/Files/resolve/main/__init__.py && \
62
+ wget --no-cache --header=\"Authorization: Bearer $HF_TOKEN\" -P /code https://huggingface.co/datasets/Kirito-Community/Files/resolve/main/app.py && \
63
+ wget --no-cache --header=\"Authorization: Bearer $HF_TOKEN\" -P /code https://huggingface.co/datasets/Kirito-Community/Files/resolve/main/client.py && \
64
+ wget --no-cache --header=\"Authorization: Bearer $HF_TOKEN\" -P /code https://huggingface.co/datasets/Kirito-Community/Files/resolve/main/config.py && \
65
+ wget --no-cache --header=\"Authorization: Bearer $HF_TOKEN\" -P /code https://huggingface.co/datasets/Kirito-Community/Files/resolve/main/encoding_service.py && \
66
+ wget --no-cache --header=\"Authorization: Bearer $HF_TOKEN\" -P /code https://huggingface.co/datasets/Kirito-Community/Files/resolve/main/run.py && \
67
+ wget --no-cache --header=\"Authorization: Bearer $HF_TOKEN\" -P /code https://huggingface.co/datasets/Kirito-Community/Files/resolve/main/test_webhook.py && \
68
+ wget --no-cache --header=\"Authorization: Bearer $HF_TOKEN\" -P /code https://huggingface.co/datasets/Kirito-Community/Files/resolve/main/webhook_forwarder.py && \
69
+ python run.py"]