Spaces:
Running
Running
Update Dockerfile
Browse files- Dockerfile +14 -21
Dockerfile
CHANGED
@@ -1,10 +1,11 @@
|
|
1 |
# Use an official Python runtime as a parent image
|
2 |
FROM python:3.9-slim
|
3 |
|
4 |
-
# Set environment variables for Python
|
5 |
ENV PYTHONDONTWRITEBYTECODE=1 \
|
6 |
PYTHONUNBUFFERED=1 \
|
7 |
-
NUMBA_DISABLE_JIT=1
|
|
|
8 |
|
9 |
# Set the working directory
|
10 |
WORKDIR /app
|
@@ -12,8 +13,7 @@ WORKDIR /app
|
|
12 |
# Copy the requirements file into the container at /app
|
13 |
COPY requirements.txt /app/
|
14 |
|
15 |
-
# Install build dependencies
|
16 |
-
# This uses the default available LLVM/Clang versions for Debian Bookworm
|
17 |
RUN apt-get update && \
|
18 |
apt-get install -y --no-install-recommends \
|
19 |
llvm \
|
@@ -27,40 +27,33 @@ RUN apt-get update && \
|
|
27 |
libxrender1 \
|
28 |
libglib2.0-0 \
|
29 |
ffmpeg \
|
30 |
-
&&
|
31 |
-
rm -rf /var/lib/apt/lists/*
|
32 |
|
33 |
-
|
34 |
-
# Set LLVM_CONFIG environment variable *before* installing numba/llvmlite
|
35 |
-
# Use the version that apt-get install llvm provides (likely llvm-config-14 for Bookworm)
|
36 |
ENV LLVM_CONFIG=/usr/bin/llvm-config-14
|
37 |
|
38 |
-
# Install numpy first
|
39 |
-
# It's explicitly installed here to ensure it's available for numba's build process.
|
40 |
RUN pip install --no-cache-dir numpy==1.22.4
|
41 |
|
42 |
-
# Install
|
43 |
RUN pip install --no-cache-dir -r requirements.txt
|
44 |
|
45 |
-
# Copy the rest of the application
|
46 |
COPY . /app/
|
47 |
|
48 |
-
# Create necessary directories
|
49 |
RUN mkdir -p /app/cache /app/uploads /app/results /app/checkpoints /app/temp \
|
50 |
&& chmod -R 777 /app/cache /app/uploads /app/results /app/checkpoints /app/temp
|
51 |
|
52 |
-
# Ensure
|
53 |
RUN chmod -R 777 /app
|
54 |
|
55 |
-
#
|
56 |
-
ENV NUMBA_DISABLE_PER_FILE_CACHE=1
|
57 |
-
|
58 |
-
# Expose the port the app runs on
|
59 |
EXPOSE 7860
|
60 |
|
61 |
-
# Set environment variables
|
62 |
ENV FLASK_APP=app.py \
|
63 |
FLASK_ENV=production
|
64 |
|
65 |
-
#
|
66 |
CMD ["gunicorn", "-w", "1", "-b", "0.0.0.0:7860", "--timeout", "120", "app:app"]
|
|
|
1 |
# Use an official Python runtime as a parent image
|
2 |
FROM python:3.9-slim
|
3 |
|
4 |
+
# Set environment variables for Python and Numba
|
5 |
ENV PYTHONDONTWRITEBYTECODE=1 \
|
6 |
PYTHONUNBUFFERED=1 \
|
7 |
+
NUMBA_DISABLE_JIT=1 \
|
8 |
+
NUMBA_CACHE_DIR=/tmp/numba_cache
|
9 |
|
10 |
# Set the working directory
|
11 |
WORKDIR /app
|
|
|
13 |
# Copy the requirements file into the container at /app
|
14 |
COPY requirements.txt /app/
|
15 |
|
16 |
+
# Install build dependencies
|
|
|
17 |
RUN apt-get update && \
|
18 |
apt-get install -y --no-install-recommends \
|
19 |
llvm \
|
|
|
27 |
libxrender1 \
|
28 |
libglib2.0-0 \
|
29 |
ffmpeg \
|
30 |
+
&& rm -rf /var/lib/apt/lists/*
|
|
|
31 |
|
32 |
+
# Set LLVM_CONFIG before building llvmlite (if needed)
|
|
|
|
|
33 |
ENV LLVM_CONFIG=/usr/bin/llvm-config-14
|
34 |
|
35 |
+
# Install numpy first for numba compatibility
|
|
|
36 |
RUN pip install --no-cache-dir numpy==1.22.4
|
37 |
|
38 |
+
# Install Python dependencies
|
39 |
RUN pip install --no-cache-dir -r requirements.txt
|
40 |
|
41 |
+
# Copy the rest of the application
|
42 |
COPY . /app/
|
43 |
|
44 |
+
# Create necessary directories
|
45 |
RUN mkdir -p /app/cache /app/uploads /app/results /app/checkpoints /app/temp \
|
46 |
&& chmod -R 777 /app/cache /app/uploads /app/results /app/checkpoints /app/temp
|
47 |
|
48 |
+
# Ensure full permissions for app directory
|
49 |
RUN chmod -R 777 /app
|
50 |
|
51 |
+
# Expose the app port
|
|
|
|
|
|
|
52 |
EXPOSE 7860
|
53 |
|
54 |
+
# Set Flask environment variables
|
55 |
ENV FLASK_APP=app.py \
|
56 |
FLASK_ENV=production
|
57 |
|
58 |
+
# Start the application with Gunicorn
|
59 |
CMD ["gunicorn", "-w", "1", "-b", "0.0.0.0:7860", "--timeout", "120", "app:app"]
|