@@ -88,124 +88,8 @@ jobs:
8888 <<< $deps jq
8989 echo "deps=$deps" >> $GITHUB_OUTPUT
9090
91- load :
92- needs : [setup]
93- strategy :
94- matrix :
95- dep : ${{ fromJSON(needs.setup.outputs.deps) }}
96- arch : ${{ fromJSON(inputs.archs) }}
97- fail-fast : false
98- name : 2 load (${{ matrix.dep.name }}, ${{ matrix.dep.ref }}, ${{ matrix.arch }}, ${{ matrix.dep.options && toJSON(matrix.dep.options) || '-' }})
99- runs-on : ubuntu-latest
100- env :
101- dep_json : ${{ toJSON(matrix.dep) }}
102- image_filename : image-${{ matrix.dep.name }}-${{ matrix.dep.id }}-${{ matrix.arch }}.tar
103- json_filename : image-${{ matrix.dep.name }}-${{ matrix.dep.id }}-${{ matrix.arch }}.json
104- missing_filename : missing-${{ matrix.dep.name }}-${{ matrix.dep.id }}-${{ matrix.arch }}.json
105- steps :
106- - name : Create Dep Details JSON (with arch)
107- run : >
108- echo "${dep_json}"
109- | jq --arg arch ${{ matrix.arch }} '.arch = $arch'
110- | tee /tmp/${{ env.json_filename }}
111- - name : Upload Dep Details JSON
112- uses : actions/upload-artifact@v4
113- with :
114- name : ${{ env.json_filename }}
115- path : /tmp/${{ env.json_filename }}
116- retention-days : ${{ env.artifact_retention_days_for_image }}
117- - name : Find Image in Cache
118- id : cache
119- uses : actions/cache/restore@v3
120- with :
121- key : ${{ inputs.cache_prefix }}${{ inputs.cache_id }}-${{ env.image_filename }}
122- path : /tmp/${{ env.image_filename }}
123- - name : Upload Image to Artifacts
124- if : steps.cache.outputs.cache-hit == 'true'
125- uses : actions/upload-artifact@v4
126- with :
127- name : ${{ env.image_filename }}
128- path : /tmp/${{ env.image_filename }}
129- retention-days : ${{ env.artifact_retention_days_for_image }}
130- - name : Upload Dep Details as Missing Marker Due to Cache Miss
131- if : steps.cache.outputs.cache-hit != 'true'
132- uses : actions/upload-artifact@v4
133- with :
134- name : ${{ env.missing_filename }}
135- path : /tmp/${{ env.json_filename }}
136- retention-days : ${{ env.artifact_retention_days_for_image }}
137-
138- prepare :
139- needs : [load]
140- name : 3 prepare
141- runs-on : ubuntu-latest
142- outputs :
143- deps-to-build : ${{ steps.deps-to-build.outputs.deps }}
144- steps :
145- - name : Download Missing Markers
146- uses : actions/download-artifact@v4
147- with :
148- pattern : missing-*
149- merge-multiple : true
150- path : /tmp/missing
151- - name : Collect Deps-to-Build from Missing Markers
152- id : deps-to-build
153- run : |
154- deps="$(find /tmp/missing -name "*.json" -exec cat {} \; | jq -c -s '.')"
155- echo "deps=$deps" | tee -a $GITHUB_OUTPUT
156-
157- build-dep :
158- needs : [setup, prepare]
159- if : needs.prepare.outputs.deps-to-build != '[]'
160- strategy :
161- matrix :
162- dep : ${{ fromJSON(needs.prepare.outputs.deps-to-build) }}
163- fail-fast : false
164- name : 4 build (${{ matrix.dep.name }}, ${{ matrix.dep.ref }}, ${{ matrix.dep.arch }}, ${{ matrix.dep.options && toJSON(matrix.dep.options) || '-' }})
165- runs-on : ${{ matrix.dep.arch == 'arm64' && 'ubuntu-24.04-arm' || 'ubuntu-latest' }}
166- env :
167- image_filename : image-${{ matrix.dep.name }}-${{ matrix.dep.id }}-${{ matrix.dep.arch }}.tar
168- dep_json : ${{ toJSON(matrix.dep) }}
169- steps :
170- - uses : actions/checkout@v3
171- with :
172- repository : ${{ inputs.repo }}
173- ref : ${{ inputs.sha }}
174- - name : Dep Args
175- id : dep_args
176- run : |
177- args="$(<<< $dep_json jq -c -r '[
178- "--build-arg \(.name | ascii_upcase)_REPO=\(.repo)",
179- "--build-arg \(.name | ascii_upcase)_REF=\(.sha)",
180- "--build-arg \(.name | ascii_upcase)_OPTIONS='"'"'\(.options)'"'"'"
181- ] | join(" ")')"
182- echo "args=${args}" | tee -a $GITHUB_OUTPUT
183- - name : Build Image
184- run : >
185- docker build
186- --platform linux/${{ matrix.dep.arch }}
187- -f Dockerfile
188- --target stellar-${{ matrix.dep.name }}-stage
189- -t stellar-${{ matrix.dep.name }}:${{ matrix.dep.sha }}-${{ matrix.dep.arch }}
190- ${{ steps.dep_args.outputs.args }}
191- .
192- - name : Save Image
193- run : docker save stellar-${{ matrix.dep.name }}:${{ matrix.dep.sha }}-${{ matrix.dep.arch }} -o /tmp/${{ env.image_filename }}
194- - name : Upload Image to Cache
195- uses : actions/cache/save@v3
196- id : cache
197- with :
198- key : ${{ inputs.cache_prefix }}${{ inputs.cache_id }}-${{ env.image_filename }}
199- path : /tmp/${{ env.image_filename }}
200- - name : Upload Image to Artifacts
201- uses : actions/upload-artifact@v4
202- with :
203- name : ${{ env.image_filename }}
204- path : /tmp/${{ env.image_filename }}
205- retention-days : ${{ env.artifact_retention_days_for_image }}
206-
20791 build :
208- needs : [setup, load, build-dep ]
92+ needs : [setup]
20993 if : always() && !failure() && !cancelled()
21094 strategy :
21195 matrix :
@@ -228,63 +112,22 @@ jobs:
228112 - name : Write Image Config
229113 run : |
230114 echo "$image_json" > .image.json
231- - name : Download Image XDR
232- uses : actions/download-artifact@v4
233- with :
234- pattern : image-xdr-${{ steps.ids.outputs.xdr }}-${{ matrix.arch }}.*
235- merge-multiple : true
236- path : /tmp/images
237- - name : Download Image Core
238- uses : actions/download-artifact@v4
239- with :
240- pattern : image-core-${{ steps.ids.outputs.core }}-${{ matrix.arch }}.*
241- merge-multiple : true
242- path : /tmp/images
243- - name : Download Image RPC
244- uses : actions/download-artifact@v4
245- with :
246- pattern : image-rpc-${{ steps.ids.outputs.rpc }}-${{ matrix.arch }}.*
247- merge-multiple : true
248- path : /tmp/images
249- - name : Download Image Horizon
250- uses : actions/download-artifact@v4
251- with :
252- pattern : image-horizon-${{ steps.ids.outputs.horizon }}-${{ matrix.arch }}.*
253- merge-multiple : true
254- path : /tmp/images
255- - name : Download Image Friendbot
256- uses : actions/download-artifact@v4
257- with :
258- pattern : image-friendbot-${{ steps.ids.outputs.friendbot }}-${{ matrix.arch }}.*
259- merge-multiple : true
260- path : /tmp/images
261- - name : Download Image Lab
262- uses : actions/download-artifact@v4
263- with :
264- pattern : image-lab-${{ steps.ids.outputs.lab }}-${{ matrix.arch }}.*
265- merge-multiple : true
266- path : /tmp/images
267- - name : Load Image into Docker
268- run : |
269- ls -lah /tmp/images/
270- for image in /tmp/images/*.tar; do
271- echo Loading image $image
272- < "${image/%.tar/.json}" jq
273- docker load -i $image
274- done
275115 - name : Pull Base Image
276116 run : docker pull --platform linux/${{ matrix.arch }} ubuntu:22.04
277117 - name : Build Args for Deps
278118 id : dep_args
279119 run : |
280120 args="$(<<< $image_json jq -c -r '[ .deps[] | [
281- "--build-arg \(.name | ascii_upcase)_IMAGE=stellar-\(.name):\(.sha)-${{ matrix.arch }}"
121+ "--build-arg \(.name | ascii_upcase)_REPO=\(.repo)",
122+ "--build-arg \(.name | ascii_upcase)_REF=\(.sha)",
123+ "--build-arg \(.name | ascii_upcase)_OPTIONS='"'"'\(.options)'"'"'"
282124 ] ] | flatten | join(" ")')"
283125 echo "args=${args}" | tee -a $GITHUB_OUTPUT
284126 - name : Build Image
285127 run : >
286128 docker build
287129 --platform linux/${{ matrix.arch }}
130+ --cache-from=type=gha --cache-to=type=gha,mode=max,compression=zstd
288131 -f Dockerfile
289132 -t quickstart:${{ matrix.image.tag }}-${{ matrix.arch }}
290133 --label org.opencontainers.image.revision="${{ inputs.sha }}"
0 commit comments