File size: 1,173 Bytes
8161e41
1e6188d
0b927d0
8161e41
 
 
 
fcd6a9a
 
a837002
f12cf77
 
1e6188d
8161e41
 
 
1e6188d
 
 
3fdcc52
f12cf77
1e6188d
ecaff12
fcd6a9a
 
 
 
8161e41
ecaff12
fcd6a9a
1e6188d
ecaff12
fcd6a9a
 
0b927d0
fcd6a9a
1e6188d
ecaff12
fcd6a9a
8161e41
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
# Step 1: Use an official Python base image
FROM python:3.9-slim

# Step 2: Set environment variables to prevent Python from writing .pyc files and to ensure the app runs in the background
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1

# Step 3: Set environment variables for torch cache directory and disable caching
ENV TORCH_HOME=/app/.cache
ENV TORCH_HUB_NO_CACHE=1

# Step 4: Install system dependencies
RUN apt-get update && apt-get install -y \
    gcc \
    g++ \
    make \
    libgl1-mesa-glx \
    libglib2.0-0 \
    && rm -rf /var/lib/apt/lists/*

# Step 5: Set the working directory inside the container
WORKDIR /app

# Step 6: Create the cache directory and ensure it's writable
RUN mkdir -p /app/.cache && chmod -R 777 /app/.cache

# Step 7: Copy the requirements file into the container
COPY requirements.txt /app/

# Step 8: Install the Python dependencies
RUN pip install --no-cache-dir -r requirements.txt

# Step 9: Copy the rest of the application files into the container
COPY . /app/

# Step 10: Expose the port that the Flask app will run on
EXPOSE 5000

# Step 11: Set the entry point to start the Flask application
CMD ["python", "app.py"]