File size: 826 Bytes
46aaf2f
7928d62
46aaf2f
7928d62
46aaf2f
 
7928d62
46aaf2f
 
 
 
 
7928d62
46aaf2f
 
 
7928d62
46aaf2f
 
7928d62
46aaf2f
 
7928d62
46aaf2f
 
 
7928d62
46aaf2f
 
7928d62
46aaf2f
 
7928d62
46aaf2f
 
 
 
 
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
FROM python:3.9-slim

WORKDIR /app

# Create a non-root user
RUN useradd -m appuser

# Install system dependencies
RUN apt-get update && apt-get install -y \
    build-essential \
    git \
    && rm -rf /var/lib/apt/lists/*

# Create directories for matplotlib and set appropriate permissions
RUN mkdir -p /home/appuser/.config/matplotlib && \
    chown -R appuser:appuser /home/appuser/.config

# Copy requirements file
COPY requirements.txt .

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

# Copy application files
COPY app.py .
COPY utils.py .

# Set environment variable for matplotlib
ENV MPLCONFIGDIR=/home/appuser/.config/matplotlib

# Expose port for the application
EXPOSE 7860

# Switch to the non-root user
USER appuser

# Command to run the application
CMD ["python", "app.py"]