Repository navigation
174 lines (158 loc) · 6.29 KB
/
Copy pathdocker.yml
File metadata and controls
174 lines (158 loc) · 6.29 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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
---
name: Docker
# Build & Push rebuilds the Tenderdash docker image every time a release is
# published and pushes the image to https://hub.docker.com/r/dashpay/tenderdash
on:
workflow_dispatch:
inputs:
tag:
type: string
description: "Existing release tag to build (empty uses the selected branch/tag)"
required: false
platforms:
type: choice
description: "Image architecture to build"
default: "linux/amd64,linux/arm64"
options:
- "linux/amd64,linux/arm64"
- "linux/amd64"
- "linux/arm64"
release:
types:
- published
# Docker Hub auth uses repository secrets; GITHUB_TOKEN only needs to read the repo.
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-26.04
outputs:
source_sha: ${{ steps.source.outputs.source_sha }}
digest: ${{ steps.docker_build.outputs.digest }}
env:
PLATFORMS: ${{ github.event_name == 'release' && 'linux/amd64,linux/arm64' || github.event.inputs.platforms }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
- name: Validate Docker publication contract
run: python3 -B -m unittest discover -s scripts/tests -p test_docker_metadata.py
- name: Resolve exact build source and version
id: source
env:
LATEST_RELEASE_TAG: pending
run: python3 scripts/docker-metadata.py
- name: Checkout resolved source
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ steps.source.outputs.source_sha }}
fetch-depth: 0
- name: Set up QEMU
uses: docker/setup-qemu-action@99012661954931238ded8c8b007157a8430204e1 # v4.4.0
with:
platforms: all
- name: Set up Docker Build
uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v4.4.1
- name: Login to DockerHub
if: ${{ github.event_name != 'pull_request' }}
uses: docker/login-action@8aa5831fb8d48d8f76594c7ddde61ae58019f550 # v4.8.0
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Set Docker tags and labels
id: docker_meta
uses: docker/metadata-action@dc802804100637a589fabce1cb79ff13a1411302 # v6.2.0
with:
images: dashpay/tenderdash
tags: ${{ steps.source.outputs.tags }}
labels: |
org.opencontainers.image.version=${{ steps.source.outputs.version }}
org.opencontainers.image.revision=${{ steps.source.outputs.source_sha }}
flavor: latest=false
# We build some dependencies and libraries separately. Layers are cached
# on Docker Hub, as Github caches are not available for other branches.
- name: Build and cache image with dependencies
id: docker_bls
uses: docker/build-push-action@c3c9e263c25d99ce0380d002d59b67737d91b0dc # v7.4.0
with:
context: .
file: ./DOCKER/Dockerfile
platforms: ${{ env.PLATFORMS }}
target: base
push: false
cache-from: |
type=registry,ref=dashpay/tenderdash:buildcache-deps
cache-to: |
type=registry,ref=dashpay/tenderdash:buildcache-deps,mode=max
build-args: |
TENDERMINT_BUILD_OPTIONS=${{ steps.source.outputs.build_options }}
VERSION=${{ steps.source.outputs.version }}
- name: Publish to Docker Hub
id: docker_build
uses: docker/build-push-action@c3c9e263c25d99ce0380d002d59b67737d91b0dc # v7.4.0
with:
context: .
file: ./DOCKER/Dockerfile
platforms: ${{ env.PLATFORMS }}
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.docker_meta.outputs.tags }}
labels: ${{ steps.docker_meta.outputs.labels }}
cache-from: |
type=gha
type=registry,ref=dashpay/tenderdash:buildcache-deps
cache-to: type=gha,mode=max
build-args: |
TENDERMINT_BUILD_OPTIONS=${{ steps.source.outputs.build_options }}
VERSION=${{ steps.source.outputs.version }}
- name: Show Docker image digest
run: echo ${{ steps.docker_build.outputs.digest }}
# Serialize alias checks/writes without replacing pending release promotions.
promote-aliases:
if: github.event_name == 'release'
needs: build
runs-on: ubuntu-26.04
concurrency:
group: docker-stable-aliases
cancel-in-progress: false
queue: max
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ needs.build.outputs.source_sha }}
fetch-depth: 0
- uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v4.4.1
- uses: docker/login-action@8aa5831fb8d48d8f76594c7ddde61ae58019f550 # v4.8.0
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Read current latest release after building
if: github.event_name == 'release'
id: latest
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
with:
result-encoding: string
script: |
try {
const {data} = await github.rest.repos.getLatestRelease(context.repo);
return data.tag_name;
} catch (error) {
if (error.status === 404) return '';
throw error;
}
- name: Resolve stable aliases
if: github.event_name == 'release'
id: aliases
env:
LATEST_RELEASE_TAG: ${{ steps.latest.outputs.result }}
run: python3 scripts/docker-metadata.py
- name: Promote current stable aliases
if: github.event_name == 'release' && steps.aliases.outputs.aliases != ''
env:
ALIASES: ${{ steps.aliases.outputs.aliases }}
SOURCE_IMAGE: dashpay/tenderdash@${{ needs.build.outputs.digest }}
run: |
set --
while IFS= read -r alias; do
set -- "$@" --tag "dashpay/tenderdash:$alias"
done <<< "$ALIASES"
docker buildx imagetools create "$@" "$SOURCE_IMAGE"