Update Dockerfile
Browse files- Dockerfile +6 -12
Dockerfile
CHANGED
@@ -48,15 +48,10 @@ RUN if [ -f /etc/ImageMagick-6/policy.xml ]; then \
|
|
48 |
|
49 |
# Create a non-root user and group
|
50 |
RUN groupadd -r appgroup && useradd --no-log-init -r -g appgroup -u 1000 appuser
|
51 |
-
# Create home directory structure for appuser, including .cache for pip
|
52 |
RUN mkdir -p /home/appuser/.cache/pip && chown -R appuser:appgroup /home/appuser
|
53 |
|
54 |
# Set Streamlit home directory to be writable by appuser
|
55 |
-
# This directory will be created within /home/appuser, so appuser will own it.
|
56 |
ENV STREAMLIT_HOME=/home/appuser/.streamlit
|
57 |
-
# No need to mkdir/chown STREAMLIT_HOME here if appuser creates it at runtime,
|
58 |
-
# or if we ensure /home/appuser is writable by appuser.
|
59 |
-
# However, to be safe, especially if Streamlit tries to create it very early:
|
60 |
RUN mkdir -p $STREAMLIT_HOME && chown -R appuser:appgroup $STREAMLIT_HOME
|
61 |
|
62 |
# Copy the requirements file first
|
@@ -65,20 +60,19 @@ COPY --chown=appuser:appgroup requirements.txt .
|
|
65 |
# Install Python dependencies as the non-root user
|
66 |
USER appuser
|
67 |
RUN pip install --no-cache-dir --upgrade pip && \
|
68 |
-
pip install --no-cache-dir -r requirements.txt
|
|
|
|
|
|
|
69 |
|
70 |
# Switch back to root temporarily for copying application files and setting permissions
|
71 |
USER root
|
72 |
-
COPY . .
|
73 |
-
RUN chown -R appuser:appgroup /app
|
74 |
|
75 |
# Create runtime directories as root, then chown to appuser
|
76 |
RUN mkdir -p /app/temp_cinegen_media && chown -R appuser:appgroup /app/temp_cinegen_media
|
77 |
RUN mkdir -p /app/assets/fonts && chown -R appuser:appgroup /app/assets/fonts
|
78 |
-
# Ensure custom fonts copied in assets/fonts are usable system-wide if needed by MoviePy's TextClip
|
79 |
-
# This assumes your 'arial.ttf' (or other custom fonts) are in 'assets/fonts/' in your project.
|
80 |
-
# If they are, copy them to a system font directory and update the font cache.
|
81 |
-
# The VisualEngine also tries to load from 'assets/fonts/' directly via Pillow.
|
82 |
RUN if [ -d "/app/assets/fonts" ] && [ "$(ls -A /app/assets/fonts)" ]; then \
|
83 |
mkdir -p /usr/local/share/fonts/truetype/cinegen_custom && \
|
84 |
cp /app/assets/fonts/*.*tf /usr/local/share/fonts/truetype/cinegen_custom/ 2>/dev/null || true && \
|
|
|
48 |
|
49 |
# Create a non-root user and group
|
50 |
RUN groupadd -r appgroup && useradd --no-log-init -r -g appgroup -u 1000 appuser
|
|
|
51 |
RUN mkdir -p /home/appuser/.cache/pip && chown -R appuser:appgroup /home/appuser
|
52 |
|
53 |
# Set Streamlit home directory to be writable by appuser
|
|
|
54 |
ENV STREAMLIT_HOME=/home/appuser/.streamlit
|
|
|
|
|
|
|
55 |
RUN mkdir -p $STREAMLIT_HOME && chown -R appuser:appgroup $STREAMLIT_HOME
|
56 |
|
57 |
# Copy the requirements file first
|
|
|
60 |
# Install Python dependencies as the non-root user
|
61 |
USER appuser
|
62 |
RUN pip install --no-cache-dir --upgrade pip && \
|
63 |
+
pip install --user --no-cache-dir -r requirements.txt # Added --user flag
|
64 |
+
|
65 |
+
# Add user's local bin to PATH. This should be done after pip install as appuser
|
66 |
+
ENV PATH="/home/appuser/.local/bin:${PATH}"
|
67 |
|
68 |
# Switch back to root temporarily for copying application files and setting permissions
|
69 |
USER root
|
70 |
+
COPY . . # This copies to /app
|
71 |
+
RUN chown -R appuser:appgroup /app # Ensure /app is owned by appuser
|
72 |
|
73 |
# Create runtime directories as root, then chown to appuser
|
74 |
RUN mkdir -p /app/temp_cinegen_media && chown -R appuser:appgroup /app/temp_cinegen_media
|
75 |
RUN mkdir -p /app/assets/fonts && chown -R appuser:appgroup /app/assets/fonts
|
|
|
|
|
|
|
|
|
76 |
RUN if [ -d "/app/assets/fonts" ] && [ "$(ls -A /app/assets/fonts)" ]; then \
|
77 |
mkdir -p /usr/local/share/fonts/truetype/cinegen_custom && \
|
78 |
cp /app/assets/fonts/*.*tf /usr/local/share/fonts/truetype/cinegen_custom/ 2>/dev/null || true && \
|