Update Dockerfile
Browse files- Dockerfile +16 -23
Dockerfile
CHANGED
@@ -1,12 +1,11 @@
|
|
1 |
FROM python:3.10-slim
|
2 |
|
3 |
# Set environment variables
|
4 |
-
ENV PYTHONUNBUFFERED=1
|
5 |
-
|
6 |
-
|
7 |
-
ENV PATH="/home/appuser/.local/bin:${PATH}"
|
8 |
|
9 |
-
# Install system dependencies
|
10 |
RUN apt-get update && \
|
11 |
apt-get install -y --no-install-recommends \
|
12 |
ffmpeg \
|
@@ -16,38 +15,32 @@ RUN apt-get update && \
|
|
16 |
apt-get clean && \
|
17 |
rm -rf /var/lib/apt/lists/*
|
18 |
|
19 |
-
#
|
20 |
RUN mkdir -p /usr/local/share/fonts/truetype/mycustomfonts
|
21 |
COPY assets/fonts/arial.ttf /usr/local/share/fonts/truetype/mycustomfonts/arial.ttf
|
22 |
-
|
23 |
-
# Rebuild font cache
|
24 |
RUN fc-cache -f -s -v
|
25 |
|
26 |
-
# Create
|
27 |
ARG APP_USER_UID=1000
|
28 |
ARG APP_USER_GID=1000
|
29 |
RUN groupadd --gid $APP_USER_GID appgroup && \
|
30 |
useradd --uid $APP_USER_UID --gid appgroup --shell /bin/bash --create-home appuser
|
31 |
-
# The --create-home flag for useradd usually sets up a basic .profile or .bashrc
|
32 |
-
# which should configure PATH to include ~/.local/bin, but we make it explicit with ENV PATH.
|
33 |
|
34 |
-
|
|
|
35 |
|
36 |
-
#
|
37 |
COPY --chown=appuser:appgroup requirements.txt ./
|
38 |
-
USER appuser
|
39 |
|
40 |
-
|
41 |
-
|
42 |
-
# However, since WORKDIR is home and we switched user, pip should install to user's .local by default.
|
43 |
-
RUN python -m pip install --no-cache-dir --upgrade pip
|
44 |
-
RUN python -m pip install --no-cache-dir -r requirements.txt --verbose # Add --verbose for more output
|
45 |
|
46 |
-
# Verify
|
47 |
-
RUN which streamlit || echo "streamlit not found in PATH
|
48 |
-
|
49 |
|
50 |
-
# Copy
|
51 |
COPY --chown=appuser:appgroup . .
|
52 |
|
53 |
EXPOSE 8501
|
|
|
1 |
FROM python:3.10-slim
|
2 |
|
3 |
# Set environment variables
|
4 |
+
ENV PYTHONUNBUFFERED=1 \
|
5 |
+
DEBIAN_FRONTEND=noninteractive \
|
6 |
+
PATH="/home/appuser/.local/bin:${PATH}"
|
|
|
7 |
|
8 |
+
# Install system dependencies
|
9 |
RUN apt-get update && \
|
10 |
apt-get install -y --no-install-recommends \
|
11 |
ffmpeg \
|
|
|
15 |
apt-get clean && \
|
16 |
rm -rf /var/lib/apt/lists/*
|
17 |
|
18 |
+
# Set up custom fonts
|
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 |
RUN fc-cache -f -s -v
|
22 |
|
23 |
+
# Create non-root user
|
24 |
ARG APP_USER_UID=1000
|
25 |
ARG APP_USER_GID=1000
|
26 |
RUN groupadd --gid $APP_USER_GID appgroup && \
|
27 |
useradd --uid $APP_USER_UID --gid appgroup --shell /bin/bash --create-home appuser
|
|
|
|
|
28 |
|
29 |
+
# Set working directory
|
30 |
+
WORKDIR /home/appuser/app
|
31 |
|
32 |
+
# Install Python dependencies
|
33 |
COPY --chown=appuser:appgroup requirements.txt ./
|
34 |
+
USER appuser
|
35 |
|
36 |
+
RUN python -m pip install --no-cache-dir --upgrade pip && \
|
37 |
+
python -m pip install --no-cache-dir -r requirements.txt --verbose
|
|
|
|
|
|
|
38 |
|
39 |
+
# Verify installation
|
40 |
+
RUN which streamlit || echo "streamlit not found in PATH" && \
|
41 |
+
ls -l /home/appuser/.local/bin || echo "Local bin directory not found"
|
42 |
|
43 |
+
# Copy application code
|
44 |
COPY --chown=appuser:appgroup . .
|
45 |
|
46 |
EXPOSE 8501
|