MaroofTechSorcerer commited on
Commit
51c2389
·
verified ·
1 Parent(s): 371555e

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +12 -8
Dockerfile CHANGED
@@ -1,8 +1,8 @@
1
  FROM python:3.10-slim
2
 
3
- # Set environment variables to reduce pip caching and ensure consistent builds
4
- ENV PIP_NO_CACHE_DIR=1
5
  ENV PYTHONUNBUFFERED=1
 
6
 
7
  # Install system dependencies from apt.txt
8
  COPY apt.txt .
@@ -10,21 +10,25 @@ RUN apt-get update && \
10
  xargs -a apt.txt apt-get install -y && \
11
  rm -rf /var/lib/apt/lists/*
12
 
13
- # Upgrade pip to avoid dependency resolution issues
 
 
 
 
14
  RUN pip install --upgrade pip
15
 
 
 
 
 
16
  # Set working directory
17
  WORKDIR /app
18
 
19
- # Copy requirements and install
20
- COPY requirements.txt .
21
- RUN pip install -r requirements.txt
22
-
23
  # Copy app code
24
  COPY app.py .
25
 
26
  # Expose port for Hugging Face Spaces
27
  EXPOSE 7860
28
 
29
- # Run Streamlit app
30
  CMD ["streamlit", "run", "app.py", "--server.port=7860", "--server.address=0.0.0.0"]
 
1
  FROM python:3.10-slim
2
 
3
+ # Set environment variables for consistent builds
 
4
  ENV PYTHONUNBUFFERED=1
5
+ ENV VENV_PATH=/opt/venv
6
 
7
  # Install system dependencies from apt.txt
8
  COPY apt.txt .
 
10
  xargs -a apt.txt apt-get install -y && \
11
  rm -rf /var/lib/apt/lists/*
12
 
13
+ # Create and activate virtual environment
14
+ RUN python -m venv $VENV_PATH
15
+ ENV PATH="$VENV_PATH/bin:$PATH"
16
+
17
+ # Upgrade pip in virtual environment
18
  RUN pip install --upgrade pip
19
 
20
+ # Install Python dependencies in virtual environment
21
+ COPY requirements.txt .
22
+ RUN pip install --no-cache-dir -r requirements.txt
23
+
24
  # Set working directory
25
  WORKDIR /app
26
 
 
 
 
 
27
  # Copy app code
28
  COPY app.py .
29
 
30
  # Expose port for Hugging Face Spaces
31
  EXPOSE 7860
32
 
33
+ # Run Streamlit app using virtual environment
34
  CMD ["streamlit", "run", "app.py", "--server.port=7860", "--server.address=0.0.0.0"]