2023-10-27 20:41:22 +00:00
|
|
|
ARG UBUNTU_VERSION=22.04
|
|
|
|
|
# This needs to generally match the container host's environment.
|
|
|
|
|
ARG CUDA_VERSION=11.7.1
|
|
|
|
|
# Target the CUDA build image
|
|
|
|
|
ARG BASE_CUDA_DEV_CONTAINER=nvidia/cuda:${CUDA_VERSION}-devel-ubuntu${UBUNTU_VERSION}
|
|
|
|
|
# Target the CUDA runtime image
|
|
|
|
|
ARG BASE_CUDA_RUN_CONTAINER=nvidia/cuda:${CUDA_VERSION}-runtime-ubuntu${UBUNTU_VERSION}
|
2023-05-26 01:18:22 +00:00
|
|
|
|
2023-10-27 20:41:22 +00:00
|
|
|
FROM ${BASE_CUDA_DEV_CONTAINER} as build
|
2023-05-27 07:05:56 +00:00
|
|
|
|
2023-11-19 22:08:57 +00:00
|
|
|
# Rust toolchain version
|
2023-11-30 15:36:42 +00:00
|
|
|
ARG RUST_TOOLCHAIN=stable
|
2023-11-19 22:08:57 +00:00
|
|
|
|
2023-09-08 02:23:57 +00:00
|
|
|
ENV DEBIAN_FRONTEND=noninteractive
|
2023-05-26 01:18:22 +00:00
|
|
|
RUN apt-get update && \
|
|
|
|
|
apt-get install -y --no-install-recommends \
|
2023-05-27 07:05:56 +00:00
|
|
|
curl \
|
2023-05-26 01:18:22 +00:00
|
|
|
pkg-config \
|
|
|
|
|
libssl-dev \
|
2023-06-11 05:46:25 +00:00
|
|
|
protobuf-compiler \
|
2023-08-29 10:19:54 +00:00
|
|
|
git \
|
2023-09-07 02:21:46 +00:00
|
|
|
cmake \
|
2023-05-26 01:18:22 +00:00
|
|
|
&& \
|
|
|
|
|
apt-get clean && \
|
|
|
|
|
rm -rf /var/lib/apt/lists/*
|
|
|
|
|
|
|
|
|
|
# setup rust.
|
2023-11-19 00:06:56 +00:00
|
|
|
RUN curl https://sh.rustup.rs -sSf | bash -s -- --default-toolchain ${RUST_TOOLCHAIN} -y
|
2023-05-26 01:18:22 +00:00
|
|
|
ENV PATH="/root/.cargo/bin:${PATH}"
|
|
|
|
|
|
2023-05-27 21:31:27 +00:00
|
|
|
WORKDIR /root/workspace
|
2023-08-29 10:19:54 +00:00
|
|
|
COPY . .
|
2023-05-26 01:18:22 +00:00
|
|
|
|
|
|
|
|
RUN mkdir -p /opt/tabby/bin
|
|
|
|
|
RUN mkdir -p /opt/tabby/lib
|
2023-05-26 18:23:14 +00:00
|
|
|
RUN mkdir -p target
|
|
|
|
|
|
|
|
|
|
RUN --mount=type=cache,target=/usr/local/cargo/registry \
|
2023-05-27 21:31:27 +00:00
|
|
|
--mount=type=cache,target=/root/workspace/target \
|
2023-10-27 23:11:10 +00:00
|
|
|
cargo build --features cuda --release --package tabby && \
|
2023-05-27 07:05:56 +00:00
|
|
|
cp target/release/tabby /opt/tabby/bin/
|
2023-05-26 01:18:22 +00:00
|
|
|
|
2023-10-27 20:41:22 +00:00
|
|
|
FROM ${BASE_CUDA_RUN_CONTAINER} as runtime
|
2023-05-26 01:18:22 +00:00
|
|
|
|
2023-06-24 16:23:16 +00:00
|
|
|
RUN apt-get update && \
|
|
|
|
|
apt-get install -y --no-install-recommends \
|
|
|
|
|
git \
|
2023-12-07 00:18:02 +00:00
|
|
|
openssh-client \
|
|
|
|
|
ca-certificates \
|
2023-06-24 16:23:16 +00:00
|
|
|
&& \
|
|
|
|
|
apt-get clean && \
|
|
|
|
|
rm -rf /var/lib/apt/lists/*
|
|
|
|
|
|
2023-10-16 21:21:09 +00:00
|
|
|
# Disable safe directory in docker
|
|
|
|
|
# Context: https://github.com/git/git/commit/8959555cee7ec045958f9b6dd62e541affb7e7d9
|
|
|
|
|
RUN git config --system --add safe.directory "*"
|
|
|
|
|
|
2023-12-11 09:48:38 +00:00
|
|
|
# Automatic platform ARGs in the global scope
|
|
|
|
|
# https://docs.docker.com/engine/reference/builder/#automatic-platform-args-in-the-global-scope
|
|
|
|
|
ARG TARGETARCH
|
|
|
|
|
|
|
|
|
|
# AMD64 only:
|
2023-08-21 10:06:38 +00:00
|
|
|
# Make link to libnvidia-ml.so (NVML) library
|
|
|
|
|
# so that we could get GPU stats.
|
2023-12-11 09:48:38 +00:00
|
|
|
RUN if [ "$TARGETARCH" = "amd64" ]; then \
|
|
|
|
|
ln -s /usr/lib/x86_64-linux-gnu/libnvidia-ml.so.1 \
|
|
|
|
|
/usr/lib/x86_64-linux-gnu/libnvidia-ml.so; \
|
|
|
|
|
fi
|
2023-08-21 10:06:38 +00:00
|
|
|
|
2023-10-27 20:41:22 +00:00
|
|
|
COPY --from=build /opt/tabby /opt/tabby
|
2023-05-26 01:18:22 +00:00
|
|
|
|
2023-05-31 23:27:55 +00:00
|
|
|
ENV TABBY_ROOT=/data
|
2023-05-26 01:18:22 +00:00
|
|
|
|
|
|
|
|
ENTRYPOINT ["/opt/tabby/bin/tabby"]
|