|
| 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" |
0 commit comments