audit_assistant / Dockerfile
akryldigital's picture
soften permissions for folder creations
973ca8b verified
raw
history blame
2.37 kB
FROM python:3.11-slim
WORKDIR /app
# Install system dependencies
RUN apt-get update && apt-get install -y \
build-essential \
curl \
git \
&& rm -rf /var/lib/apt/lists/*
# Copy requirements first (for better Docker layer caching)
COPY requirements.txt ./
# Install Python dependencies
RUN pip3 install --no-cache-dir -r requirements.txt
# Pre-download Hugging Face models during build
# This caches models in the Docker image for faster container startup
# IMPORTANT: Set cache directory BEFORE downloading to ensure models are in /app/.cache/huggingface
ENV HF_HOME=/app/.cache/huggingface
ENV TRANSFORMERS_CACHE=/app/.cache/huggingface
ENV HF_DATASETS_CACHE=/app/.cache/huggingface
ENV HF_HUB_CACHE=/app/.cache/huggingface
ENV SENTENCE_TRANSFORMERS_HOME=/app/.cache/huggingface
COPY download_models.py ./
COPY src/config/settings.yaml ./src/config/settings.yaml
RUN mkdir -p /app/.cache/huggingface && \
chmod -R 755 /app/.cache && \
chmod -R 755 /app/.cache/huggingface && \
python download_models.py
# Copy all application files (excluding .dockerignore patterns)
COPY . .
RUN mkdir -p /app/.streamlit && \
mkdir -p /app/.cache/streamlit && \
mkdir -p /app/.cache/huggingface && \
mkdir -p /app/conversations && \
mkdir -p /app/feedback && \
printf '[server]\nport = 8501\nheadless = true\nenableCORS = false\nenableXsrfProtection = false\n\n[browser]\ngatherUsageStats = false\n' > /app/.streamlit/config.toml && \
chmod -R 777 /app/.streamlit && \
chmod -R 777 /app/.cache/streamlit && \
chmod -R 777 /app/.cache/huggingface && \
chmod -R 777 /app/conversations && \
chmod -R 777 /app/feedback
ENV STREAMLIT_CONFIG_HOME=/app/.streamlit
ENV STREAMLIT_USER_BASE_PATH=/app/.cache/streamlit
ENV STREAMLIT_BROWSER_GATHER_USAGE_STATS=false
# Expose Streamlit port (HF Spaces maps to 7860 automatically)
EXPOSE 8501
# Health check for Streamlit
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
CMD curl --fail http://localhost:8501/_stcore/health || exit 1
#temp developement commands
# RUN mkdir /app/conversations && chmod -R 777 conversations
# RUN mkdir /app/feedback && chmod -R 777 feedback
# Run Streamlit app
ENTRYPOINT ["streamlit", "run", "app.py", "--server.port=8501", "--server.address=0.0.0.0", "--server.headless", "true"]