-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
64 lines (48 loc) · 2.07 KB
/
Copy pathDockerfile
File metadata and controls
64 lines (48 loc) · 2.07 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
55
56
57
58
59
60
61
62
63
64
# QuantLab container image.
# Build: docker build -t quantlab .
# Run the offline demo:
# docker run --rm quantlab backtest --shipped-config demo_offline
FROM python:3.12-slim@sha256:229a2c5bfa27522db7815ea81f9bed70af17ccb9de9fc7ad142b1877b5830d36 AS builder
ENV PYTHONDONTWRITEBYTECODE=1 \
PIP_NO_CACHE_DIR=1 \
UV_PROJECT_ENVIRONMENT=/opt/venv
WORKDIR /build
# Compilers remain confined to the builder for packages without compatible wheels.
RUN apt-get update && apt-get install -y --no-install-recommends build-essential \
&& rm -rf /var/lib/apt/lists/* \
&& python -m pip install "uv==0.12.3"
COPY pyproject.toml uv.lock README.md LICENSE ./
COPY src ./src
# Hatchling resolves forced includes while installing the non-editable package.
COPY configs ./configs
COPY data/raw/SPY.csv data/raw/QQQ.csv data/raw/TLT.csv data/raw/GLD.csv ./data/raw/
# Consume the same lockfile as CI and install only runtime dashboard/data extras.
RUN uv sync --locked --no-dev --extra dashboard --extra yahoo --no-editable
FROM python:3.12-slim@sha256:229a2c5bfa27522db7815ea81f9bed70af17ccb9de9fc7ad142b1877b5830d36 AS runtime
ARG QUANTLAB_UID=1000
ARG QUANTLAB_GID=1000
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
GIT_PYTHON_REFRESH=quiet \
STREAMLIT_BROWSER_GATHER_USAGE_STATS=false \
PATH=/opt/venv/bin:$PATH \
HOME=/home/quantlab
RUN groupadd --gid "$QUANTLAB_GID" quantlab \
&& useradd --uid "$QUANTLAB_UID" --gid "$QUANTLAB_GID" \
--create-home --shell /usr/sbin/nologin quantlab
COPY --from=builder /opt/venv /opt/venv
RUN mkdir -p \
/home/quantlab/.quantlab/data/raw \
/home/quantlab/.quantlab/data/processed \
/home/quantlab/.quantlab/data/metadata \
/home/quantlab/.quantlab/data/cache \
/home/quantlab/.quantlab/reports/generated \
/home/quantlab/.quantlab/reports/figures \
/home/quantlab/.quantlab/reports/tables \
/home/quantlab/.quantlab/logs \
&& chown -R quantlab:quantlab /home/quantlab
USER quantlab
WORKDIR /home/quantlab
EXPOSE 8501
ENTRYPOINT ["quantlab"]
CMD ["--help"]