Skip to content

Commit

Permalink
perf: arm build (#1859)
Browse files Browse the repository at this point in the history
Signed-off-by: 逆流而上 <[email protected]>
  • Loading branch information
DokiDoki1103 authored Jan 19, 2024
1 parent 3e3fa43 commit 2f52d49
Showing 1 changed file with 273 additions and 0 deletions.
273 changes: 273 additions & 0 deletions .github/workflows/release-arm64.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,273 @@
name: Release arm64 Docker image
on:
workflow_dispatch:
inputs:
branch:
description: 'branch'
required: false
default: 'main'
clone_url:
description: 'clone_url'
required: false
default: 'https://github.com/goodrain'
version:
description: 'version'
required: true
default: 'v5.18.0-release-arm64'
environment:
description: 'environment'
required: false
default: 'release-arm'
type: choice
options:
- release-arm
- release
- release-arch
- enterprise-arm
- enterprise
action:
description: 'action'
required: false
default: 'GitHub'
type: choice
options:
- GitHub
- GitLab
gh_token:
description: 'gh_token'
required: true
default: 'AO6VOB64OOE5QU7TBWCQFG3FVJ4UU'
env:
VERSION: ${{ github.event.inputs.version }}

jobs:
create-ecs:
strategy:
matrix:
server: [ runner1, runner2,runner3, runner4,runner5, runner6 ]
runs-on: 'ubuntu-22.04'
environment: ${{ github.event.inputs.environment }}
steps:
- name: Download and extract aliyun-cli
run: |
wget https://aliyuncli.alicdn.com/aliyun-cli-linux-latest-amd64.tgz
sudo tar -zxvf aliyun-cli-linux-latest-amd64.tgz -C /usr/bin/
aliyun configure set --profile akProfile --mode AK --region ap-southeast-1 --access-key-id ${{ secrets.ALI_KEY }} --access-key-secret ${{ secrets.ALI_SECRET }}
instanceIds=($(aliyun ecs DescribeInstanceStatus --region ap-southeast-1 --PageSize 50 --RegionId 'ap-southeast-1' | jq -r '.InstanceStatuses.InstanceStatus | map(.InstanceId)[]'))
if [ ${#instanceIds[@]} -gt 5 ]; then
echo "已经有${#instanceIds[@]}台服务器,不再进行创建"
exit 0
fi
create=$(aliyun ecs RunInstances --region ap-southeast-1 --RegionId 'ap-southeast-1' --ImageId 'ubuntu_22_04_arm64_20G_alibase_20230712.vhd' --InstanceType '${{ vars.ECS }}' --SecurityGroupId 'sg-t4n8sj6bpvaxfe3s47po' --VSwitchId 'vsw-t4nsosaaw6fw28vpjd2n7' --SystemDisk.Category cloud_essd --Description '打包arm64发布' --InstanceChargeType PostPaid --CreditSpecification Unlimited --InternetChargeType PayByTraffic --PasswordInherit false --Password '${{ secrets.ECS_PWD }}' --UniqueSuffix true --InternetMaxBandwidthOut 100 --InternetMaxBandwidthIn 100 --SystemDisk.Size 50 --SpotStrategy SpotAsPriceGo --SpotDuration 1)
instanceId=$(echo "$create" | jq -r '.InstanceIdSets.InstanceIdSet[0]')
echo "创建服务器成功,实例ID为 $instanceId,等待5秒后开始查询公网IP"
sleep 5
# 查询服务器信息
info=$(aliyun ecs DescribeInstanceAttribute --region ap-southeast-1 --InstanceId "$instanceId")
publishIp=$(echo "$info" | jq -r '.PublicIpAddress.IpAddress[0]')
echo "查询公网IP为 $publishIp,等待60s后执行github runner"
echo "PUBLISH_IP=$publishIp" >> $GITHUB_ENV
sleep 60
- name: SSH To Server And Run Github Action Script
if: contains(env.PUBLISH_IP, '.')
uses: appleboy/ssh-action@master
with:
host: ${{ env.PUBLISH_IP }}
username: root
password: ${{ secrets.ECS_PWD }}
port: 22
script: |
export GH_TOKEN="${{ github.event.inputs.gh_token }}" && curl https://rainbond-script.oss-cn-hangzhou.aliyuncs.com/runner.sh | bash
build-ui:
needs: create-ecs
runs-on: self-hosted
environment: ${{ github.event.inputs.environment }}
steps:
- name: Build the Docker image
env:
BUILD_RBD_APP_UI: false
# GitHub
DOCKER_USERNAME: ${{ vars.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
# GitLab
UI_DOCKER_USERNAME: ${{ vars.UI_DOCKER_USERNAME }}
UI_DOCKER_PASSWORD: ${{ secrets.UI_DOCKER_PASSWORD }}
ALLINONE: ${{ vars.ALLINONE }}
ROUTE_MODE: ${{ vars.ROUTE_MODE }}
run: |
if [ ${{ github.event.inputs.action }} == 'GitHub' ];then
git clone -b ${{ github.event.inputs.branch }} ${{ github.event.inputs.clone_url }}/rainbond-ui.git
cd rainbond-ui
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
else
git clone -b ${{ github.event.inputs.branch }} ${{ github.event.inputs.clone_url }}/rainbond-ui-cloud.git
cd rainbond-ui-cloud
echo "$UI_DOCKER_PASSWORD" | docker login -u "$UI_DOCKER_USERNAME" --password-stdin
fi
chmod +x ./build.sh
./build.sh
docker build -t rainbond/rainbond-ui:$VERSION .
docker push rainbond/rainbond-ui:$VERSION
build-rainbond-allinone:
needs:
- create-ecs
- build-ui
runs-on: self-hosted
environment: ${{ github.event.inputs.environment }}
steps:
- name: Pull code and Build allinone image
env:
TRAVIS_PULL_REQUEST: false
ADAPTOR_BRANCH: ${{ vars.ADAPTOR_BRANCH}}
BUILD_ARCH: ${{ vars.BUILD_ARCH}}
# GitHub
DOCKER_USERNAME: ${{ vars.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
# GitLab
DOMESTIC_DOCKER_USERNAME: ${{ vars.DOMESTIC_DOCKER_USERNAME }}
DOMESTIC_DOCKER_PASSWORD: ${{ secrets.DOMESTIC_DOCKER_PASSWORD }}
DOMESTIC_BASE_NAME: ${{ vars.DOMESTIC_BASE_NAME }}
DOMESTIC_NAMESPACE: ${{ vars.DOMESTIC_NAMESPACE }}
run: |
if [ ${{ github.event.inputs.action }} == 'GitHub' ];then
git clone -b ${{ github.event.inputs.branch }} ${{ github.event.inputs.clone_url }}/rainbond-console.git
cd rainbond-console
else
git clone -b ${{ github.event.inputs.branch }} ${{ github.event.inputs.clone_url }}/rainbond-console-cloud.git
cd rainbond-console-cloud
fi
chmod +x ./release.sh
./release.sh allinone
build-rainbond-region:
needs:
- create-ecs
runs-on: self-hosted
environment: ${{ github.event.inputs.environment }}
strategy:
matrix:
component: [ api, chaos, gateway, monitor, mq, webcli, worker, eventlog, init-probe, mesh-data-panel, node, resource-proxy ]
steps:
- name: Pull code and Build the Docker image
env:
DISABLE_GOPROXY: true
# GitHub
DOCKER_USERNAME: ${{ vars.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
# GitLab
DOMESTIC_DOCKER_USERNAME: ${{ vars.DOMESTIC_DOCKER_USERNAME }}
DOMESTIC_DOCKER_PASSWORD: ${{ secrets.DOMESTIC_DOCKER_PASSWORD }}
DOMESTIC_BASE_NAME: ${{ vars.DOMESTIC_BASE_NAME }}
DOMESTIC_NAMESPACE: ${{ vars.DOMESTIC_NAMESPACE }}
run: |
git clone -b ${{ github.event.inputs.branch }} ${{ github.event.inputs.clone_url }}/rainbond.git
cd rainbond
chmod +x ./release.sh
./release.sh ${{ matrix.component }} push
build-rainbond-region-grctl-shell:
needs:
- create-ecs
runs-on: self-hosted
environment: ${{ github.event.inputs.environment }}
steps:
- name: Pull code and Build the Docker image
env:
DISABLE_GOPROXY: true
# GitHub
DOCKER_USERNAME: ${{ vars.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
# GitLab
DOMESTIC_DOCKER_USERNAME: ${{ vars.DOMESTIC_DOCKER_USERNAME }}
DOMESTIC_DOCKER_PASSWORD: ${{ secrets.DOMESTIC_DOCKER_PASSWORD }}
DOMESTIC_BASE_NAME: ${{ vars.DOMESTIC_BASE_NAME }}
DOMESTIC_NAMESPACE: ${{ vars.DOMESTIC_NAMESPACE }}
run: |
git clone -b ${{ github.event.inputs.branch }} ${{ github.event.inputs.clone_url }}/rainbond.git
cd rainbond
chmod +x ./release.sh
./release.sh grctl push
./release.sh shell push
build-operator:
needs:
- create-ecs
runs-on: self-hosted
environment: ${{ github.event.inputs.environment }}
steps:
- name: Build and push
env:
BUILD_ARCH: ${{ vars.BUILD_ARCH}}
# GitHub
DOCKER_USERNAME: ${{ vars.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
# GitLab
DOMESTIC_DOCKER_USERNAME: ${{ vars.DOMESTIC_DOCKER_USERNAME }}
DOMESTIC_DOCKER_PASSWORD: ${{ secrets.DOMESTIC_DOCKER_PASSWORD }}
DOMESTIC_BASE_NAME: ${{ vars.DOMESTIC_BASE_NAME }}
DOMESTIC_NAMESPACE: ${{ vars.DOMESTIC_NAMESPACE }}
OPERATOR_BRANCH: ${{ vars.OPERATOR_BRANCH }}
OPERATOR_URL: ${{ vars.OPERATOR_URL }}
run: |
if [ ${{ github.event.inputs.action }} == 'GitHub' ];then
git clone -b ${{ github.event.inputs.branch }} ${{ github.event.inputs.clone_url }}/rainbond-operator.git
cd rainbond-operator
else
git clone -b $OPERATOR_BRANCH $OPERATOR_URL/rainbond-operator.git
cd rainbond-operator
fi
chmod +x ./release.sh
./release.sh
build-dind:
if: github.event.inputs.action == 'GitHub'
needs: [ create-ecs,build-ui,build-rainbond-region,build-rainbond-region-grctl-shell,build-operator ]
runs-on: self-hosted
environment: ${{ github.event.inputs.environment }}
steps:
- name: Build the Docker image
env:
TRAVIS_PULL_REQUEST: false
BUILD_ARCH: ${{ vars.BUILD_ARCH}}
ADAPTOR_BRANCH: ${{ vars.ADAPTOR_BRANCH}}
# GitHub
DOCKER_USERNAME: ${{ vars.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
run: |
git clone -b ${{ github.event.inputs.branch }} ${{ github.event.inputs.clone_url }}/rainbond-console.git
cd rainbond-console
./release.sh dind
push-arch:
if: github.event.inputs.action == 'GitHub'
needs: [ create-ecs,build-rainbond-allinone,build-rainbond-region,build-rainbond-region-grctl-shell,build-operator,build-dind ]
runs-on: self-hosted
environment: release-arch
steps:
- uses: actions/checkout@v2
- name: push arch images
env:
RBD_VER: ${{ vars.RBD_VER }}
DOMESTIC_DOCKER_USERNAME: ${{ vars.DOMESTIC_DOCKER_USERNAME }}
DOMESTIC_DOCKER_PASSWORD: ${{ secrets.DOMESTIC_DOCKER_PASSWORD }}
PUSH_ARCH: ${{ vars.PUSH_ARCH }}
run: |
if [ $PUSH_ARCH == 'true' ];then
chmod +x .github/scripts/push-arch.sh && ./.github/scripts/push-arch.sh
fi
close-ecs:
needs: push-arch
runs-on: 'ubuntu-22.04'
environment: ${{ github.event.inputs.environment }}
steps:
- name: Download and extract aliyun-cli
run: |
wget https://aliyuncli.alicdn.com/aliyun-cli-linux-latest-amd64.tgz
sudo tar -zxvf aliyun-cli-linux-latest-amd64.tgz -C /usr/bin/
aliyun configure set --profile akProfile --mode AK --region ap-southeast-1 --access-key-id ${{ secrets.ALI_KEY }} --access-key-secret ${{ secrets.ALI_SECRET }}
instanceIds=($(aliyun ecs DescribeInstanceStatus --region ap-southeast-1 --PageSize 50 --RegionId 'ap-southeast-1' | jq -r '.InstanceStatuses.InstanceStatus | map(.InstanceId)[]'))
for id in "${instanceIds[@]}"; do
echo "开始释放云服务器: $id"
aliyun ecs DeleteInstance --region ap-southeast-1 --InstanceId "$id" --Force true --TerminateSubscription true
done

0 comments on commit 2f52d49

Please sign in to comment.