Skip to content

Commit 0f1c2b9

Browse files
committed
Fixing the build system
1 parent 5c3dbdc commit 0f1c2b9

File tree

1 file changed

+44
-27
lines changed

1 file changed

+44
-27
lines changed
Lines changed: 44 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,65 @@
11
name: latent-to-image-docker-cd
22
on:
3+
pull_request:
34
push:
45
branches:
56
- main
67
paths:
78
- "docker_images/latent-to-image/**"
89
jobs:
910
build:
10-
runs-on: ubuntu-latest
11+
runs-on:
12+
group: aws-general-8-plus-priv
1113
steps:
1214
- name: Set up Python ${{ matrix.python-version }}
1315
uses: actions/setup-python@v2
1416
with:
15-
python-version: "3.8"
17+
python-version: "3.10"
1618
- name: Checkout
17-
uses: actions/checkout@v2
18-
- name: Set up QEMU
19-
uses: docker/setup-qemu-action@v1
20-
- name: Set up Docker Buildx
21-
uses: docker/setup-buildx-action@v1
22-
- name: Install dependencies
23-
run: |
24-
pip install --upgrade pip
25-
pip install awscli
26-
- uses: huggingface/tailscale-action@v1
19+
uses: actions/checkout@v4
20+
- name: Initialize Docker Buildx
21+
uses: docker/setup-buildx-action@v3
2722
with:
28-
authkey: ${{ secrets.TAILSCALE_AUTHKEY }}
29-
- name: Update upstream
30-
env:
31-
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
32-
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
33-
AWS_DEFAULT_REGION: ${{ secrets.AWS_DEFAULT_REGION }}
34-
DEFAULT_HOSTNAME: ${{ secrets.DEFAULT_HOSTNAME }}
35-
REGISTRY_USERNAME: ${{ secrets.REGISTRY_USERNAME }}
36-
REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }}
37-
run: |
38-
python build_docker.py latent-to-image --out out.txt
23+
install: true
24+
buildkitd-config: /tmp/buildkitd.toml
25+
- name: Inject slug/short variables
26+
uses: rlespinasse/[email protected]
27+
- name: Login to internal Container Registry
28+
uses: docker/login-action@v3
29+
with:
30+
username: ${{ secrets.REGISTRY_USERNAME }}
31+
password: ${{ secrets.REGISTRY_PASSWORD }}
32+
registry: registry.internal.huggingface.tech
33+
- name: Extract metadata (tags, labels) for Docker
34+
id: meta-pr
35+
uses: docker/metadata-action@v5
36+
with:
37+
images: |
38+
registry.internal.huggingface.tech/api-inference/community
39+
tags: |
40+
type=raw,value=latent-to-image-sha-${{ env.GITHUB_SHA_SHORT }}
41+
- name: Build and push Docker image
42+
id: build-and-push
43+
uses: docker/build-push-action@v4
44+
with:
45+
context: docker_images/latent-to-image
46+
dockerfile: docker_images/latent-to-image/Dockerfile
47+
push: true
48+
platforms: 'linux/amd64'
49+
build-args: |
50+
GIT_SHA=${{ env.GITHUB_SHA }}
51+
DOCKER_LABEL=latent-to-image-sha-${{ env.GITHUB_SHA_SHORT }}
52+
PLATFORM=${{ env.PLATFORM }}
53+
tags: ${{ steps.meta.outputs.tags || steps.meta-pr.outputs.tags }}
54+
labels: ${{ steps.meta.outputs.labels || steps.meta-pr.outputs.labels }}
55+
cache-from: type=s3,region=us-east-1,bucket=ci-docker-buildx-cache,name=latent-to-image-cache${{ env.LABEL }},mode=min,access_key_id=${{ secrets.S3_CI_DOCKER_BUILDX_CACHE_ACCESS_KEY_ID }},secret_access_key=${{ secrets.S3_CI_DOCKER_BUILDX_CACHE_SECRET_ACCESS_KEY }},mode=min
56+
cache-to: type=s3,region=us-east-1,bucket=ci-docker-buildx-cache,name=latent-to-image-cache${{ env.LABEL }},mode=min,access_key_id=${{ secrets.S3_CI_DOCKER_BUILDX_CACHE_ACCESS_KEY_ID }},secret_access_key=${{ secrets.S3_CI_DOCKER_BUILDX_CACHE_SECRET_ACCESS_KEY }},mode=min
3957
- name: Deploy on API
4058
run: |
4159
# Load the tags into the env
42-
cat out.txt >> $GITHUB_ENV
43-
export $(xargs < out.txt)
44-
echo ${LATENT_TO_IMAGE_CPU_TAG}
60+
echo sha-${{ env.GITHUB_SHA_SHORT }}
4561
# Weird single quote escape mechanism because string interpolation does
4662
# not work on single quote in bash
47-
curl -H "Authorization: Bearer ${{ secrets.API_GITHUB_TOKEN }}" https://api.github.com/repos/huggingface/api-inference/actions/workflows/update_community.yaml/dispatches -d '{"ref":"main","inputs":{"framework":"LATENT_TO_IMAGE","tag": "'"${LATENT_TO_IMAGE_CPU_TAG}"'"}}'
63+
curl -H "Authorization: Bearer ${{ secrets.API_GITHUB_TOKEN }}" https://api.github.com/repos/huggingface-internal/api-inference/actions/workflows/update_community.yaml/dispatches -d '{"ref":"main","inputs":{"framework":"LATENT_TO_IMAGE","tag": "latent-to-image-sha-${{ env.GITHUB_SHA_SHORT }}"}}'
64+
4865

0 commit comments

Comments
 (0)