Skip to content

Commit

Permalink
使用buildx工具,将arm64和amd64合并至同一镜像
Browse files Browse the repository at this point in the history
  • Loading branch information
expoli authored May 28, 2022
1 parent 68fb2e5 commit af27fa5
Showing 1 changed file with 2 additions and 70 deletions.
72 changes: 2 additions & 70 deletions .github/workflows/docker-image-builder.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ on:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
amd64-build:
bolo-buildx:
runs-on: ubuntu-latest
steps:
-
Expand Down Expand Up @@ -74,82 +74,14 @@ jobs:
with:
context: .
file: ./Dockerfile
platforms: linux/amd64
platforms: linux/amd64,linux/arm64/v8
push: ${{ github.event_name != 'pull_request' }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new
tags: |
${{ steps.prep.outputs.image }}:amd64-${{ steps.date.outputs.today }}
${{ steps.prep.outputs.image }}:amd64-${{ steps.prep.outputs.tag }}
${{ steps.prep.outputs.image }}:latest
- name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
arm64-build:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v2
-
name: Get current date
id: date
run: echo "::set-output name=today::$(date +'%Y-%m-%d')"
- name: Prepare
id: prep
run: |
TAG=$(echo $GITHUB_REF | cut -d / -f 3)
IMAGE="tangcuyu/bolo-solo"
echo ::set-output name=image::${IMAGE}
echo ::set-output name=tag::${TAG}
echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//}
-
name: Set up QEMU
uses: docker/setup-qemu-action@v1
with:
platforms: all
-
name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
-
name: Available platforms
run: echo ${{ steps.buildx.outputs.platforms }}
-
name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
-
name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Build and push
uses: docker/build-push-action@v2
with:
context: .
file: ./Dockerfile
platforms: linux/arm64/v8
push: ${{ github.event_name != 'pull_request' }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new
tags: |
${{ steps.prep.outputs.image }}:arm64-${{ steps.date.outputs.today }}
${{ steps.prep.outputs.image }}:arm64-${{ steps.prep.outputs.tag }}
${{ steps.prep.outputs.image }}:arm64-latest
- name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache

0 comments on commit af27fa5

Please sign in to comment.