File size: 1,884 Bytes
96c728b
 
 
8c532b0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
96c728b
 
 
 
 
 
 
8c532b0
 
 
 
 
96c728b
 
 
 
8c532b0
 
 
 
 
 
 
 
 
 
96c728b
 
8c532b0
 
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
# Use an official Python runtime as a parent image
FROM python:3.9-slim

# Set environment variables to ensure Python output is unbuffered (helps with logging)
ENV PYTHONUNBUFFERED=1

# Install system dependencies that might be needed by Pillow or other libraries
# gcc and python3-dev are for compiling C extensions if wheels are not available
# libjpeg-dev, zlib1g-dev are common for Pillow's JPEG and PNG support
# build-essential includes gcc, g++, make, etc.
RUN apt-get update && apt-get install -y --no-install-recommends --fix-missing \
    build-essential \
    python3-dev \
    libjpeg-dev \
    zlib1g-dev \
    && echo "System dependencies installed." \
    && rm -rf /var/lib/apt/lists/*

# Set the working directory in the container
WORKDIR /app

# Copy the requirements file first to leverage Docker cache
COPY requirements.txt .

# Install any needed packages specified in requirements.txt
# Using --verbose can sometimes give more insight into pip errors
RUN echo "Starting pip install..." && \
    pip install --no-cache-dir --upgrade pip && \
    pip install --no-cache-dir --verbose -r requirements.txt && \
    echo "Pip install completed."

# Copy all files from the build context (app.py, etc.) into the working directory
COPY . .

# Create necessary directories that the app will use
# These directories will be relative to WORKDIR (/app)
RUN echo "Creating directories: ./data ./downloads ./session" && \
    mkdir -p ./data ./downloads ./session && \
    echo "Setting permissions for directories..." && \
    chmod -R 777 ./data ./downloads ./session && \
    echo "Permissions set."

# List contents of /app for debugging (check build logs for this output)
RUN echo "Contents of /app:" && ls -la /app

# Command to run the application when the container launches
# The -u flag for python is equivalent to PYTHONUNBUFFERED=1
CMD ["python", "-u", "app.py"]