CingenAI / Dockerfile
mgbam's picture
Update Dockerfile
0f0f717 verified
raw
history blame
2.25 kB
FROM python:3.10-slim
# Set environment variables
ENV PYTHONUNBUFFERED=1
ENV DEBIAN_FRONTEND=noninteractive
# Add the default user local bin to PATH. This is where pip often installs executables.
ENV PATH="/home/appuser/.local/bin:${PATH}"
# Install system dependencies (ffmpeg, fontconfig for managing copied fonts)
RUN apt-get update && \
apt-get install -y --no-install-recommends \
ffmpeg \
libsm6 \
libxext6 \
fontconfig && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# Create directory for custom fonts and copy your font file(s)
RUN mkdir -p /usr/local/share/fonts/truetype/mycustomfonts
COPY assets/fonts/arial.ttf /usr/local/share/fonts/truetype/mycustomfonts/arial.ttf
# Rebuild font cache
RUN fc-cache -f -s -v
# Create a non-root user and group
ARG APP_USER_UID=1000
ARG APP_USER_GID=1000
RUN groupadd --gid $APP_USER_GID appgroup && \
useradd --uid $APP_USER_UID --gid appgroup --shell /bin/bash --create-home appuser
# The --create-home flag for useradd usually sets up a basic .profile or .bashrc
# which should configure PATH to include ~/.local/bin, but we make it explicit with ENV PATH.
WORKDIR /home/appuser/app # This is appuser's home and working directory
# Copy requirements.txt and install Python dependencies AS APPUSER
COPY --chown=appuser:appgroup requirements.txt ./
USER appuser # Switch to appuser BEFORE pip install
# Upgrade pip and install Python dependencies
# Use python -m pip and specify --user if installing into user's site-packages
# However, since WORKDIR is home and we switched user, pip should install to user's .local by default.
RUN python -m pip install --no-cache-dir --upgrade pip
RUN python -m pip install --no-cache-dir -r requirements.txt --verbose # Add --verbose for more output
# Verify streamlit installation location after pip install
RUN which streamlit || echo "streamlit not found in PATH after pip install"
RUN ls -l /home/appuser/.local/bin || echo "/home/appuser/.local/bin does not exist or is empty"
# Copy the rest of the application code as the appuser
COPY --chown=appuser:appgroup . .
EXPOSE 8501
CMD ["streamlit", "run", "app.py", "--server.headless=true", "--server.port=8501", "--server.fileWatcherType=none"]