Repository navigation
Expand file tree
/
Copy pathDockerfile
More file actions
141 lines (108 loc) · 5.11 KB
/
Copy pathDockerfile
File metadata and controls
141 lines (108 loc) · 5.11 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
ARG KAFKA_VERSION=4.3.1
ARG SCALA_VERSION=2.13
ARG UV_VERSION=0.10.0
# A stage of its own because `COPY --from` does not expand build args, and the
# version belongs in one place. Both the dev and runtime stages copy uv out of
# here: the task worker shells out to boompy for catalog sourcing, under
# cargo-watch in dev exactly as from the release binary in prod.
FROM ghcr.io/astral-sh/uv:${UV_VERSION} AS uv
FROM rust:slim-trixie AS base
ARG KAFKA_VERSION
ARG SCALA_VERSION
RUN apt-get update && \
apt-get install -y --no-install-recommends \
ca-certificates curl bash tar xz-utils gcc g++ python3 python3-venv libhdf5-dev \
perl make libsasl2-dev libsasl2-2 default-jre-headless pkg-config clang libclang-dev libcfitsio-dev && \
apt-get clean && rm -rf /var/lib/apt/lists/* && \
curl -fsSL https://dlcdn.apache.org/kafka/${KAFKA_VERSION}/kafka_${SCALA_VERSION}-${KAFKA_VERSION}.tgz -o /tmp/kafka.tgz && \
tar -xzf /tmp/kafka.tgz -C /opt && \
ln -s /opt/kafka_${SCALA_VERSION}-${KAFKA_VERSION} /opt/kafka && \
rm -f /tmp/kafka.tgz
COPY --from=uv /uv /uvx /usr/local/bin/
ENV PATH="/opt/kafka/bin:${PATH}"
ENV LIBCLANG_PATH=/usr/lib/llvm-19/lib
WORKDIR /app
FROM base AS chef
RUN cargo install --locked cargo-chef --version 0.1.78
FROM chef AS planner
COPY apache-avro-macros /app/apache-avro-macros
COPY Cargo.toml Cargo.lock build.rs /app/
COPY ./src /app/src
RUN cargo chef prepare --recipe-path recipe.json
FROM chef AS builder
ARG ONNXRUNTIME_GPU_VERSION=1.24.4
RUN python3 -m venv /opt/ort-py && \
/opt/ort-py/bin/pip install --no-cache-dir "onnxruntime==${ONNXRUNTIME_GPU_VERSION}" && \
true
RUN ORT_CAPI_DIR="$('/opt/ort-py/bin/python' -c 'import pathlib, onnxruntime as ort; print(pathlib.Path(ort.__file__).resolve().parent / "capi")')" && \
mkdir -p /opt/ort && \
cp "${ORT_CAPI_DIR}/libonnxruntime.so.${ONNXRUNTIME_GPU_VERSION}" /opt/ort/ && \
cp "${ORT_CAPI_DIR}/libonnxruntime_providers_shared.so" /opt/ort/ && \
rm -rf /opt/ort-py && ln -sf /opt/ort/libonnxruntime.so.${ONNXRUNTIME_GPU_VERSION} /opt/ort/libonnxruntime.so
COPY --from=planner /app/recipe.json /app/recipe.json
RUN cargo chef cook --release --recipe-path recipe.json
# Compiled into the binaries and recorded on every data mutation, so the ledger
# can name the commit that produced a change. Absent when unset -- the ledger
# records that honestly rather than inventing a value.
ARG BOOM_GIT_SHA
ENV BOOM_GIT_SHA=${BOOM_GIT_SHA}
COPY apache-avro-macros /app/apache-avro-macros
COPY Cargo.toml Cargo.lock build.rs /app/
# build.rs generates the Milvus gRPC bindings from these vendored protos into
# OUT_DIR; without them src/milvus/proto.rs has nothing to include!().
COPY ./proto /app/proto
COPY ./schemas /app/schemas
COPY ./src /app/src
RUN cargo build --release && \
mkdir -p /app/bin && \
cp target/release/scheduler \
target/release/kafka_consumer \
target/release/kafka_producer \
target/release/api \
target/release/task_worker \
target/release/linker \
/app/bin/
FROM builder AS dev
RUN cargo install --locked cargo-watch
# On Linux, `ort` uses the `load-dynamic` feature (Cargo.toml), so it looks up
# libonnxruntime.so at runtime instead of linking it in. These tell it where.
# The `app` stage repeats them; without them here the enrichment workers hang
# in SharedModels::load and never reach their queue loop.
ENV ORT_DYLIB_PATH=/opt/ort/libonnxruntime.so
ENV LD_LIBRARY_PATH=/opt/ort
CMD ["cargo", "watch", "-x", "run --bin api"]
FROM debian:trixie-slim AS app
ARG KAFKA_VERSION=4.3.1
ARG SCALA_VERSION=2.13
RUN apt-get update && \
apt-get install -y --no-install-recommends \
ca-certificates curl bash libsasl2-2 default-jre-headless libcfitsio10t64 && \
apt-get clean && rm -rf /var/lib/apt/lists/*
# boompy fetches archival catalogs -- see boompy/README.md. uv manages both the
# interpreter and the dependencies, so there is no system Python to keep in step
# with the lockfile.
COPY --from=uv /uv /uvx /usr/local/bin/
ENV ORT_DYLIB_PATH=/opt/ort/libonnxruntime.so
ENV LD_LIBRARY_PATH=/opt/ort
COPY --from=builder /opt/kafka_${SCALA_VERSION}-${KAFKA_VERSION} /opt/kafka
ENV PATH="/opt/kafka/bin:${PATH}"
WORKDIR /app
COPY --from=builder /app/bin/scheduler /app/scheduler
COPY --from=builder /app/bin/kafka_consumer /app/kafka_consumer
COPY --from=builder /app/bin/kafka_producer /app/kafka_producer
COPY --from=builder /app/bin/api /app/boom-api
COPY --from=builder /app/bin/task_worker /app/task_worker
COPY --from=builder /app/bin/linker /app/linker
COPY --from=builder /opt/ort /opt/ort
RUN mkdir -p /app/data/kernels && \
curl -fsSL -o /app/data/kernels/de440s.bsp https://naif.jpl.nasa.gov/pub/naif/generic_kernels/spk/planets/de440s.bsp && \
chmod 644 /app/data/kernels/de440s.bsp
# Resolved at build time from the committed lockfile, so a catalog ingest does
# not depend on PyPI being reachable -- or on resolving to different versions
# than the ones the tests ran against.
COPY boompy /app/boompy
ENV UV_PROJECT_ENVIRONMENT=/app/boompy/.venv
ENV BOOM_BOOMPY_PATH=/app/boompy
RUN uv sync --project /app/boompy --frozen --no-dev
# Temporary
CMD ["/app/scheduler"]