File size: 1,152 Bytes
9506fdc
 
 
 
 
 
 
 
 
 
7f15fad
 
9506fdc
 
 
dff0eff
 
 
 
 
 
9506fdc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
FROM python:3.12-slim

# Set working directory
WORKDIR /app

# Install system dependencies
RUN apt-get update && apt-get install -y \
    ghostscript \
    imagemagick \
    libmagickwand-dev \
    potrace \
    inkscape \
    && rm -rf /var/lib/apt/lists/*

# Configure ImageMagick to allow EPS/PS/PDF processing
RUN POLICY_FILE=$(find /etc -name policy.xml 2>/dev/null | head -n 1) && \
    if [ -n "$POLICY_FILE" ]; then \
        sed -i 's/<policy domain="coder" rights="none" pattern="PS" \/>/<policy domain="coder" rights="read|write" pattern="PS" \/>/g' "$POLICY_FILE" && \
        sed -i 's/<policy domain="coder" rights="none" pattern="EPS" \/>/<policy domain="coder" rights="read|write" pattern="EPS" \/>/g' "$POLICY_FILE" && \
        sed -i 's/<policy domain="coder" rights="none" pattern="PDF" \/>/<policy domain="coder" rights="read|write" pattern="PDF" \/>/g' "$POLICY_FILE"; \
    fi

# Copy requirements file
COPY requirements.txt .

# Install Python dependencies
RUN pip install --no-cache-dir -r requirements.txt

# Copy application code
COPY app.py .

# Expose Gradio port
EXPOSE 7860

# Run the application
CMD ["python", "app.py"]