-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
42 lines (27 loc) · 861 Bytes
/
Dockerfile
File metadata and controls
42 lines (27 loc) · 861 Bytes
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
42
FROM python:3.11-slim AS builder
WORKDIR /app
# Create a virtual environment
RUN python -m venv venv
# Activate the virtual environment
ENV VIRTUAL_ENV=/app/venv
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
# Upgrade pip
RUN pip install --upgrade pip
# Copy requirements first for better caching
COPY requirements.txt .
# Install dependencies
RUN pip install --no-cache-dir -r requirements.txt
# Copy only the source code
COPY src/ .
FROM python:3.11-slim
WORKDIR /app
# Copy the virtual environment folders
COPY --from=builder /app/venv/bin /app/venv/bin
COPY --from=builder /app/venv/lib /app/venv/lib
# Copy only the source code
COPY --from=builder /app /app/
# Activate the virtual environment and set the PATH to include the bin folder of venv
ENV VIRTUAL_ENV=/app/venv
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
EXPOSE 8501
CMD ["streamlit", "run", "app.py"]