71 lines
3.0 KiB
YAML
71 lines
3.0 KiB
YAML
name: Build Gateway E2E Container
|
|
|
|
permissions: {}
|
|
|
|
on:
|
|
workflow_call:
|
|
secrets:
|
|
DOCKERHUB_LIMITED_TOKEN:
|
|
required: true
|
|
|
|
jobs:
|
|
build-gateway-e2e-container:
|
|
name: build-gateway-e2e-container
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 45
|
|
if: github.repository == 'tensorzero/tensorzero'
|
|
permissions:
|
|
# Permission to checkout the repository
|
|
contents: read # Required for checkout or repository metadata reads.
|
|
# Permission to fetch GitHub OIDC token authentication
|
|
id-token: write # Required for OIDC-backed build or publish tooling.
|
|
|
|
steps:
|
|
- name: Check out the repo
|
|
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
|
with:
|
|
persist-credentials: false
|
|
|
|
# We use 'DOCKERHUB_LIMITED_TOKEN' to ensure that we can only push to our private '-dev' repos,
|
|
# not to any of the public production repos.
|
|
- name: Login to Docker Hub
|
|
uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3.4.0
|
|
with:
|
|
# We're using an organization access token, so we need to use the org name for the username.
|
|
username: tensorzero
|
|
password: ${{ secrets.DOCKERHUB_LIMITED_TOKEN }}
|
|
|
|
# We allow the namespace builder setup to fail on Dependabot PRs and PRs from forks
|
|
# (where the oidc token is not available)
|
|
|
|
- name: Install Namespace CLI
|
|
uses: namespacelabs/nscloud-setup@f378676225212387f1283f4da878712af2c4cd60 # v0.0.11
|
|
continue-on-error: ${{ github.event.pull_request.head.repo.full_name != github.repository || github.actor == 'dependabot[bot]' }}
|
|
|
|
- name: Configure Namespace-powered Buildx
|
|
uses: namespacelabs/nscloud-setup-buildx-action@91c2e6537780e3b092cb8476406be99a8f91bd5e # v0.0.20
|
|
with:
|
|
wait-for-builder: true
|
|
continue-on-error: ${{ github.event.pull_request.head.repo.full_name != github.repository || github.actor == 'dependabot[bot]' }}
|
|
|
|
# Note that this pushes an e2e build of the gateway to 'tensorzero/gateway-e2e'.
|
|
# It does *not* push to the production 'tensorzero/gateway' repo.
|
|
- name: Build and push `gateway-e2e` container
|
|
run: |
|
|
docker buildx build --build-arg BUILDKIT_CONTEXT_KEEP_GIT_DIR=1 -f crates/gateway/Dockerfile --build-arg PROFILE=dev --build-arg "CARGO_BUILD_FLAGS=--features e2e_tests" --target gateway . -t tensorzero/gateway-e2e:sha-$GITHUB_SHA --push
|
|
|
|
- name: Wait for image to be available on Docker Hub
|
|
run: |
|
|
IMAGE="tensorzero/gateway-e2e:sha-$GITHUB_SHA"
|
|
echo "Waiting for ${IMAGE} to be available on Docker Hub..."
|
|
for i in $(seq 1 60); do
|
|
if docker manifest inspect "${IMAGE}" > /dev/null 2>&1; then
|
|
echo "Image ${IMAGE} is available on Docker Hub"
|
|
exit 0
|
|
fi
|
|
echo "Attempt ${i}/60: Image not yet available, waiting 5s..."
|
|
sleep 5
|
|
done
|
|
echo "Timed out waiting for ${IMAGE} to appear on Docker Hub"
|
|
exit 1
|