mirror of
https://github.com/huggingface/text-generation-inference.git
synced 2025-04-19 22:02:06 +00:00
* nix: experimental support for building a Docker image Run using something like: ``` docker run \ --device nvidia.com/gpu=all \ -it --rm -p 8080:80 \ -v $PWD/data:/data \ -v $PWD/tmp:/tmp \ tgi-docker:latest \ --model-id <model_id> ``` * Example of building the Docker image using Nix inside Docker * Stream to make the builder image smaller This avoids storing a Docker image tarball in the image. Instead, stream the layers while doing `docker run`. * Don't spam journalctl on Linux * Other dockerfile. --------- Co-authored-by: Nicolas Patry <patry.nicolas@protonmail.com>
25 lines
691 B
Nix
25 lines
691 B
Nix
# Build the image and get out the docker file:
|
|
#
|
|
# docker build -t tgi-nix-builder -f Dockerfile.nix
|
|
# docker run --log-driver=none tgi-nix-builder | docker load
|
|
|
|
FROM nixos/nix:2.18.8 AS builder
|
|
RUN echo "experimental-features = nix-command flakes" >> /etc/nix/nix.conf
|
|
RUN nix profile install nixpkgs#cachix
|
|
RUN cachix use text-generation-inference
|
|
WORKDIR /root
|
|
ADD . .
|
|
RUN nix build .
|
|
RUN mkdir /tmp/nix-store-closure
|
|
RUN cp -R $(nix-store -qR result/) /tmp/nix-store-closure
|
|
|
|
FROM ubuntu:24.04
|
|
|
|
WORKDIR /app
|
|
|
|
# Copy /nix/store
|
|
COPY --from=builder /tmp/nix-store-closure /nix/store
|
|
COPY --from=builder /root/result /app
|
|
RUN ldconfig
|
|
CMD ["ldconfig", "/app/bin/text-generation-launcher"]
|