Poojasreeh commited on
Commit
40eabe2
·
verified ·
1 Parent(s): 5a6dd01

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +29 -11
Dockerfile CHANGED
@@ -1,30 +1,48 @@
1
- # Use Python 3.11 slim for prebuilt wheels
2
- FROM python:3.11-slim
3
 
4
- # Set working directory
5
  WORKDIR /app
6
 
7
- # Install system dependencies required by some Python packages
8
  RUN apt-get update && apt-get install -y \
9
  build-essential \
10
- curl \
11
  git \
 
12
  libgomp1 \
13
  && rm -rf /var/lib/apt/lists/*
14
 
15
- # Copy requirements and source code
 
 
 
16
  COPY requirements.txt ./
 
 
 
 
 
17
  COPY src/ ./src/
18
 
19
- # Upgrade pip and install Python dependencies
20
- RUN pip install --upgrade pip
21
- RUN pip install -r requirements.txt
 
 
 
 
 
 
 
 
 
 
 
22
 
23
  # Expose Streamlit port
24
  EXPOSE 8501
25
 
26
- # Healthcheck for Streamlit
27
  HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health || exit 1
28
 
29
- # Run the Streamlit app
30
  ENTRYPOINT ["streamlit", "run", "src/streamlit_app.py", "--server.port=8501", "--server.address=0.0.0.0"]
 
1
+ # ---- Build stage ----
2
+ FROM python:3.11-slim AS build
3
 
 
4
  WORKDIR /app
5
 
6
+ # Install build dependencies
7
  RUN apt-get update && apt-get install -y \
8
  build-essential \
 
9
  git \
10
+ curl \
11
  libgomp1 \
12
  && rm -rf /var/lib/apt/lists/*
13
 
14
+ # Upgrade pip
15
+ RUN pip install --upgrade pip
16
+
17
+ # Copy requirements
18
  COPY requirements.txt ./
19
+
20
+ # Install dependencies into a temporary directory
21
+ RUN pip install --prefix=/install -r requirements.txt
22
+
23
+ # Copy application code
24
  COPY src/ ./src/
25
 
26
+ # ---- Runtime stage ----
27
+ FROM python:3.11-slim
28
+
29
+ WORKDIR /app
30
+
31
+ # Install runtime dependencies only
32
+ RUN apt-get update && apt-get install -y libgomp1 curl git \
33
+ && rm -rf /var/lib/apt/lists/*
34
+
35
+ # Copy installed Python packages from build stage
36
+ COPY --from=build /install /usr/local
37
+
38
+ # Copy application code
39
+ COPY --from=build /app/src ./src
40
 
41
  # Expose Streamlit port
42
  EXPOSE 8501
43
 
44
+ # Healthcheck
45
  HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health || exit 1
46
 
47
+ # Entry point
48
  ENTRYPOINT ["streamlit", "run", "src/streamlit_app.py", "--server.port=8501", "--server.address=0.0.0.0"]