mirror of
https://github.com/huggingface/text-generation-inference.git
synced 2025-04-29 22:12:07 +00:00
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`.
This commit is contained in:
parent
755361b932
commit
b806a856c7
@ -1,8 +1,7 @@
|
|||||||
# Build the image and get out the docker file:
|
# Build the image and get out the docker file:
|
||||||
#
|
#
|
||||||
# docker build -t tgi-nix -f Dockerfile.nix
|
# docker build -t tgi-nix-builder -f Dockerfile.nix
|
||||||
# docker run --rm --volume $PWD/data:/data tgi-nix cp -H result /data/tgi-docker.tar.gz
|
# docker run tgi-nix-builder | docker load
|
||||||
# docker load < tgi-docker.tar.gz
|
|
||||||
|
|
||||||
FROM nixos/nix:2.18.8
|
FROM nixos/nix:2.18.8
|
||||||
RUN echo "experimental-features = nix-command flakes" >> /etc/nix/nix.conf
|
RUN echo "experimental-features = nix-command flakes" >> /etc/nix/nix.conf
|
||||||
@ -10,4 +9,5 @@ RUN nix profile install nixpkgs#cachix
|
|||||||
RUN cachix use text-generation-inference
|
RUN cachix use text-generation-inference
|
||||||
WORKDIR /root
|
WORKDIR /root
|
||||||
ADD . .
|
ADD . .
|
||||||
RUN nix build .#dockerImage
|
RUN nix build .#dockerImageStreamed
|
||||||
|
ENTRYPOINT ./result
|
||||||
|
17
flake.nix
17
flake.nix
@ -153,18 +153,13 @@
|
|||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
dockerImage = pkgs.dockerTools.buildLayeredImage {
|
dockerImage = pkgs.callPackage nix/docker.nix {
|
||||||
name = "tgi-docker";
|
text-generation-inference = default;
|
||||||
tag = "latest";
|
};
|
||||||
config = {
|
|
||||||
EntryPoint = [ "${default}/bin/text-generation-inference" ];
|
|
||||||
Env = [
|
|
||||||
"HF_HOME=/data"
|
|
||||||
"PORT=80"
|
|
||||||
];
|
|
||||||
|
|
||||||
};
|
dockerImageStreamed = pkgs.callPackage nix/docker.nix {
|
||||||
contents = [ pkgs.cacert ];
|
text-generation-inference = default;
|
||||||
|
stream = true;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
23
nix/docker.nix
Normal file
23
nix/docker.nix
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
{
|
||||||
|
dockerTools,
|
||||||
|
cacert,
|
||||||
|
text-generation-inference,
|
||||||
|
stream ? false,
|
||||||
|
}:
|
||||||
|
|
||||||
|
let
|
||||||
|
build = if stream then dockerTools.streamLayeredImage else dockerTools.buildLayeredImage;
|
||||||
|
in
|
||||||
|
build {
|
||||||
|
name = "tgi-docker";
|
||||||
|
tag = "latest";
|
||||||
|
config = {
|
||||||
|
EntryPoint = [ "${text-generation-inference}/bin/text-generation-inference" ];
|
||||||
|
Env = [
|
||||||
|
"HF_HOME=/data"
|
||||||
|
"PORT=80"
|
||||||
|
];
|
||||||
|
|
||||||
|
};
|
||||||
|
contents = [ cacert ];
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user