Spaces:
Paused
Paused
| # Use an official Python runtime as a parent image | |
| FROM python:3.9-slim | |
| # Set environment variables | |
| ENV PYTHONDONTWRITEBYTECODE 1 | |
| ENV PYTHONUNBUFFERED 1 | |
| # Create a non-root user with ID 1000 | |
| RUN useradd -m -u 1000 user | |
| # Set the user to the non-root user | |
| USER user | |
| ENV PATH="/home/user/.local/bin:$PATH" | |
| # Set the working directory in the container | |
| WORKDIR /app | |
| # Copy the requirements file into the container and install dependencies | |
| COPY --chown=user ./requirements.txt requirements.txt | |
| RUN pip install --no-cache-dir -r requirements.txt | |
| # Ensure upload directories exist with correct permissions | |
| RUN mkdir -p /app/uploads /app/converted && chmod -R 777 /app/uploads /app/converted | |
| # Install LibreOffice and Java dependencies | |
| USER root | |
| RUN apt-get update \ | |
| && apt-get install -y \ | |
| libreoffice-core \ | |
| libreoffice-writer \ | |
| libreoffice-java-common \ | |
| default-jre \ | |
| fontconfig \ | |
| --no-install-recommends \ | |
| && apt-get clean \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Switch back to the non-root user | |
| USER user | |
| # Add the custom font | |
| COPY --chown=user fonts/majalla.ttf /usr/share/fonts/truetype/majalla.ttf | |
| # Rebuild font cache | |
| RUN fc-cache -fv | |
| # Copy the rest of the application code | |
| COPY --chown=user . . | |
| # Expose the port the app runs on | |
| EXPOSE 7860 | |
| # Run the script using Gunicorn | |
| CMD ["gunicorn", "-w", "4", "-b", "0.0.0.0:7860", "app:app"] | |