forked from dragonflydb/dragonfly
-
Notifications
You must be signed in to change notification settings - Fork 0
131 lines (115 loc) · 4.2 KB
/
docker-dev-release.yml
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
name: Development Docker Build
on:
schedule:
- cron: '15 0 * * *'
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
env:
image: ghcr.io/dragonflydb/dragonfly-dev
jobs:
build_and_tag:
name: Build and Push ${{matrix.flavor}} ${{ matrix.os.arch }} image
strategy:
matrix:
flavor: [alpine,ubuntu]
os:
- image: ubuntu-24.04
arch: amd64
- image: ubuntu-24.04-arm
arch: arm64
runs-on: ${{ matrix.os.image }}
permissions:
contents: read
packages: write
id-token: write
steps:
- name: checkout
uses: actions/checkout@v4
with:
fetch-depth: 1
submodules: true
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Get Build Information
id: build_info
run: |
echo "short_sha=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
- name: Docker meta
id: metadata
uses: docker/metadata-action@v5
with:
images: |
${{ env.image }}
tags: |
type=sha,enable=true,prefix=${{ matrix.flavor}}-,suffix=-${{ matrix.os.arch }},format=short
labels: |
org.opencontainers.image.vendor=DragonflyDB LTD
org.opencontainers.image.title=Dragonfly Development Image
org.opencontainers.image.description=The fastest in-memory store
- name: Build image
id: build
uses: docker/build-push-action@v6
with:
context: .
push: true
provenance: false # Prevent pushing a docker manifest
tags: |
${{ steps.metadata.outputs.tags }}
labels: ${{ steps.metadata.outputs.labels }}
file: tools/packaging/Dockerfile.${{ matrix.flavor }}-dev
cache-from: type=gha,scope=tagged${{ matrix.flavor }}
cache-to: type=gha,scope=tagged${{ matrix.flavor }},mode=max
load: true # Load the build images into the local docker.
- name: Test Image
run: |
image_tag=${{ steps.metadata.outputs.tags }}
echo ${{ steps.build.outputs.digest }}
image_digest=${{ env.image }}@${{ steps.build.outputs.digest }}
# install redis-tools
sudo apt-get install redis-tools -y
docker image inspect ${image_tag}
echo "Testing ${{ matrix.flavor }} image"
# docker run with port-forwarding
docker run -d -p 6379:6379 ${image_tag}
sleep 5
if [[ $(redis-cli -h localhost ping) != "PONG" ]]; then
echo "Redis ping failed"
exit 1
fi
echo "Redis ping succeeded"
exit 0
outputs:
# matrix jobs outputs override each other, but we use the same sha
# for all images, so we can use the same output name.
sha: ${{ steps.build_info.outputs.short_sha }}
merge_manifest:
needs: [build_and_tag]
runs-on: ubuntu-latest
strategy:
matrix:
flavor: [alpine,ubuntu]
steps:
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Merge and Push
run: |
flavor_tag=${{ env.image }}:${{matrix.flavor}}
sha_tag=${flavor_tag}-${{ needs.build_and_tag.outputs.sha }}
# Create and push the manifest like dragonfly-dev:alpine-<sha>
docker manifest create ${sha_tag} --amend ${sha_tag}-amd64 --amend ${sha_tag}-arm64
docker manifest push ${sha_tag}
# Create and push the manifest like dragonfly-dev:alpine
docker manifest create ${flavor_tag} --amend ${sha_tag}-amd64 --amend ${sha_tag}-arm64
docker manifest push ${flavor_tag}