forked from nuclia/nucliadb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile.withbinding
117 lines (87 loc) · 4.01 KB
/
Dockerfile.withbinding
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
FROM python:3.11 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;
# Install system dependencies
COPY scripts/install-system-deps.sh /tmp/
RUN /tmp/install-system-deps.sh && rm /tmp/install-system-deps.sh
RUN apt-get update -y && apt-get install --yes --no-install-recommends patchelf cmake && apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
RUN pip install maturin
COPY . /nucliadb
WORKDIR /nucliadb
RUN set -eux; \
cd nucliadb_node_binding; \
maturin build --profile ${RUST_BUILD_PROFILE}
FROM python:3.11
ENV TIKV_CLIENT_VERSION=0.0.3
RUN ARCH="$(uname -m)"; \
case "$ARCH" in \
aarch64) pip install https://storage.googleapis.com/stashify-cdn/python/tikv_client-${TIKV_CLIENT_VERSION}-cp36-abi3-manylinux_2_31_aarch64.whl;; \
x86_64) pip install https://storage.googleapis.com/stashify-cdn/python/tikv_client-${TIKV_CLIENT_VERSION}-cp36-abi3-manylinux_2_31_x86_64.whl;; \
esac;
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
RUN pip install --upgrade pip wheel && \
pip install Cython==0.29.24 pybind11 uvicorn uvloop
RUN set -eux; \
dpkgArch="$(dpkg --print-architecture)"; \
case "${dpkgArch##*-}" in \
amd64) probeArch='amd64'; probeSha256='8d104fb997c9a5146a15a9c9f1fd45afa9d2dd995e185aeb96a19263fbd55b8a' ;; \
arm64) probeArch='arm64'; probeSha256='6a74ac6eebb173987dd4a68fa99b74b2e1bdd3e0c7cf634c0d823595fbb28609' ;; \
i386) probeArch='386'; probeSha256='eaed3339e273116d2c44a271d7245da1999b28a0c0bdf1d7b3aa75917712dc1a' ;; \
*) echo >&2 "unsupported architecture: ${dpkgArch}"; exit 1 ;; \
esac; \
curl -L -o /bin/grpc_health_probe https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/v0.4.17/grpc_health_probe-linux-${probeArch}; \
echo "${probeSha256} /bin/grpc_health_probe" | sha256sum -c -; \
chmod +x /bin/grpc_health_probe
# Install entrypoint.sh dependencies
RUN apt-get update && apt-get install -y jq
# Copy source code
COPY VERSION /usr/src/app/VERSION
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
WORKDIR /usr/src/app
RUN pip install -r nucliadb/requirements-sources.txt
RUN pip install -e /usr/src/app/nucliadb
# make sure to install the built wheel after so it is installed no matter what
COPY --from=python_rust /nucliadb/target/wheels/ /wheels/
RUN pip install /wheels/*.whl --force
RUN mkdir -p /data
ENV NUA_ZONE=europe-1
ENV NUA_API_KEY=
ENV NUCLIA_PUBLIC_URL=https://{zone}.nuclia.cloud
ENV DRIVER=LOCAL
ENV MAINDB=/data/maindb
ENV BLOB=/data/blobs
ENV NODE=/data/node
ENV HTTP_PORT=8080
ENV INGEST_GRPC_PORT=8060
ENV TRAIN_GRPC_PORT=8040
# HTTP
EXPOSE 8080/tcp
# GRPC
EXPOSE 8060/tcp
# GRPC - TRAIN
EXPOSE 8040/tcp
CMD ["nucliadb"]