Skip to content

Commit

Permalink
Push Antrea Ubuntu-based images to ghcr.io
Browse files Browse the repository at this point in the history
The Github Container Registry (ghcr.io) is introduced as an alternative
to Docker Hub for users. There is no change to how images are pushed to
Docker Hub, but antrea/antrea-agent-ubuntu and
antrea/antrea-controller-ubuntu are now also available in ghcr.io, as
antrea-io/antrea-agent-ubuntu and antrea-io/antrea-controller-ubuntu
respectively.

We do not retroactively push previously-released images to
ghcr.io. Antrea v2.3 will be the first release also available in ghcr.io.

In the future, we may also push UBI-based images to ghcr.io.

Fixes #6454

Signed-off-by: Antonin Bas <[email protected]>
  • Loading branch information
antoninbas committed Nov 26, 2024
1 parent 18e9111 commit 95b2998
Show file tree
Hide file tree
Showing 2 changed files with 123 additions and 55 deletions.
83 changes: 58 additions & 25 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,18 +71,37 @@ jobs:
if: ${{ needs.check-env.outputs.push_needed == 'false' }}
run: |
./hack/build-antrea-linux-all.sh --platform ${{ matrix.platform }} --pull
- name: Build and push Antrea Docker image to registry
- name: Login to Docker Hub
if: ${{ needs.check-env.outputs.push_needed == 'true' }}
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Login to Github Container Registry
if: ${{ needs.check-env.outputs.push_needed == 'true' }}
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Antrea Docker image to registries
if: ${{ needs.check-env.outputs.push_needed == 'true' }}
env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
run: |
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
./hack/build-antrea-linux-all.sh --platform ${{ matrix.platform }} --pull --push-base-images
docker tag antrea/antrea-controller-ubuntu:"${DOCKER_TAG}" antrea/antrea-controller-ubuntu-${{ matrix.suffix }}:"${DOCKER_TAG}"
docker tag antrea/antrea-agent-ubuntu:"${DOCKER_TAG}" antrea/antrea-agent-ubuntu-${{ matrix.suffix }}:"${DOCKER_TAG}"
docker push antrea/antrea-controller-ubuntu-${{ matrix.suffix }}:"${DOCKER_TAG}"
docker push antrea/antrea-agent-ubuntu-${{ matrix.suffix }}:"${DOCKER_TAG}"
targets=(
"docker.io antrea"
"ghcr.io antrea-io"
)
for target in "${targets[@]}"; do
t=($target)
registry="${t[0]}"
namespace="${t[1]}"
docker tag antrea/antrea-controller-ubuntu:"${DOCKER_TAG}" ${registry}/${namespace}/antrea-controller-ubuntu-${{ matrix.suffix }}:"${DOCKER_TAG}"
docker tag antrea/antrea-agent-ubuntu:"${DOCKER_TAG}" ${registry}/${namespace}/antrea-agent-ubuntu-${{ matrix.suffix }}:"${DOCKER_TAG}"
docker push ${registry}/${namespace}/antrea-controller-ubuntu-${{ matrix.suffix }}:"${DOCKER_TAG}"
docker push ${registry}/${namespace}/antrea-agent-ubuntu-${{ matrix.suffix }}:"${DOCKER_TAG}"
done
# Same repository workflow dispatch to run conformance tests
- name: Run conformance tests
if: ${{ needs.check-env.outputs.push_needed == 'true' }}
Expand All @@ -94,6 +113,13 @@ jobs:
push-manifest:
needs: [check-env, build]
if: ${{ needs.check-env.outputs.push_needed == 'true' }}
strategy:
matrix:
include:
- registry: docker.io
namespace: antrea
- registry: ghcr.io
namespace: antrea-io
runs-on: ubuntu-latest
env:
DOCKER_TAG: latest
Expand All @@ -102,26 +128,33 @@ jobs:
uses: docker/setup-buildx-action@v3
with:
driver: ${{ needs.check-env.outputs.docker_driver }}
- name: Docker login
env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
run: |
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
- name: Login to Docker Hub
if: ${{ needs.check-env.outputs.push_needed == 'true' && matrix.registry == 'docker.io' }}
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Login to Github Container Registry
if: ${{ needs.check-env.outputs.push_needed == 'true' && matrix.registry == 'ghcr.io' }}
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Create and push manifest for controller image
run: |
docker manifest create antrea/antrea-controller-ubuntu:"${DOCKER_TAG}" \
antrea/antrea-controller-ubuntu-arm64:"${DOCKER_TAG}" \
antrea/antrea-controller-ubuntu-arm:"${DOCKER_TAG}" \
antrea/antrea-controller-ubuntu-amd64:"${DOCKER_TAG}"
docker manifest push --purge antrea/antrea-controller-ubuntu:"${DOCKER_TAG}"
docker manifest create ${{ matrix.registry }}/${{ matrix.namespace }}/antrea-controller-ubuntu:"${DOCKER_TAG}" \
${{ matrix.registry }}/${{ matrix.namespace }}/antrea-controller-ubuntu-arm64:"${DOCKER_TAG}" \
${{ matrix.registry }}/${{ matrix.namespace }}/antrea-controller-ubuntu-arm:"${DOCKER_TAG}" \
${{ matrix.registry }}/${{ matrix.namespace }}/antrea-controller-ubuntu-amd64:"${DOCKER_TAG}"
docker manifest push --purge ${{ matrix.registry }}/${{ matrix.namespace }}/antrea-controller-ubuntu:"${DOCKER_TAG}"
- name: Create and push manifest for agent image
run: |
docker manifest create antrea/antrea-agent-ubuntu:"${DOCKER_TAG}" \
antrea/antrea-agent-ubuntu-arm64:"${DOCKER_TAG}" \
antrea/antrea-agent-ubuntu-arm:"${DOCKER_TAG}" \
antrea/antrea-agent-ubuntu-amd64:"${DOCKER_TAG}"
docker manifest push --purge antrea/antrea-agent-ubuntu:"${DOCKER_TAG}"
docker manifest create ${{ matrix.registry }}/${{ matrix.namespace }}/antrea-agent-ubuntu:"${DOCKER_TAG}" \
${{ matrix.registry }}/${{ matrix.namespace }}/antrea-agent-ubuntu-arm64:"${DOCKER_TAG}" \
${{ matrix.registry }}/${{ matrix.namespace }}/antrea-agent-ubuntu-arm:"${DOCKER_TAG}" \
${{ matrix.registry }}/${{ matrix.namespace }}/antrea-agent-ubuntu-amd64:"${DOCKER_TAG}"
docker manifest push --purge ${{ matrix.registry }}/${{ matrix.namespace }}/antrea-agent-ubuntu:"${DOCKER_TAG}"
build-ubi:
needs: check-env
Expand Down
95 changes: 65 additions & 30 deletions .github/workflows/build_tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,53 +44,88 @@ jobs:
uses: docker/setup-buildx-action@v3
with:
driver: docker
- name: Build and push Antrea Ubuntu Docker image to registry
- name: Build Antrea Ubuntu Docker image
env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
VERSION: ${{ needs.get-version.outputs.version }}
run: |
./hack/build-antrea-linux-all.sh --platform ${{ matrix.platform }} --pull
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
docker tag antrea/antrea-agent-ubuntu:"${DOCKER_TAG}" antrea/antrea-agent-ubuntu-${{ matrix.suffix }}:"${DOCKER_TAG}"
docker tag antrea/antrea-controller-ubuntu:"${DOCKER_TAG}" antrea/antrea-controller-ubuntu-${{ matrix.suffix }}:"${DOCKER_TAG}"
docker push antrea/antrea-agent-ubuntu-${{ matrix.suffix }}:"${DOCKER_TAG}"
docker push antrea/antrea-controller-ubuntu-${{ matrix.suffix }}:"${DOCKER_TAG}"
- name: Login to Docker Hub
if: ${{ needs.check-env.outputs.push_needed == 'true' }}
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Login to Github Container Registry
if: ${{ needs.check-env.outputs.push_needed == 'true' }}
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Push Antrea Ubuntu Docker image to registries
run: |
targets=(
"docker.io antrea"
"ghcr.io antrea-io"
)
for target in "${targets[@]}"; do
t=($target)
registry="${t[0]}"
namespace="${t[1]}"
docker tag antrea/antrea-agent-ubuntu:"${DOCKER_TAG}" ${registry}/${namespace}/antrea-agent-ubuntu-${{ matrix.suffix }}:"${DOCKER_TAG}"
docker tag antrea/antrea-controller-ubuntu:"${DOCKER_TAG}" ${registry}/${namespace}/antrea-controller-ubuntu-${{ matrix.suffix }}:"${DOCKER_TAG}"
docker push ${registry}/${namespace}/antrea-agent-ubuntu-${{ matrix.suffix }}:"${DOCKER_TAG}"
docker push ${registry}/${namespace}/antrea-controller-ubuntu-${{ matrix.suffix }}:"${DOCKER_TAG}"
done
# Same repository workflow dispatch to run conformance tests
- name: Run conformance tests
uses: benc-uk/workflow-dispatch@v1
with:
workflow: .github/workflows/conformance.yml
inputs: ${{ format('{{ "antrea-version":"{0}", "antrea-image-distro":"ubuntu", "test-suite":"conformance", "runner":"{1}", "antrea-image-platform":"{2}", "always-upload-logs":true }}', github.ref, matrix.runner, matrix.platform) }}

