Skip to content

Commit 11f2eec

Browse files
authored
Publish nix docker image. (#3122)
* Publish nix docker image. * Run during PR. * Something else. * Forgot to push. * Build zstd. * Pushing with skopeo * Testing the PR. * Runnign from nix. * Cleaner tags.
1 parent a35fbdb commit 11f2eec

File tree

2 files changed

+54
-1
lines changed

2 files changed

+54
-1
lines changed

.github/workflows/nix_build.yaml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: "Nix Build Docker image"
2+
on:
3+
pull_request:
4+
push:
5+
branches:
6+
- 'main'
7+
tags:
8+
- 'v*'
9+
concurrency:
10+
group: nix-image-${{ github.workflow }}-${{ github.head_ref || github.run_id }}
11+
cancel-in-progress: true
12+
13+
jobs:
14+
build_nix_image:
15+
runs-on:
16+
group: aws-highmemory-32-plus-priv
17+
steps:
18+
- uses: actions/checkout@v4
19+
- uses: cachix/install-nix-action@v27
20+
with:
21+
nix_path: nixpkgs=channel:nixos-unstable
22+
- uses: cachix/cachix-action@v14
23+
with:
24+
name: text-generation-inference
25+
# If you chose signing key for write access
26+
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
27+
env:
28+
USER: github_runner
29+
- name: Build
30+
run: nix build .#dockerImage
31+
- name: Initialize Docker Buildx
32+
uses: docker/setup-buildx-action@v3
33+
with:
34+
install: true
35+
buildkitd-config: /tmp/buildkitd.toml
36+
- name: Inject slug/short variables
37+
uses: rlespinasse/github-slug-action@v4.4.1
38+
- name: Login to internal Container Registry
39+
# if: github.event_name != 'pull_request'
40+
uses: docker/login-action@v3
41+
with:
42+
username: ${{ secrets.REGISTRY_USERNAME }}
43+
password: ${{ secrets.REGISTRY_PASSWORD }}
44+
registry: registry.internal.huggingface.tech
45+
- name: Push to docker
46+
run: |
47+
if [ "${{ github.event_name }}" = "pull_request" ]; then
48+
export TAG=nix-sha-${{ env.GITHUB_SHA_SHORT }}
49+
else
50+
export TAG=nix-{{ version }}
51+
fi
52+
export IMAGE=registry.internal.huggingface.tech/api-inference/community/text-generation-inference:$TAG
53+
nix-shell -p skopeo --command "skopeo --insecure-policy copy docker-archive:$(readlink -f ./result) docker://$IMAGE --dest-compress-format zstd"

nix/docker.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
dockerTools,
44
cacert,
55
text-generation-inference,
6-
runCommand,
76
stream ? false,
87
}:
98

@@ -13,6 +12,7 @@ in
1312
build {
1413
name = "tgi-docker";
1514
tag = "latest";
15+
compressor = "zstd";
1616
config = {
1717
EntryPoint = [ "${text-generation-inference}/bin/text-generation-inference" ];
1818
Env = [

0 commit comments

Comments
 (0)