MostlyK commited on
Commit
de4059f
·
1 Parent(s): 0111a48

HF docker permission fixes

Browse files
Files changed (1) hide show
  1. Dockerfile +19 -7
Dockerfile CHANGED
@@ -2,8 +2,14 @@ FROM python:3.10-slim
2
 
3
  ENV DEBIAN_FRONTEND=noninteractive
4
  ENV PYTHONUNBUFFERED=1
 
 
 
 
 
 
 
5
 
6
- # (ffmpeg, latexmk, texlive-full, libcairo2-dev, pkg-config)
7
  RUN apt-get update && apt-get install -y --no-install-recommends \
8
  ffmpeg \
9
  latexmk \
@@ -18,20 +24,26 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
18
 
19
  WORKDIR /app
20
 
21
- COPY requirements.txt .
22
 
 
 
23
  RUN pip install --no-cache-dir --upgrade pip && \
24
  pip install --no-cache-dir -r requirements.txt
25
 
26
- COPY src/ ./src/
 
 
 
 
27
 
28
- RUN mkdir -p media/videos/generated_video/1080p60 media/Tex media/texts media/images
29
 
30
  EXPOSE 7860
31
- #streamlit checks
32
  HEALTHCHECK --interval=15s --timeout=5s --start-period=30s \
33
- CMD curl --fail http://localhost:8501/_stcore/health || exit 1
34
 
35
  # Pass GEMINI_API_KEY as an environment variable during `docker run`
36
- # Example: docker run -p 8501:8501 -e GEMINI_API_KEY='your_api_key' manimator-image
37
  CMD ["streamlit", "run", "src/app.py", "--server.port=7860", "--server.address=0.0.0.0"]
 
2
 
3
  ENV DEBIAN_FRONTEND=noninteractive
4
  ENV PYTHONUNBUFFERED=1
5
+ ENV XDG_CACHE_HOME=/app/.cache
6
+ ENV PIP_CACHE_DIR=/app/.cache/pip
7
+ ENV MPLCONFIGDIR=/app/.cache/matplotlib
8
+ ENV HF_HOME=/app/.cache/huggingface
9
+
10
+ RUN groupadd --gid 1000 appuser && \
11
+ useradd --uid 1000 --gid 1000 --create-home --shell /bin/bash appuser
12
 
 
13
  RUN apt-get update && apt-get install -y --no-install-recommends \
14
  ffmpeg \
15
  latexmk \
 
24
 
25
  WORKDIR /app
26
 
27
+ COPY --chown=appuser:appuser requirements.txt .
28
 
29
+ # Install Python dependencies as root (some might need system access)
30
+ # but use the user-writable pip cache dir
31
  RUN pip install --no-cache-dir --upgrade pip && \
32
  pip install --no-cache-dir -r requirements.txt
33
 
34
+ COPY --chown=appuser:appuser src/ ./src/
35
+
36
+ RUN mkdir -p /app/.cache/pip /app/.cache/matplotlib /app/.cache/huggingface \
37
+ media/videos/generated_video/1080p60 media/Tex media/texts media/images && \
38
+ chown -R appuser:appuser /app
39
 
40
+ USER appuser
41
 
42
  EXPOSE 7860
43
+
44
  HEALTHCHECK --interval=15s --timeout=5s --start-period=30s \
45
+ CMD curl --fail http://localhost:7860/_stcore/health || exit 1
46
 
47
  # Pass GEMINI_API_KEY as an environment variable during `docker run`
48
+ # Example: docker run -p 7860:7860 -e GEMINI_API_KEY='your_api_key' manimator-image
49
  CMD ["streamlit", "run", "src/app.py", "--server.port=7860", "--server.address=0.0.0.0"]