forked from steemit/steem
-
Notifications
You must be signed in to change notification settings - Fork 7
129 lines (114 loc) · 4.75 KB
/
docker-main.yml
File metadata and controls
129 lines (114 loc) · 4.75 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
name: Build docker images
on:
push:
branches:
- master
paths-ignore:
- 'documentation/**'
- '**.md'
jobs:
build_testnet:
name: Build testnet image
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- uses: docker/setup-buildx-action@v3
id: setup-buildx
- uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
# Cache-mount key hashes BOTH Dockerfiles so the testnet and
# production jobs (which install identical packages) compute the
# same key prefix — letting build_prod restore what build_testnet
# just saved.
- name: Restore BuildKit cache mounts from Actions Cache
uses: actions/cache@v4
id: cache-mounts
with:
path: cache-mount
key: viz-cache-mount-${{ runner.os }}-main-${{ hashFiles('share/vizd/docker/Dockerfile-production', 'share/vizd/docker/Dockerfile-testnet') }}-${{ github.sha }}
restore-keys: |
viz-cache-mount-${{ runner.os }}-main-${{ hashFiles('share/vizd/docker/Dockerfile-production', 'share/vizd/docker/Dockerfile-testnet') }}-
viz-cache-mount-${{ runner.os }}-main-
- name: Inject cache mounts into BuildKit
uses: reproducible-containers/buildkit-cache-dance@v3
with:
builder: ${{ steps.setup-buildx.outputs.name }}
cache-map: |
{
"cache-mount/var-cache-apt": "/var/cache/apt",
"cache-mount/var-lib-apt-lists": "/var/lib/apt/lists",
"cache-mount/ccache": {
"target": "/root/.ccache",
"id": "viz-ccache"
}
}
skip-extraction: ${{ steps.cache-mounts.outputs.cache-hit }}
# Both jobs share scope=main so build_prod (which runs after
# build_testnet via needs:) can reuse the ccache populated by the
# testnet build. The two images differ only in CMake flags so most
# compiled object files have identical ccache hashes.
- uses: docker/build-push-action@v6
with:
context: .
file: ./share/vizd/docker/Dockerfile-testnet
push: true
tags: vizblockchain/vizd:testnet
cache-from: type=gha,scope=main
cache-to: type=gha,scope=main,mode=max
build_prod:
name: Build production image
runs-on: ubuntu-latest
# needs: build_testnet ensures build_prod runs after build_testnet so
# it can pull the warm cache exported by build_testnet's cache-to step.
# Side-effect: a build_testnet failure now blocks build_prod, which is
# arguably an improvement (don't ship prod if testnet is broken).
needs: build_testnet
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- uses: docker/setup-buildx-action@v3
id: setup-buildx
- uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
# Same cache-mount key prefix as build_testnet so this job restores
# the cache build_testnet just saved (same SHA, same Dockerfile
# hashes). Apt content fully reusable; ccache reuse depends on how
# -DBUILD_TESTNET propagates through the build (measured per run).
- name: Restore BuildKit cache mounts from Actions Cache
uses: actions/cache@v4
id: cache-mounts
with:
path: cache-mount
key: viz-cache-mount-${{ runner.os }}-main-${{ hashFiles('share/vizd/docker/Dockerfile-production', 'share/vizd/docker/Dockerfile-testnet') }}-${{ github.sha }}
restore-keys: |
viz-cache-mount-${{ runner.os }}-main-${{ hashFiles('share/vizd/docker/Dockerfile-production', 'share/vizd/docker/Dockerfile-testnet') }}-
viz-cache-mount-${{ runner.os }}-main-
- name: Inject cache mounts into BuildKit
uses: reproducible-containers/buildkit-cache-dance@v3
with:
builder: ${{ steps.setup-buildx.outputs.name }}
cache-map: |
{
"cache-mount/var-cache-apt": "/var/cache/apt",
"cache-mount/var-lib-apt-lists": "/var/lib/apt/lists",
"cache-mount/ccache": {
"target": "/root/.ccache",
"id": "viz-ccache"
}
}
skip-extraction: ${{ steps.cache-mounts.outputs.cache-hit }}
- uses: docker/build-push-action@v6
with:
context: .
file: ./share/vizd/docker/Dockerfile-production
push: true
tags: vizblockchain/vizd:latest
cache-from: type=gha,scope=main
cache-to: type=gha,scope=main,mode=max