Spaces:
Runtime error
Runtime error
Update Dockerfile
Browse files- Dockerfile +32 -10
Dockerfile
CHANGED
@@ -1,6 +1,21 @@
|
|
1 |
# Use an official Python runtime as a parent image
|
2 |
FROM python:3.9-slim
|
3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
# Set the working directory in the container
|
5 |
WORKDIR /app
|
6 |
|
@@ -8,19 +23,26 @@ WORKDIR /app
|
|
8 |
COPY requirements.txt .
|
9 |
|
10 |
# Install any needed packages specified in requirements.txt
|
11 |
-
# --
|
12 |
-
RUN pip install
|
13 |
-
pip install --no-cache-dir
|
|
|
|
|
14 |
|
15 |
# Copy all files from the build context (app.py, etc.) into the working directory
|
16 |
COPY . .
|
17 |
|
18 |
-
# Create necessary directories that the app will use
|
19 |
-
#
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
chmod -R 777 ./data ./downloads ./session
|
|
|
|
|
|
|
|
|
24 |
|
25 |
# Command to run the application when the container launches
|
26 |
-
|
|
|
|
1 |
# Use an official Python runtime as a parent image
|
2 |
FROM python:3.9-slim
|
3 |
|
4 |
+
# Set environment variables to ensure Python output is unbuffered (helps with logging)
|
5 |
+
ENV PYTHONUNBUFFERED=1
|
6 |
+
|
7 |
+
# Install system dependencies that might be needed by Pillow or other libraries
|
8 |
+
# gcc and python3-dev are for compiling C extensions if wheels are not available
|
9 |
+
# libjpeg-dev, zlib1g-dev are common for Pillow's JPEG and PNG support
|
10 |
+
# build-essential includes gcc, g++, make, etc.
|
11 |
+
RUN apt-get update && apt-get install -y --no-install-recommends --fix-missing \
|
12 |
+
build-essential \
|
13 |
+
python3-dev \
|
14 |
+
libjpeg-dev \
|
15 |
+
zlib1g-dev \
|
16 |
+
&& echo "System dependencies installed." \
|
17 |
+
&& rm -rf /var/lib/apt/lists/*
|
18 |
+
|
19 |
# Set the working directory in the container
|
20 |
WORKDIR /app
|
21 |
|
|
|
23 |
COPY requirements.txt .
|
24 |
|
25 |
# Install any needed packages specified in requirements.txt
|
26 |
+
# Using --verbose can sometimes give more insight into pip errors
|
27 |
+
RUN echo "Starting pip install..." && \
|
28 |
+
pip install --no-cache-dir --upgrade pip && \
|
29 |
+
pip install --no-cache-dir --verbose -r requirements.txt && \
|
30 |
+
echo "Pip install completed."
|
31 |
|
32 |
# Copy all files from the build context (app.py, etc.) into the working directory
|
33 |
COPY . .
|
34 |
|
35 |
+
# Create necessary directories that the app will use
|
36 |
+
# These directories will be relative to WORKDIR (/app)
|
37 |
+
RUN echo "Creating directories: ./data ./downloads ./session" && \
|
38 |
+
mkdir -p ./data ./downloads ./session && \
|
39 |
+
echo "Setting permissions for directories..." && \
|
40 |
+
chmod -R 777 ./data ./downloads ./session && \
|
41 |
+
echo "Permissions set."
|
42 |
+
|
43 |
+
# List contents of /app for debugging (check build logs for this output)
|
44 |
+
RUN echo "Contents of /app:" && ls -la /app
|
45 |
|
46 |
# Command to run the application when the container launches
|
47 |
+
# The -u flag for python is equivalent to PYTHONUNBUFFERED=1
|
48 |
+
CMD ["python", "-u", "app.py"]
|