-
Notifications
You must be signed in to change notification settings - Fork 58
Expand file tree
/
Copy pathDockerfile.withbinding
More file actions
108 lines (87 loc) · 3.51 KB
/
Dockerfile.withbinding
File metadata and controls
108 lines (87 loc) · 3.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
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
#
# This Dockerfile build nucliadb with the binding.
# It's a copy of `Dockerfile` adding the additional `python_rust` stage.
#
#
# Stage to build nidx_binding (with Rust)
#
FROM python:3.14-trixie AS python_rust
ARG RUST_BUILD_PROFILE=release
ENV RUSTUP_HOME=/usr/local/rustup \
CARGO_HOME=/usr/local/cargo \
PATH=/usr/local/cargo/bin:$PATH
COPY rust-toolchain.toml /tmp
WORKDIR /tmp
RUN set -eux; \
dpkgArch="$(dpkg --print-architecture)"; \
case "${dpkgArch##*-}" in \
amd64) rustArch='x86_64-unknown-linux-gnu'; rustupSha256='3dc5ef50861ee18657f9db2eeb7392f9c2a6c95c90ab41e45ab4ca71476b4338' ;; \
armhf) rustArch='armv7-unknown-linux-gnueabihf'; rustupSha256='67777ac3bc17277102f2ed73fd5f14c51f4ca5963adadf7f174adf4ebc38747b' ;; \
arm64) rustArch='aarch64-unknown-linux-gnu'; rustupSha256='32a1532f7cef072a667bac53f1a5542c99666c4071af0c9549795bbdb2069ec1' ;; \
i386) rustArch='i686-unknown-linux-gnu'; rustupSha256='e50d1deb99048bc5782a0200aa33e4eea70747d49dffdc9d06812fd22a372515' ;; \
*) echo >&2 "unsupported architecture: ${dpkgArch}"; exit 1 ;; \
esac; \
rustVersion=$(awk -F '=' '/channel/ {print $2}' rust-toolchain.toml | tr -d '" '); \
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal --default-toolchain ${rustVersion} --default-host ${rustArch}; \
chmod -R a+w $RUSTUP_HOME $CARGO_HOME; \
rustup --version; \
cargo --version; \
rustc --version;
RUN apt update && apt install -y protobuf-compiler
RUN pip install maturin
COPY . /nucliadb
WORKDIR /nucliadb
RUN set -eux; \
cd nidx/nidx_binding; \
maturin build --profile ${RUST_BUILD_PROFILE}
#
# This stage builds a virtual env with all dependencies
#
FROM python:3.14-slim-trixie AS builder
RUN pip install uv
# Install Python dependencies
WORKDIR /usr/src/app
COPY pyproject.toml uv.lock ./
RUN python -m venv /app && VIRTUAL_ENV=/app uv sync --active --no-dev --no-group nidx --no-group sdk --no-install-workspace --frozen
# Copy application
COPY VERSION pyproject.toml uv.lock /usr/src/app/
COPY nucliadb_utils /usr/src/app/nucliadb_utils
COPY nucliadb_telemetry /usr/src/app/nucliadb_telemetry
COPY nucliadb_protos /usr/src/app/nucliadb_protos
COPY nucliadb_models /usr/src/app/nucliadb_models
COPY nucliadb /usr/src/app/nucliadb
COPY nidx /usr/src/app/nidx
# Copy stubs for packages we won't install
COPY nucliadb_sdk/pyproject.toml /usr/src/app/nucliadb_sdk/pyproject.toml
COPY nucliadb_dataset/pyproject.toml /usr/src/app/nucliadb_dataset/pyproject.toml
# Install our packages to the virtualenv
RUN VIRTUAL_ENV=/app uv sync --active --no-dev --no-editable --no-group sdk --no-group nidx --compile-bytecode
# make sure to install the built wheel after so it is installed no matter what
COPY --from=python_rust /nucliadb/nidx/target/wheels/ /wheels/
RUN /app/bin/pip install /wheels/*.whl --force
#
# This is the main image, it just copies the virtual env into the base image
#
FROM python:3.14-slim-trixie
# media-types needed for content type checks (python mimetype module uses this)
RUN apt update && apt install -y media-types && apt clean && rm -rf /var/lib/apt/lists/*
COPY --from=builder /app /app
RUN mkdir -p /data
ENV NUA_ZONE=europe-1
ENV NUA_API_KEY=
ENV NUCLIA_PUBLIC_URL=https://{zone}.nuclia.cloud
ENV PYTHONUNBUFFERED=1
ENV DRIVER=LOCAL
ENV HTTP_PORT=8080
ENV INGEST_GRPC_PORT=8060
ENV TRAIN_GRPC_PORT=8040
ENV LOG_OUTPUT_TYPE=stdout
# HTTP
EXPOSE 8080/tcp
# GRPC - INGEST
EXPOSE 8060/tcp
# GRPC - TRAIN
EXPOSE 8040/tcp
ENV PATH="/app/bin:$PATH"
WORKDIR /app
CMD ["nucliadb"]