File size: 1,405 Bytes
c705885
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# 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"]