Spaces:
Sleeping
Sleeping
File size: 1,615 Bytes
3c2e3e7 3cdcb59 3c2e3e7 30d3c6d 3c2e3e7 8739839 3c2e3e7 3cdcb59 3c2e3e7 3cdcb59 8739839 3cdcb59 3c2e3e7 3cdcb59 3c2e3e7 3cdcb59 30d3c6d 3cdcb59 3c2e3e7 3cdcb59 30d3c6d 3cdcb59 3c2e3e7 3cdcb59 3c2e3e7 |
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 |
FROM python:3.11-slim
# Set environment variables
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PYTHONFAULTHANDLER=1 \
HOME_DIR=/home/user \
APP_DIR=/home/user/app \
PATH="/root/.local/bin:$PATH" \
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/*
# Install uv (as root, it will go to /root/.local/bin)
RUN curl -LsSf https://astral.sh/uv/install.sh | sh
# Set working directory
WORKDIR ${APP_DIR}
# Copy all project files. Crucially, these are now owned by root by default
# as we haven't switched user yet. This ensures setuptools (run by root's uv)
# can read them and write build artifacts in this directory.
COPY . ${APP_DIR}
# Install dependencies using uv (run as root, installing system-wide)
# This will also build and install the local insightflow-ai package
RUN uv pip install --system --no-cache .
# Now that installation is done, change ownership of the app directory to the non-root user
RUN chown -R user:user ${APP_DIR}
# Switch to non-root user for subsequent operations and runtime
USER user
# Create necessary runtime directories (as non-root user)
RUN mkdir -p ${APP_DIR}/exports ${APP_DIR}/data_sources
# Run data download script to initialize data sources (as non-root user)
RUN python ${APP_DIR}/download_data.py
# Expose the port the app runs on
EXPOSE 7860
# Run the app
CMD ["chainlit", "run", "app.py", "--host", "0.0.0.0", "--port", "7860"] |