Malaji71 commited on
Commit
f810e6d
·
verified ·
1 Parent(s): f5e9a57

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +40 -34
Dockerfile CHANGED
@@ -7,69 +7,70 @@ WORKDIR /app
7
  # Prevent interactive prompts
8
  ENV DEBIAN_FRONTEND=noninteractive
9
 
10
- # Install system dependencies for Real-ESRGAN
11
  RUN apt-get update && apt-get install -y \
12
  # Build essentials
13
  build-essential \
14
  cmake \
15
  pkg-config \
 
 
 
16
  # OpenCV dependencies
17
  libopencv-dev \
18
- python3-opencv \
19
- # Graphics libraries
20
  libgl1-mesa-dev \
21
  libglu1-mesa-dev \
22
- # X11 libraries
23
  libx11-dev \
24
  libxext-dev \
25
  libxrender-dev \
26
- # Image/video processing
 
 
 
27
  ffmpeg \
28
  libavcodec-dev \
29
  libavformat-dev \
30
  libswscale-dev \
31
- # Additional libraries
32
- libglib2.0-0 \
33
- libsm6 \
34
- libgomp1 \
35
- # Download tools
36
- wget \
37
- curl \
38
- git \
39
- # Clean up
40
  && rm -rf /var/lib/apt/lists/* \
41
  && apt-get clean
42
 
43
- # Upgrade pip and install wheel
44
  RUN pip install --upgrade pip setuptools wheel
45
 
46
- # Install PyTorch first (CPU version for compatibility)
 
 
 
47
  RUN pip install --no-cache-dir torch==2.0.1 torchvision==0.15.2 --index-url https://download.pytorch.org/whl/cpu
48
 
49
- # Install core dependencies first
50
  RUN pip install --no-cache-dir \
51
  Flask==2.3.3 \
52
  Werkzeug==2.3.7 \
53
  Pillow==10.0.1 \
54
- numpy==1.24.4 \
55
  opencv-python-headless==4.8.1.78 \
56
- scipy==1.11.4 \
57
- tqdm==4.66.1 \
58
- pyyaml==6.0.1 \
59
- requests==2.31.0
60
 
61
- # Install Real-ESRGAN dependencies step by step
62
  RUN pip install --no-cache-dir \
 
 
 
63
  addict==2.4.0 \
64
  future==0.18.3 \
65
  lmdb==1.4.1 \
66
  yapf==0.40.2 \
67
  filterpy==1.4.5
68
 
69
- # Install BasicSR first (Real-ESRGAN dependency)
70
  RUN pip install --no-cache-dir basicsr==1.4.2
71
 
72
- # Install remaining Real-ESRGAN dependencies
73
  RUN pip install --no-cache-dir \
74
  facexlib==0.3.0 \
75
  gfpgan==1.3.8
@@ -77,17 +78,21 @@ RUN pip install --no-cache-dir \
77
  # Finally install Real-ESRGAN
78
  RUN pip install --no-cache-dir realesrgan==0.3.0
79
 
80
- # Copy requirements for verification
81
- COPY requirements.txt .
82
-
83
  # Copy application files
84
- COPY . .
 
 
 
85
 
86
- # Create necessary directories
87
- RUN mkdir -p /data/uploads /data/outputs /data/models
 
88
 
89
- # Test Real-ESRGAN installation - FIXED SYNTAX
90
- RUN python -c "from realesrgan import RealESRGANer; from basicsr.archs.rrdbnet_arch import RRDBNet; print(' Real-ESRGAN import successful')"
 
 
 
91
 
92
  # Set environment variables
93
  ENV PYTHONUNBUFFERED=1
@@ -95,13 +100,14 @@ ENV FLASK_APP=app.py
95
  ENV FLASK_ENV=production
96
  ENV TORCH_HOME=/data/models
97
  ENV OPENCV_LOG_LEVEL=ERROR
 
98
 
99
  # Expose port
100
  EXPOSE 7860
101
 
102
  # Health check
103
  HEALTHCHECK --interval=30s --timeout=30s --start-period=15s --retries=3 \
104
- CMD curl -f http://localhost:7860/ || exit 1
105
 
106
  # Run the application
107
  CMD ["python", "app.py"]
 
7
  # Prevent interactive prompts
8
  ENV DEBIAN_FRONTEND=noninteractive
9
 
10
+ # Install system dependencies
11
  RUN apt-get update && apt-get install -y \
12
  # Build essentials
13
  build-essential \
14
  cmake \
15
  pkg-config \
16
+ git \
17
+ wget \
18
+ curl \
19
  # OpenCV dependencies
20
  libopencv-dev \
21
+ # Graphics and video libraries
 
22
  libgl1-mesa-dev \
23
  libglu1-mesa-dev \
 
24
  libx11-dev \
25
  libxext-dev \
26
  libxrender-dev \
27
+ libglib2.0-0 \
28
+ libsm6 \
29
+ libgomp1 \
30
+ # Video processing
31
  ffmpeg \
32
  libavcodec-dev \
33
  libavformat-dev \
34
  libswscale-dev \
35
+ # Additional dependencies
36
+ libjpeg-dev \
37
+ libpng-dev \
38
+ libtiff-dev \
 
 
 
 
 
39
  && rm -rf /var/lib/apt/lists/* \
40
  && apt-get clean
41
 
42
+ # Upgrade pip and install essential tools
43
  RUN pip install --upgrade pip setuptools wheel
44
 
45
+ # Install numpy first (critical for all other packages)
46
+ RUN pip install --no-cache-dir numpy==1.24.4
47
+
48
+ # Install PyTorch CPU version
49
  RUN pip install --no-cache-dir torch==2.0.1 torchvision==0.15.2 --index-url https://download.pytorch.org/whl/cpu
50
 
51
+ # Install core dependencies
52
  RUN pip install --no-cache-dir \
53
  Flask==2.3.3 \
54
  Werkzeug==2.3.7 \
55
  Pillow==10.0.1 \
 
56
  opencv-python-headless==4.8.1.78 \
57
+ scipy==1.11.4
 
 
 
58
 
59
+ # Install Real-ESRGAN dependencies in correct order
60
  RUN pip install --no-cache-dir \
61
+ tqdm==4.66.1 \
62
+ pyyaml==6.0.1 \
63
+ requests==2.31.0 \
64
  addict==2.4.0 \
65
  future==0.18.3 \
66
  lmdb==1.4.1 \
67
  yapf==0.40.2 \
68
  filterpy==1.4.5
69
 
70
+ # Install BasicSR (Real-ESRGAN's core dependency)
71
  RUN pip install --no-cache-dir basicsr==1.4.2
72
 
73
+ # Install face-related dependencies
74
  RUN pip install --no-cache-dir \
75
  facexlib==0.3.0 \
76
  gfpgan==1.3.8
 
78
  # Finally install Real-ESRGAN
79
  RUN pip install --no-cache-dir realesrgan==0.3.0
80
 
 
 
 
81
  # Copy application files
82
+ COPY requirements.txt .
83
+ COPY *.py .
84
+ COPY templates/ templates/ 2>/dev/null || true
85
+ COPY static/ static/ 2>/dev/null || true
86
 
87
+ # Create necessary directories with proper permissions
88
+ RUN mkdir -p /data/uploads /data/outputs /data/models && \
89
+ chmod 755 /data /data/uploads /data/outputs /data/models
90
 
91
+ # Test installations
92
+ RUN python -c "import numpy; print(f'NumPy version: {numpy.__version__}')" && \
93
+ python -c "import torch; print(f'PyTorch version: {torch.__version__}')" && \
94
+ python -c "import cv2; print(f'OpenCV version: {cv2.__version__}')" && \
95
+ python -c "from realesrgan import RealESRGANer; from basicsr.archs.rrdbnet_arch import RRDBNet; print('✅ Real-ESRGAN import successful')"
96
 
97
  # Set environment variables
98
  ENV PYTHONUNBUFFERED=1
 
100
  ENV FLASK_ENV=production
101
  ENV TORCH_HOME=/data/models
102
  ENV OPENCV_LOG_LEVEL=ERROR
103
+ ENV NUMBA_CACHE_DIR=/tmp/numba_cache
104
 
105
  # Expose port
106
  EXPOSE 7860
107
 
108
  # Health check
109
  HEALTHCHECK --interval=30s --timeout=30s --start-period=15s --retries=3 \
110
+ CMD curl -f http://localhost:7860/api/system || exit 1
111
 
112
  # Run the application
113
  CMD ["python", "app.py"]