admin08077 commited on
Commit
20a2ec5
·
verified ·
1 Parent(s): aab002d

Create Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +62 -0
Dockerfile ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Use a stable Python 3.10 base image (buster-slim) for better compatibility with Pillow build.
2
+ # This is a CPU-only base image.
3
+ FROM python:3.10-slim-buster
4
+
5
+ # Set the working directory in the container
6
+ WORKDIR /app
7
+
8
+ # Install system dependencies
9
+ # These are commonly needed for Python packages like Pillow (for image processing)
10
+ # and for general development utilities.
11
+ RUN apt-get update && apt-get install -y \
12
+ build-essential \
13
+ libgl1-mesa-glx \
14
+ libgomp1 \
15
+ git \
16
+ git-lfs \
17
+ ffmpeg \
18
+ libsm6 \
19
+ libxext6 \
20
+ cmake \
21
+ rsync \
22
+ && rm -rf /var/lib/apt/lists/* \
23
+ && git lfs install
24
+
25
+ # --- OPTIONAL: CUDA/GPU Installation (uncomment ONLY if you need GPU and select GPU hardware) ---
26
+ # If you enable these lines, make sure your Hugging Face Space has GPU hardware selected.
27
+ # Otherwise, keep them commented out for CPU-only deployment.
28
+ # These steps are for installing CUDA toolkit and PyTorch with CUDA support on a slim-buster image.
29
+ # You would replace the PyTorch and CUDA versions with what you need.
30
+ # ENV CUDA_VERSION=11.8
31
+ # ENV CUDNN_VERSION=8
32
+ # ENV PATH=/usr/local/nvidia/bin:/usr/local/cuda/bin:${PATH}
33
+ # ENV LD_LIBRARY_PATH=/usr/local/nvidia/lib:/usr/local/nvidia/lib64:/usr/local/cuda/lib64:${LD_LIBRARY_PATH}
34
+ # RUN apt-get update && apt-get install -y --no-install-recommends \
35
+ # cuda-keyring-11-8 \
36
+ # cuda-toolkit-11-8 \
37
+ # libcudnn8=${CUDNN_VERSION}.*-1+cuda${CUDA_VERSION} \
38
+ # libcudnn8-dev=${CUDNN_VERSION}.*-1+cuda${CUDA_VERSION} \
39
+ # && rm -rf /var/lib/apt/lists/*
40
+ # RUN pip install --no-cache-dir torch==2.1.0 torchvision==0.16.0 torchaudio==2.1.0 --index-url https://download.pytorch.org/whl/cu118
41
+ # ENV USE_GPU=true
42
+ # --- END OPTIONAL CUDA/GPU Installation ---
43
+
44
+ # Copy the requirements file into the container
45
+ COPY requirements.txt .
46
+
47
+ # Install Python dependencies from requirements.txt
48
+ RUN pip install --no-cache-dir -r requirements.txt
49
+
50
+ # Copy the application code into the container
51
+ COPY app.py .
52
+
53
+ # Expose the port Flask runs on
54
+ EXPOSE 5000
55
+
56
+ # Set an environment variable for GPU usage.
57
+ # If you uncommented the CUDA installation above, USE_GPU should be true.
58
+ # Otherwise, for CPU-only, keep it false.
59
+ ENV USE_GPU=false # Set to 'true' if you uncommented the CUDA/PyTorch installation above
60
+
61
+ # Command to run the Flask application using gunicorn for production serving.
62
+ CMD ["gunicorn", "--bind", "0.0.0.0:5000", "app:app"]