-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
54 lines (41 loc) · 2.44 KB
/
Dockerfile
File metadata and controls
54 lines (41 loc) · 2.44 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
45
46
47
48
49
50
51
52
53
54
FROM python:3.11-slim
WORKDIR /app
# Install system dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
curl \
&& rm -rf /var/lib/apt/lists/*
# ── Install Julia ────────────────────────────────────────────────────────────
ENV JULIA_VERSION=1.12.4
ENV JULIA_PATH=/opt/julia
ENV PATH="${JULIA_PATH}/bin:${PATH}"
# juliacall signal handling (required for Python↔Julia interop)
ENV PYTHON_JULIACALL_HANDLE_SIGNALS=yes
# Use all available cores for Julia threading
ENV JULIA_NUM_THREADS=auto
RUN curl -fsSL "https://julialang-s3.julialang.org/bin/linux/x64/1.12/julia-${JULIA_VERSION}-linux-x86_64.tar.gz" \
| tar -xz -C /opt \
&& mv /opt/julia-${JULIA_VERSION} ${JULIA_PATH}
# ── Install Python dependencies ──────────────────────────────────────────────
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# ── Copy Julia project and precompile ────────────────────────────────────────
# Copy Julia project first (changes less often → better layer caching)
COPY julia/ /app/julia/
RUN julia --project=/app/julia -e ' \
using Pkg; \
Pkg.instantiate(); \
Pkg.precompile(); \
'
# ── Precompile juliacall/PythonCall bridge ───────────────────────────────────
# This avoids a multi-minute delay on the first request in the container.
# juliacall discovers Julia on PATH, installs PythonCall.jl, and precompiles.
# We also warm-load HypertensionSim so the module is fully cached.
COPY scripts/warmup_julia.py /tmp/warmup_julia.py
RUN python /tmp/warmup_julia.py && rm /tmp/warmup_julia.py
# ── Copy application ────────────────────────────────────────────────────────
COPY . .
EXPOSE 8501
# Health check — Julia init is precompiled, but Streamlit still needs ~15s
HEALTHCHECK --interval=30s --timeout=10s --start-period=30s --retries=3 \
CMD curl --fail http://localhost:8501/_stcore/health || exit 1
ENTRYPOINT ["streamlit", "run", "streamlit_app.py", "--server.port=8501", "--server.address=0.0.0.0"]