text2svg-demo-app / Dockerfile
Jinglong Xiong
fix permission
8ab6e21
raw
history blame
1.95 kB
FROM nvidia/cuda:12.1.1-devel-ubuntu22.04
# Set environment variables
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
DEBIAN_FRONTEND=noninteractive \
# Set cache directories to locations with write permissions
KAGGLE_CONFIG_DIR=/app/.cache/kaggle \
KAGGLEHUB_CACHE_FOLDER=/app/.cache/kagglehub \
MPLCONFIGDIR=/app/.cache/matplotlib \
TRANSFORMERS_CACHE=/app/.cache/transformers \
HF_HOME=/app/.cache/huggingface \
XDG_CACHE_HOME=/app/.cache \
HOME=/app
WORKDIR /app
# Install system dependencies
RUN apt-get update && apt-get install -y \
build-essential \
python3-pip \
python3-dev \
git \
wget \
libcairo2-dev \
pkg-config \
libgl1 \
libglib2.0-0 \
libsm6 \
libxrender1 \
libxext6 \
ffmpeg \
curl \
&& rm -rf /var/lib/apt/lists/*
# Create a non-root user to run our application
RUN groupadd -r appuser && useradd -r -g appuser -m -d /app appuser
# Copy requirements first to leverage Docker cache
COPY requirements.txt .
# Install Python dependencies
RUN pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir -r requirements.txt && \
pip install --no-cache-dir 'tensorflow[and-cuda]' && \
pip install --no-cache-dir git+https://github.com/openai/CLIP.git
# Copy the whole application
COPY . .
# Create cache directories and set proper ownership
RUN mkdir -p /app/.cache/kaggle /app/.cache/kagglehub /app/.cache/matplotlib /app/.cache/transformers /app/.cache/huggingface && \
chown -R appuser:appuser /app
# Set environment variables for GPU usage
ENV NVIDIA_VISIBLE_DEVICES=all \
NVIDIA_DRIVER_CAPABILITIES=compute,utility
# Switch to non-root user
USER appuser
# Expose port for Streamlit
EXPOSE 8501
# Create a healthcheck
HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health || exit 1
# Set entry point
CMD yes | streamlit run app.py --server.port=8501 --server.address=0.0.0.0