Spaces:
Running
Running
| FROM python:3.11-slim | |
| WORKDIR /app | |
| # Install system dependencies | |
| RUN apt-get update && apt-get install -y \ | |
| libgl1-mesa-glx \ | |
| libglib2.0-0 \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Create necessary directories with proper permissions | |
| RUN mkdir -p /app/data/planogram001 /app/assets && \ | |
| chmod -R 777 /app/data /app/assets | |
| # Copy requirements first to leverage Docker cache | |
| COPY requirements.txt . | |
| # Install Python dependencies | |
| RUN pip install --no-cache-dir -r requirements.txt && \ | |
| pip install --no-cache-dir hf_transfer | |
| # Copy the rest of the application | |
| COPY . . | |
| # Create necessary directories and set permissions | |
| RUN mkdir -p data/planogram001 && \ | |
| mkdir -p .files && \ | |
| mkdir -p /.cache && \ | |
| mkdir -p .chainlit/assets && \ | |
| chmod -R 777 .files && \ | |
| chmod -R 777 data && \ | |
| chmod -R 777 /.cache && \ | |
| chmod -R 777 .chainlit | |
| # Expose the port Chainlit runs on | |
| EXPOSE 7860 | |
| # Set environment variables | |
| ENV PYTHONPATH=/app | |
| ENV HF_HUB_ENABLE_HF_TRANSFER=1 | |
| ENV TRANSFORMERS_CACHE=/.cache | |
| ENV HF_HOME=/.cache | |
| ENV CHAINLIT_SERVER_HOST=0.0.0.0 | |
| ENV CHAINLIT_SERVER_PORT=7860 | |
| ENV CHAINLIT_DEBUG=1 | |
| ENV PYTHONUNBUFFERED=1 | |
| # Create a startup script with debugging | |
| RUN echo '#!/bin/bash\n\ | |
| echo "Starting Chainlit server..."\n\ | |
| echo "Current directory: $(pwd)"\n\ | |
| echo "Directory contents:"\n\ | |
| ls -la\n\ | |
| echo "Chainlit config:"\n\ | |
| cat .chainlit/config.toml\n\ | |
| echo "Starting server..."\n\ | |
| chainlit run app.py --host 0.0.0.0 --port 7860 --debug\n\ | |
| ' > /app/start.sh && chmod +x /app/start.sh | |
| # Run the application | |
| CMD ["/app/start.sh"] |