Spaces:
Sleeping
Sleeping
File size: 1,687 Bytes
31add3b |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
FROM python:3.11-slim
# Set environment variables
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PYTHONFAULTHANDLER=1 \
PATH="/home/user/.local/bin:$PATH" \
HOME=/home/user \
PYTHONPATH="/home/user/app:$PYTHONPATH"
# Add non-root user
RUN useradd -m -u 1000 user
# Install system dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
curl \
&& rm -rf /var/lib/apt/lists/*
# Set working directory
WORKDIR $HOME/app
# Copy requirements file
COPY --chown=user requirements.txt .
# Install pip and dependencies
RUN pip install --upgrade pip setuptools wheel
RUN pip install -r requirements.txt
# Copy application files
COPY --chown=user app.py .
COPY --chown=user insight_state.py .
COPY --chown=user chainlit.md .
COPY --chown=user README.md .
COPY --chown=user utils ./utils
COPY --chown=user persona_configs ./persona_configs
COPY --chown=user download_data.py .
COPY --chown=user .env.example .
# Create necessary directories
RUN mkdir -p data data_sources exports public
RUN mkdir -p exports && touch exports/.gitkeep
RUN mkdir -p data && touch data/.gitkeep
# Set permissions
RUN chown -R user:user $HOME
# Switch to non-root user
USER user
# Run data download script to initialize data sources
RUN python download_data.py
# Create config for HF Spaces
RUN mkdir -p $HOME/app/.hf && echo "sdk_version: 3\ntitle: InsightFlow AI\ndescription: Multi-perspective research assistant with visualization capabilities\napp_port: 7860" > $HOME/app/.hf/settings.yaml
# Expose Hugging Face Spaces port
EXPOSE 7860
# Run the app
CMD ["chainlit", "run", "app.py", "--host", "0.0.0.0", "--port", "7860"] |