Spaces:
Sleeping
Sleeping
| FROM python:3.11 | |
| # Install system dependencies | |
| RUN apt-get update && apt-get install -y \ | |
| wget \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Create directory for MiniZinc | |
| RUN mkdir -p /opt/minizinc | |
| # Download and extract MiniZinc bundle | |
| RUN wget https://github.com/MiniZinc/MiniZincIDE/releases/download/2.9.0/MiniZincIDE-2.9.0-bundle-linux-x86_64.tgz && \ | |
| tar xzf MiniZincIDE-2.9.0-bundle-linux-x86_64.tgz -C /opt/minizinc --strip-components=1 && \ | |
| rm MiniZincIDE-2.9.0-bundle-linux-x86_64.tgz | |
| # Add MiniZinc bin to system PATH | |
| ENV PATH="/opt/minizinc/bin:$PATH" | |
| # Set SPACE_ID for enabling a custom save process | |
| ENV SPACE_ID="Its a space!" | |
| # Set up non-root user FIRST (before creating app directories) | |
| RUN useradd -m -u 1000 user | |
| # Create necessary directories for data persistence with proper ownership | |
| RUN mkdir -p /app/submissions /app/results /tmp/flet_storage && \ | |
| chown -R user:user /app && \ | |
| chmod -R 777 /app/submissions /app/results /tmp/flet_storage /tmp | |
| # Switch to user | |
| USER user | |
| # Set environment variables | |
| ENV PATH="/home/user/.local/bin:/opt/minizinc/bin:$PATH" | |
| ENV HOME="/home/user" | |
| ENV FLET_APP_STORAGE_DIR=/tmp/flet_storage | |
| # Set working directory | |
| WORKDIR /app | |
| # Copy requirements first for better caching | |
| COPY --chown=user:user ./requirements.txt requirements.txt | |
| RUN pip install --no-cache-dir --upgrade -r requirements.txt | |
| # Copy application files | |
| COPY --chown=user:user . /app | |
| # Expose port | |
| EXPOSE 7860 | |
| # Command to run the Flet web app | |
| CMD ["flet", "run", "--web", "--port", "7860", "--host", "0.0.0.0", "app.py"] |