mgbam commited on
Commit
8f7a7a3
·
verified ·
1 Parent(s): 27a4a8c

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +16 -23
Dockerfile CHANGED
@@ -52,49 +52,42 @@ RUN groupadd -r appgroup --gid 1000 && \
52
 
53
  # Set Streamlit home directory (already created and chowned)
54
  ENV STREAMLIT_HOME=/home/appuser/.streamlit
 
 
55
 
56
- # Set the working directory in the container (owned by root initially, will be chowned)
57
  WORKDIR /app
58
 
59
- # Copy requirements.txt and install dependencies AS APPUSER
60
- # First, copy just requirements.txt and chown its destination so appuser can write to /app (temporarily for this step)
61
  COPY --chown=appuser:appgroup requirements.txt .
 
 
62
  USER appuser
63
  RUN pip install --no-cache-dir --upgrade pip && \
64
- pip install --user --no-cache-dir -r requirements.txt # --user installs to ~/.local
65
 
66
  # Add user's local bin to PATH
67
  ENV PATH="/home/appuser/.local/bin:${PATH}"
68
 
69
- # Copy the rest of the application code AS APPUSER
70
- # WORKDIR /app is still in effect, appuser should have rights to write here if /app was chowned.
71
- # However, to be absolutely safe, we copy to a location appuser definitely owns, or chown /app after copy by root.
72
- # Let's stick to copying as root then chowning all of /app.
73
-
74
  USER root
75
- COPY . .
76
  RUN chown -R appuser:appgroup /app
77
 
78
- # Create runtime directories AS APPUSER (now that /app is owned by appuser)
79
  USER appuser
80
  RUN mkdir -p /app/temp_cinegen_media
81
- RUN mkdir -p /app/assets/fonts # This directory should exist from COPY, but ensure it.
82
 
83
- # Copy custom fonts to system location (as root, if needed by MoviePy's ImageMagick backend directly)
84
- # This step is optional if Pillow direct font path loading is sufficient.
85
  # USER root
86
  # RUN if [ -d "/app/assets/fonts" ] && [ "$(ls -A /app/assets/fonts)" ]; then \
87
- # mkdir -p /usr/local/share/fonts/truetype/cinegen_custom && \
88
- # cp /app/assets/fonts/*.*tf /usr/local/share/fonts/truetype/cinegen_custom/ 2>/dev/null || true && \
89
- # fc-cache -fv && \
90
- # echo "INFO: Copied custom fonts and refreshed font cache (as root)."; \
91
- # else \
92
- # echo "INFO: No custom fonts found in /app/assets/fonts to copy system-wide." ; \
93
- # fi
94
- # USER appuser # Switch back to appuser for runtime
95
 
96
  # Expose the port Streamlit runs on
97
  EXPOSE 8501
98
 
99
  # Define the command to run the application
100
- CMD ["streamlit", "run", "app.py", "--server.port=8501", "--server.address=0.0.0.0", "--global.sharingMode=off", "--client.gatherUsageStats=false"]
 
 
52
 
53
  # Set Streamlit home directory (already created and chowned)
54
  ENV STREAMLIT_HOME=/home/appuser/.streamlit
55
+ # Set environment variable to disable telemetry (alternative to CLI flag)
56
+ ENV STREAMLIT_CLIENT_GATHER_USAGE_STATS=false
57
 
58
+ # Set the working directory in the container
59
  WORKDIR /app
60
 
61
+ # Copy requirements.txt
 
62
  COPY --chown=appuser:appgroup requirements.txt .
63
+
64
+ # Install Python dependencies as the non-root user
65
  USER appuser
66
  RUN pip install --no-cache-dir --upgrade pip && \
67
+ pip install --user --no-cache-dir -r requirements.txt
68
 
69
  # Add user's local bin to PATH
70
  ENV PATH="/home/appuser/.local/bin:${PATH}"
71
 
72
+ # Switch back to root temporarily for copying application files and setting permissions
 
 
 
 
73
  USER root
74
+ COPY . .
75
  RUN chown -R appuser:appgroup /app
76
 
77
+ # Create runtime directories as appuser (now that /app is owned by appuser)
78
  USER appuser
79
  RUN mkdir -p /app/temp_cinegen_media
80
+ RUN mkdir -p /app/assets/fonts
81
 
82
+ # (Optional: System-wide font copy block, commented out as before, only if needed)
 
83
  # USER root
84
  # RUN if [ -d "/app/assets/fonts" ] && [ "$(ls -A /app/assets/fonts)" ]; then \
85
+ # ...
86
+ # USER appuser
 
 
 
 
 
 
87
 
88
  # Expose the port Streamlit runs on
89
  EXPOSE 8501
90
 
91
  # Define the command to run the application
92
+ # REMOVED --global.sharingMode=off
93
+ CMD ["streamlit", "run", "app.py", "--server.port=8501", "--server.address=0.0.0.0", "--client.gatherUsageStats=false"]