-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
44 lines (31 loc) · 1.51 KB
/
Copy pathDockerfile
File metadata and controls
44 lines (31 loc) · 1.51 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: Build & Dependencies ───────────────────────────────────────────
FROM python:3.11-slim AS builder
WORKDIR /app
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
&& rm -rf /var/lib/apt/lists/*
COPY requirements.txt .
RUN pip install --no-cache-dir --prefix=/install -r requirements.txt
# ── Stage 2: Production Runtime ──────────────────────────────────────────────
FROM python:3.11-slim AS runtime
WORKDIR /app
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
PATH="/install/bin:${PATH}" \
PYTHONPATH="/install/lib/python3.11/site-packages:${PYTHONPATH}"
# Copy installed dependencies from builder
COPY --from=builder /install /install
# Copy project files
COPY . .
# Create persistent directories with appropriate permissions
RUN mkdir -p data/raw data/interim data/processed reports logs && \
chmod -R 777 data reports logs
# Default port for Streamlit
EXPOSE 8501
# Healthcheck for Streamlit app
HEALTHCHECK --interval=30s --timeout=5s --start-period=5s --retries=3 \
CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:8501/_stcore/health')" || exit 1
# Default entrypoint runs Streamlit dashboard
CMD ["streamlit", "run", "app.py", "--server.address=0.0.0.0", "--server.port=8501"]