push-manifest:
needs: [get-version, build]
strategy:
matrix:
include:
- registry: docker.io
namespace: antrea
- registry: ghcr.io
namespace: antrea-io
runs-on: ubuntu-latest
env:
DOCKER_TAG: ${{ needs.get-version.outputs.version }}
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Docker login
env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
run: |
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
- name: Login to Docker Hub
if: ${{ needs.check-env.outputs.push_needed == 'true' && matrix.registry == 'docker.io' }}
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Login to Github Container Registry
if: ${{ needs.check-env.outputs.push_needed == 'true' && matrix.registry == "ghcr.io" }}
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Create and push manifest for controller image
run: |
docker manifest create antrea/antrea-controller-ubuntu:"${DOCKER_TAG}" \
antrea/antrea-controller-ubuntu-arm64:"${DOCKER_TAG}" \
antrea/antrea-controller-ubuntu-arm:"${DOCKER_TAG}" \
antrea/antrea-controller-ubuntu-amd64:"${DOCKER_TAG}"
docker manifest push --purge antrea/antrea-controller-ubuntu:"${DOCKER_TAG}"
docker manifest create ${{ matrix.registry }}/${{ matrix.namespace }}/antrea-controller-ubuntu:"${DOCKER_TAG}" \
${{ matrix.registry }}/${{ matrix.namespace }}/antrea-controller-ubuntu-arm64:"${DOCKER_TAG}" \
${{ matrix.registry }}/${{ matrix.namespace }}/antrea-controller-ubuntu-arm:"${DOCKER_TAG}" \
${{ matrix.registry }}/${{ matrix.namespace }}/antrea-controller-ubuntu-amd64:"${DOCKER_TAG}"
docker manifest push --purge ${{ matrix.registry }}/${{ matrix.namespace }}/antrea-controller-ubuntu:"${DOCKER_TAG}"
- name: Create and push manifest for agent image
run: |
docker manifest create antrea/antrea-agent-ubuntu:"${DOCKER_TAG}" \
antrea/antrea-agent-ubuntu-arm64:"${DOCKER_TAG}" \
antrea/antrea-agent-ubuntu-arm:"${DOCKER_TAG}" \
antrea/antrea-agent-ubuntu-amd64:"${DOCKER_TAG}"
docker manifest push --purge antrea/antrea-agent-ubuntu:"${DOCKER_TAG}"
# Same repository workflow dispatch to run conformance tests
- name: Run conformance tests
uses: benc-uk/workflow-dispatch@v1
with:
workflow: .github/workflows/conformance.yml
inputs: ${{ format('{{ "antrea-version":"{0}", "antrea-image-distro":"ubuntu", "test-suite":"conformance", "runner":"{1}", "antrea-image-platform":"{2}", "always-upload-logs":true }}', github.ref, matrix.runner, matrix.platform) }}
docker manifest create ${{ matrix.registry }}/${{ matrix.namespace }}/antrea-agent-ubuntu:"${DOCKER_TAG}" \
${{ matrix.registry }}/${{ matrix.namespace }}/antrea-agent-ubuntu-arm64:"${DOCKER_TAG}" \
${{ matrix.registry }}/${{ matrix.namespace }}/antrea-agent-ubuntu-arm:"${DOCKER_TAG}" \
${{ matrix.registry }}/${{ matrix.namespace }}/antrea-agent-ubuntu-amd64:"${DOCKER_TAG}"
docker manifest push --purge ${{ matrix.registry }}/${{ matrix.namespace }}/antrea-agent-ubuntu:"${DOCKER_TAG}"
build-ubi:
runs-on: [ubuntu-latest]
Expand Down

0 comments on commit 95b2998

Please sign in to comment.