Update Dockerfile
Browse files- Dockerfile +14 -23
Dockerfile
CHANGED
@@ -2,51 +2,42 @@ FROM python:3.10-slim
|
|
2 |
|
3 |
# Set environment variables
|
4 |
ENV PYTHONUNBUFFERED=1
|
5 |
-
|
6 |
-
ENV DEBIAN_FRONTEND=noninteractive
|
7 |
|
8 |
-
# Install
|
9 |
RUN apt-get update && \
|
10 |
apt-get install -y --no-install-recommends \
|
11 |
ffmpeg \
|
12 |
libsm6 \
|
13 |
libxext6 \
|
14 |
-
fontconfig \
|
15 |
-
debconf-utils && \
|
16 |
-
# For Microsoft Core Fonts EULA pre-acceptance, use full path for robustness
|
17 |
-
# Ensure 'echo' is properly part of the RUN command chain
|
18 |
-
echo "ttf-mscorefonts-installer msttcorefonts/accepted-mscorefonts-eula select true" | /usr/bin/debconf-set-sections && \
|
19 |
-
# Install Microsoft Core Fonts
|
20 |
-
apt-get install -y --no-install-recommends ttf-mscorefonts-installer && \
|
21 |
-
# Update font cache
|
22 |
-
fc-cache -f -v && \
|
23 |
-
# Clean up
|
24 |
apt-get clean && \
|
25 |
rm -rf /var/lib/apt/lists/*
|
26 |
|
27 |
-
# Create
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
ARG APP_USER_UID=1000
|
29 |
ARG APP_USER_GID=1000
|
30 |
RUN groupadd --gid $APP_USER_GID appgroup && \
|
31 |
useradd --uid $APP_USER_UID --gid appgroup --shell /bin/bash --create-home appuser
|
32 |
|
33 |
-
# Set the working directory (this will also be appuser's home directory)
|
34 |
WORKDIR /home/appuser/app
|
35 |
-
|
36 |
-
# Copy requirements.txt first to leverage Docker build cache
|
37 |
COPY --chown=appuser:appgroup requirements.txt ./
|
38 |
|
39 |
-
# Upgrade pip and install Python dependencies as the appuser
|
40 |
USER appuser
|
41 |
RUN python -m pip install --no-cache-dir --upgrade pip
|
42 |
RUN python -m pip install --no-cache-dir -r requirements.txt
|
43 |
|
44 |
-
# Copy the rest of the application code as the appuser
|
45 |
-
# This ensures correct ownership from the start
|
46 |
COPY --chown=appuser:appgroup . .
|
47 |
|
48 |
-
# Expose Streamlit's default port
|
49 |
EXPOSE 8501
|
50 |
-
|
51 |
-
# Command to run Streamlit
|
52 |
CMD ["streamlit", "run", "app.py", "--server.headless=true", "--server.port=8501", "--server.fileWatcherType=none"]
|
|
|
2 |
|
3 |
# Set environment variables
|
4 |
ENV PYTHONUNBUFFERED=1
|
5 |
+
ENV DEBIAN_FRONTEND=noninteractive # Still good practice
|
|
|
6 |
|
7 |
+
# Install system dependencies (ffmpeg, fontconfig for managing copied fonts)
|
8 |
RUN apt-get update && \
|
9 |
apt-get install -y --no-install-recommends \
|
10 |
ffmpeg \
|
11 |
libsm6 \
|
12 |
libxext6 \
|
13 |
+
fontconfig && \ # fontconfig is essential for fc-cache
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
apt-get clean && \
|
15 |
rm -rf /var/lib/apt/lists/*
|
16 |
|
17 |
+
# Create directory for custom fonts and copy your font file(s)
|
18 |
+
# Make sure 'assets/fonts/arial.ttf' exists in your repository
|
19 |
+
RUN mkdir -p /usr/local/share/fonts/truetype/mycustomfonts
|
20 |
+
COPY assets/fonts/arial.ttf /usr/local/share/fonts/truetype/mycustomfonts/arial.ttf
|
21 |
+
# If you have other fonts, COPY them here as well:
|
22 |
+
# COPY assets/fonts/anotherfont.ttf /usr/local/share/fonts/truetype/mycustomfonts/anotherfont.ttf
|
23 |
+
|
24 |
+
# Rebuild font cache to make newly installed fonts available
|
25 |
+
RUN fc-cache -f -s -v # -s for system-wide, -v for verbose
|
26 |
+
|
27 |
+
# Create a non-root user and group
|
28 |
ARG APP_USER_UID=1000
|
29 |
ARG APP_USER_GID=1000
|
30 |
RUN groupadd --gid $APP_USER_GID appgroup && \
|
31 |
useradd --uid $APP_USER_UID --gid appgroup --shell /bin/bash --create-home appuser
|
32 |
|
|
|
33 |
WORKDIR /home/appuser/app
|
|
|
|
|
34 |
COPY --chown=appuser:appgroup requirements.txt ./
|
35 |
|
|
|
36 |
USER appuser
|
37 |
RUN python -m pip install --no-cache-dir --upgrade pip
|
38 |
RUN python -m pip install --no-cache-dir -r requirements.txt
|
39 |
|
|
|
|
|
40 |
COPY --chown=appuser:appgroup . .
|
41 |
|
|
|
42 |
EXPOSE 8501
|
|
|
|
|
43 |
CMD ["streamlit", "run", "app.py", "--server.headless=true", "--server.port=8501", "--server.fileWatcherType=none"]
|