support multi arch image (#483)

This commit is contained in:
澄潭
2023-08-14 20:41:09 +08:00
committed by GitHub
parent ec229e69ac
commit 8048436604
5 changed files with 191 additions and 20 deletions

View File

@@ -66,13 +66,17 @@ jobs:
- name: Build Docker Image and Push
run: |
GOPROXY="https://proxy.golang.org,direct" make docker-build
GOPROXY="https://proxy.golang.org,direct" TARGET_ARCH=amd64 make docker-build
GOPROXY="https://proxy.golang.org,direct" TARGET_ARCH=arm64 make docker-build
BUILT_IMAGE="higress-registry.cn-hangzhou.cr.aliyuncs.com/higress/higress"
docker push $BUILT_IMAGE:$GITHUB_SHA-amd64
docker push $BUILT_IMAGE:$GITHUB_SHA-arm64
readarray -t IMAGES <<< "${{ steps.docker-meta.outputs.tags }}"
for image in ${IMAGES[@]}; do
echo "Image: $image"
docker tag $BUILT_IMAGE:$GITHUB_SHA $image
docker push $image
docker manifest rm $image
docker manifest create $image $BUILT_IMAGE:$GITHUB_SHA-amd64 $BUILT_IMAGE:$GITHUB_SHA-arm64
docker manifest push $image
done
build-pilot-image:
@@ -132,13 +136,83 @@ jobs:
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_PASSWORD }}
- name: Build Docker Image and Push
- name: Build Pilot-Discovery Image and Push
run: |
sudo GOPROXY="https://proxy.golang.org,direct" make build-istio
sudo GOPROXY="https://proxy.golang.org,direct" TARGET_ARCH=amd64 make build-istio
sudo GOPROXY="https://proxy.golang.org,direct" TARGET_ARCH=arm64 make build-istio
BUILT_IMAGE="higress-registry.cn-hangzhou.cr.aliyuncs.com/higress/pilot"
docker push $BUILT_IMAGE:$GITHUB_SHA-amd64
docker push $BUILT_IMAGE:$GITHUB_SHA-arm64
readarray -t IMAGES <<< "${{ steps.docker-meta.outputs.tags }}"
for image in ${IMAGES[@]}; do
echo "Image: $image"
docker tag $BUILT_IMAGE:$GITHUB_SHA $image
docker push $image
docker manifest rm $image
docker manifest create $image $BUILT_IMAGE:$GITHUB_SHA-amd64 $BUILT_IMAGE:$GITHUB_SHA-arm64
docker manifest push $image
done
build-gateway-image:
runs-on: ubuntu-latest
environment:
name: image-registry-pilot
env:
GATEWAY_IMAGE_REGISTRY: ${{ vars.IMAGE_REGISTRY || 'higress-registry.cn-hangzhou.cr.aliyuncs.com' }}
GATEWAY_IMAGE_NAME: ${{ vars.GATEWAY_IMAGE_NAME || 'higress/gateway' }}
steps:
- name: "Checkout ${{ github.ref }}"
uses: actions/checkout@v3
with:
fetch-depth: 1
- name: "Setup Go"
uses: actions/setup-go@v3
with:
go-version: 1.19
- name: Setup Golang Caches
uses: actions/cache@v3
with:
path: |-
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ github.run_id }}
restore-keys: ${{ runner.os }}-go
- name: Setup Submodule Caches
uses: actions/cache@v3
with:
path: |-
envoy
istio
external
.git/modules
key: ${{ runner.os }}-submodules-${{ github.run_id }}
restore-keys: ${{ runner.os }}-submodules
- name: Calculate Docker metadata
id: docker-meta
uses: docker/metadata-action@v4
with:
images: |
${{ env.GATEWAY_IMAGE_REGISTRY }}/${{ env.GATEWAY_IMAGE_NAME }}
tags: |
type=sha
type=ref,event=tag
type=semver,pattern={{version}}
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') }}
- name: Build Gateway Image and Push
run: |
sudo GOPROXY="https://proxy.golang.org,direct" TARGET_ARCH=amd64 make build-gateway
sudo GOPROXY="https://proxy.golang.org,direct" TARGET_ARCH=arm64 make build-gateway
BUILT_IMAGE="higress-registry.cn-hangzhou.cr.aliyuncs.com/higress/proxyv2"
docker push $BUILT_IMAGE:$GITHUB_SHA-amd64
docker push $BUILT_IMAGE:$GITHUB_SHA-arm64
readarray -t IMAGES <<< "${{ steps.docker-meta.outputs.tags }}"
for image in ${IMAGES[@]}; do
echo "Image: $image"
docker manifest rm $image
docker manifest create $image $BUILT_IMAGE:$GITHUB_SHA-amd64 $BUILT_IMAGE:$GITHUB_SHA-arm64
docker manifest push $image
done