-
Notifications
You must be signed in to change notification settings - Fork 2
117 lines (101 loc) · 3.35 KB
/
Copy pathdocker.yml
File metadata and controls
117 lines (101 loc) · 3.35 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
name: docker
on:
push:
branches: "main"
tags: "v*"
workflow_dispatch:
env:
IMAGE_NAME: marksverdhei/bakery
ARM64_CACHE_DIR: /var/lib/buildx-cache/bakery-arm64
jobs:
build-amd64:
runs-on: [self-hosted, linux, x64]
steps:
- uses: actions/checkout@v4
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: marksverdhei
password: ${{ secrets.DOCKER_PAT }}
- name: Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.IMAGE_NAME }}
tags: |
type=raw,value=latest,enable={{is_default_branch}}
type=semver,pattern={{version}}
type=sha,prefix=
- name: Build and push
env:
TAGS: ${{ steps.meta.outputs.tags }}
run: |
docker build -t ${{ env.IMAGE_NAME }}:ci-build -f Dockerfile .
echo "$TAGS" | while IFS= read -r tag; do
[ -z "$tag" ] && continue
docker tag ${{ env.IMAGE_NAME }}:ci-build "$tag"
docker push "$tag"
done
- name: Cleanup
if: always()
run: |
docker rmi ${{ env.IMAGE_NAME }}:ci-build 2>/dev/null || true
docker image prune -f --filter "label=org.opencontainers.image.source=https://github.com/marksverdhei/bakery" --filter "until=72h" 2>/dev/null || true
build-arm64:
runs-on: [self-hosted, linux, x64]
needs: build-amd64
steps:
- uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: arm64
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
buildkitd-config-inline: |
[worker.oci]
[[worker.oci.gcpolicy]]
maxUsedSpace = "20GB"
keepDuration = 604800
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: marksverdhei
password: ${{ secrets.DOCKER_PAT }}
- name: Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.IMAGE_NAME }}
tags: |
type=raw,value=latest-arm64,enable={{is_default_branch}}
type=semver,pattern={{version}},suffix=-arm64
type=sha,prefix=,suffix=-arm64
- name: Prepare cache
run: mkdir -p ${{ env.ARM64_CACHE_DIR }}
- name: Build and push (arm64)
uses: docker/build-push-action@v6
with:
context: .
file: Dockerfile.arm64
platforms: linux/arm64
push: true
provenance: false
sbom: false
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=local,src=${{ env.ARM64_CACHE_DIR }}
cache-to: type=local,dest=${{ env.ARM64_CACHE_DIR }}-new,mode=max
- name: Rotate cache
if: always()
run: |
rm -rf ${{ env.ARM64_CACHE_DIR }}
if [ -d "${{ env.ARM64_CACHE_DIR }}-new" ]; then
mv ${{ env.ARM64_CACHE_DIR }}-new ${{ env.ARM64_CACHE_DIR }}
fi
- name: Cleanup
if: always()
run: |
docker buildx prune -f --keep-storage 20g 2>/dev/null || true
docker image prune -f --filter "until=72h" 2>/dev/null || true