-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
44 lines (36 loc) · 1.48 KB
/
Copy pathDockerfile
File metadata and controls
44 lines (36 loc) · 1.48 KB
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
43
44
# ==========================================
# Stage 1: The Base Environment
# ==========================================
# We start with a slimmed-down Linux image that has Python 3.11 pre-installed
FROM python:3.11-slim AS base
# Prevent Python from writing .pyc files and keep stdout/stderr unbuffered for clean logging
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
PIP_NO_CACHE_DIR=off
WORKDIR /workspace
# Install system tools needed to compile certain Python ML packages
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
curl \
&& rm -rf /var/lib/apt/lists/*
# Copy your dependencies list and install them inside the image
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Copy your actual application code into the image
COPY app/ ./app/
COPY main.py .
COPY streamlit_app.py .
# ==========================================
# Stage 2: The Backend Runtime
# ==========================================
FROM base AS backend
RUN python -c "from sentence_transformers import SentenceTransformer; SentenceTransformer('all-MiniLM-L6-v2')"
EXPOSE 8080
CMD ["sh", "-c", "uvicorn main:app --host 0.0.0.0 --port ${PORT:-8080}"]
# ==========================================
# Stage 3: The Frontend Runtime
# ==========================================
FROM base AS frontend
EXPOSE 8501
# Point this directly to your root-level UI file!
CMD ["streamlit", "run", "streamlit_app.py", "--server.port=8501", "--server.address=0.0.0.0"]