Repository navigation
80 lines (70 loc) · 2.86 KB
/
Copy pathloop.yml
File metadata and controls
80 lines (70 loc) · 2.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
name: 构建镜像:loop
on:
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
name: 构建镜像:loop
env:
IMAGE_NAME: loop
DOCKER_CLI_EXPERIMENTAL: enabled
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Buildx cache
uses: actions/cache@v2
id: buildx-cache
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx
- name: Build
run: |
cd ${IMAGE_NAME}
DOCKERHUB_REPOSITORY=${{ secrets.DOCKER_USERNAME }}/${IMAGE_NAME}
declare -a IMAGES
echo "Build amd64"
docker buildx build \
--cache-from "type=local,src=/tmp/.buildx-cache" \
--cache-to "type=local,dest=/tmp/.buildx-cache" \
--output "type=image,push=true" \
--platform linux/amd64 \
--build-arg "TARGET=x86_64-unknown-linux-musl" \
--tag "${DOCKERHUB_REPOSITORY}:latest-amd64" \
-f Dockerfile \
.
IMAGES+=( "${DOCKERHUB_REPOSITORY}:latest-amd64" )
echo "Build arm-v7"
docker buildx build \
--cache-from "type=local,src=/tmp/.buildx-cache" \
--cache-to "type=local,dest=/tmp/.buildx-cache" \
--output "type=image,push=true" \
--platform linux/arm/v7 \
--build-arg "TARGET=armv7-unknown-linux-musleabihf" \
--tag "${DOCKERHUB_REPOSITORY}:latest-arm-v7" \
-f Dockerfile \
.
IMAGES+=( "${DOCKERHUB_REPOSITORY}:latest-arm-v7" )
echo "Build arm64-v8"
docker buildx build \
--cache-from "type=local,src=/tmp/.buildx-cache" \
--cache-to "type=local,dest=/tmp/.buildx-cache" \
--output "type=image,push=true" \
--platform linux/arm64/v8 \
--build-arg "TARGET=aarch64-unknown-linux-musl" \
--tag "${DOCKERHUB_REPOSITORY}:latest-arm64-v8" \
-f Dockerfile \
.
IMAGES+=( "${DOCKERHUB_REPOSITORY}:latest-arm64-v8" )
echo "Create manifest lists"
docker manifest create "${DOCKERHUB_REPOSITORY}:latest" "${IMAGES[@]}"
docker manifest annotate "${DOCKERHUB_REPOSITORY}:latest" "${DOCKERHUB_REPOSITORY}:latest-arm-v7" --variant "v7"
docker manifest annotate "${DOCKERHUB_REPOSITORY}:latest" "${DOCKERHUB_REPOSITORY}:latest-arm64-v8" --variant "v8"
echo "Push manifest lists & delete local copies"
docker manifest push --purge "${DOCKERHUB_REPOSITORY}:latest"