Skip to content

Commit 66a4217

Browse files
authored
⚗️CI: Separate image building of frontend (#6918)
1 parent 186c07b commit 66a4217

File tree

22 files changed

+108
-111
lines changed

22 files changed

+108
-111
lines changed

.github/workflows/ci-testing-deploy.yml

Lines changed: 52 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -272,20 +272,43 @@ jobs:
272272
python: ["3.11"]
273273
os: [ubuntu-22.04]
274274
fail-fast: false
275-
name: "[build] docker images"
275+
name: "[build] docker images (excluding frontend)"
276276
steps:
277-
- name: Remove unused software
277+
- uses: actions/checkout@v4
278+
- name: setup docker buildx
279+
id: buildx
280+
uses: docker/setup-buildx-action@v3
281+
with:
282+
driver: docker-container
283+
- name: expose github runtime for buildx
284+
uses: crazy-max/ghaction-github-runtime@v3
285+
- name: show system environs
286+
run: ./ci/helpers/show_system_versions.bash
287+
- name: build images
278288
run: |
279-
echo "Available storage before:"
280-
sudo df -h
281-
echo
282-
sudo rm -rf /usr/share/dotnet
283-
sudo rm -rf /usr/local/lib/android
284-
sudo rm -rf /opt/ghc
285-
sudo rm -rf /opt/hostedtoolcache/CodeQL
286-
echo "Available storage after:"
287-
sudo df -h
288-
echo
289+
export DOCKER_IMAGE_TAG=$(exec ci/helpers/build_docker_image_tag.bash)
290+
mkdir --parents /${{ runner.temp }}/build
291+
make build local-dest=/${{ runner.temp }}/build exclude=static-webserver
292+
- name: upload build artifacts
293+
uses: actions/upload-artifact@v4
294+
with:
295+
name: docker-buildx-images-${{ runner.os }}-${{ github.sha }}-backend
296+
path: /${{ runner.temp }}/build
297+
298+
build-test-images-frontend:
299+
# this step comes first, so that it is executed as first job in push calls
300+
# in PR calls this step is anyway skipped
301+
needs: changes
302+
if: ${{ needs.changes.outputs.anything == 'true' || github.event_name == 'push' }}
303+
timeout-minutes: 30
304+
runs-on: ${{ matrix.os }}
305+
strategy:
306+
matrix:
307+
python: ["3.11"]
308+
os: [ubuntu-22.04]
309+
fail-fast: false
310+
name: "[build] docker images (frontend-only)"
311+
steps:
289312
- uses: actions/checkout@v4
290313
- name: setup docker buildx
291314
id: buildx
@@ -300,11 +323,11 @@ jobs:
300323
run: |
301324
export DOCKER_IMAGE_TAG=$(exec ci/helpers/build_docker_image_tag.bash)
302325
mkdir --parents /${{ runner.temp }}/build
303-
make build local-dest=/${{ runner.temp }}/build
326+
make build local-dest=/${{ runner.temp }}/build target=static-webserver
304327
- name: upload build artifacts
305328
uses: actions/upload-artifact@v4
306329
with:
307-
name: docker-buildx-images-${{ runner.os }}-${{ github.sha }}
330+
name: docker-buildx-images-${{ runner.os }}-${{ github.sha }}-frontend
308331
path: /${{ runner.temp }}/build
309332

310333
unit-test-webserver-01:
@@ -1868,7 +1891,7 @@ jobs:
18681891
with:
18691892
action: actions/download-artifact@v4
18701893
with: |
1871-
name: docker-buildx-images-${{ runner.os }}-${{ github.sha }}
1894+
name: docker-buildx-images-${{ runner.os }}-${{ github.sha }}-backend
18721895
path: /${{ runner.temp }}/build
18731896
attempt_limit: 5
18741897
attempt_delay: 1000
@@ -1932,7 +1955,7 @@ jobs:
19321955
with:
19331956
action: actions/download-artifact@v4
19341957
with: |
1935-
name: docker-buildx-images-${{ runner.os }}-${{ github.sha }}
1958+
name: docker-buildx-images-${{ runner.os }}-${{ github.sha }}-backend
19361959
path: /${{ runner.temp }}/build
19371960
attempt_limit: 5
19381961
attempt_delay: 1000
@@ -1996,7 +2019,7 @@ jobs:
19962019
with:
19972020
action: actions/download-artifact@v4
19982021
with: |
1999-
name: docker-buildx-images-${{ runner.os }}-${{ github.sha }}
2022+
name: docker-buildx-images-${{ runner.os }}-${{ github.sha }}-backend
20002023
path: /${{ runner.temp }}/build
20012024
attempt_limit: 5
20022025
attempt_delay: 1000
@@ -2067,7 +2090,7 @@ jobs:
20672090
with:
20682091
action: actions/download-artifact@v4
20692092
with: |
2070-
name: docker-buildx-images-${{ runner.os }}-${{ github.sha }}
2093+
name: docker-buildx-images-${{ runner.os }}-${{ github.sha }}-backend
20712094
path: /${{ runner.temp }}/build
20722095
attempt_limit: 5
20732096
attempt_delay: 1000
@@ -2133,7 +2156,7 @@ jobs:
21332156
with:
21342157
action: actions/download-artifact@v4
21352158
with: |
2136-
name: docker-buildx-images-${{ runner.os }}-${{ github.sha }}
2159+
name: docker-buildx-images-${{ runner.os }}-${{ github.sha }}-backend
21372160
path: /${{ runner.temp }}/build
21382161
attempt_limit: 5
21392162
attempt_delay: 1000
@@ -2199,7 +2222,7 @@ jobs:
21992222
with:
22002223
action: actions/download-artifact@v4
22012224
with: |
2202-
name: docker-buildx-images-${{ runner.os }}-${{ github.sha }}
2225+
name: docker-buildx-images-${{ runner.os }}-${{ github.sha }}-backend
22032226
path: /${{ runner.temp }}/build
22042227
attempt_limit: 5
22052228
attempt_delay: 1000
@@ -2257,7 +2280,7 @@ jobs:
22572280
run: echo "::notice All good!"
22582281

22592282
system-test-public-api:
2260-
needs: [changes, build-test-images]
2283+
needs: [changes, build-test-images, build-test-images-frontend]
22612284
if: ${{ needs.changes.outputs.anything == 'true' || github.event_name == 'push' }}
22622285
timeout-minutes: 25 # if this timeout gets too small, then split the tests
22632286
name: "[sys] public api"
@@ -2286,7 +2309,7 @@ jobs:
22862309
with:
22872310
action: actions/download-artifact@v4
22882311
with: |
2289-
name: docker-buildx-images-${{ runner.os }}-${{ github.sha }}
2312+
pattern: docker-buildx-images-${{ runner.os }}-${{ github.sha }}-*
22902313
path: /${{ runner.temp }}/build
22912314
attempt_limit: 5
22922315
attempt_delay: 1000
@@ -2317,7 +2340,7 @@ jobs:
23172340
run: ./ci/github/system-testing/public-api.bash clean_up
23182341

23192342
system-test-swarm-deploy:
2320-
needs: [changes, build-test-images]
2343+
needs: [changes, build-test-images, build-test-images-frontend]
23212344
if: ${{ needs.changes.outputs.anything == 'true' || github.event_name == 'push' }}
23222345
timeout-minutes: 30 # if this timeout gets too small, then split the tests
23232346
name: "[sys] deploy simcore"
@@ -2346,7 +2369,7 @@ jobs:
23462369
with:
23472370
action: actions/download-artifact@v4
23482371
with: |
2349-
name: docker-buildx-images-${{ runner.os }}-${{ github.sha }}
2372+
pattern: docker-buildx-images-${{ runner.os }}-${{ github.sha }}-*
23502373
path: /${{ runner.temp }}/build
23512374
attempt_limit: 5
23522375
attempt_delay: 1000
@@ -2382,7 +2405,7 @@ jobs:
23822405
run: ./ci/github/system-testing/swarm-deploy.bash clean_up
23832406

23842407
system-test-e2e:
2385-
needs: [changes, build-test-images]
2408+
needs: [changes, build-test-images, build-test-images-frontend]
23862409
if: ${{ needs.changes.outputs.anything == 'true' || github.event_name == 'push' }}
23872410
timeout-minutes: 30 # if this timeout gets too small, then split the tests
23882411
name: "[sys] e2e"
@@ -2417,7 +2440,7 @@ jobs:
24172440
with:
24182441
action: actions/download-artifact@v4
24192442
with: |
2420-
name: docker-buildx-images-${{ runner.os }}-${{ github.sha }}
2443+
pattern: docker-buildx-images-${{ runner.os }}-${{ github.sha }}-*
24212444
path: /${{ runner.temp }}/build
24222445
attempt_limit: 5
24232446
attempt_delay: 1000
@@ -2462,7 +2485,7 @@ jobs:
24622485
run: ./ci/github/system-testing/e2e.bash clean_up
24632486

24642487
system-test-e2e-playwright:
2465-
needs: [changes, build-test-images]
2488+
needs: [changes, build-test-images, build-test-images-frontend]
24662489
if: ${{ needs.changes.outputs.anything == 'true' || github.event_name == 'push' }}
24672490
timeout-minutes: 30 # if this timeout gets too small, then split the tests
24682491
name: "[sys] e2e-playwright"
@@ -2497,7 +2520,7 @@ jobs:
24972520
- name: download docker images
24982521
uses: actions/download-artifact@v4
24992522
with:
2500-
name: docker-buildx-images-${{ runner.os }}-${{ github.sha }}
2523+
pattern: docker-buildx-images-${{ runner.os }}-${{ github.sha }}-*
25012524
path: /${{ runner.temp }}/build
25022525
- name: load docker images
25032526
run: make load-images local-src=/${{ runner.temp }}/build
@@ -2616,7 +2639,7 @@ jobs:
26162639
with:
26172640
action: actions/download-artifact@v4
26182641
with: |
2619-
name: docker-buildx-images-${{ runner.os }}-${{ github.sha }}
2642+
pattern: docker-buildx-images-${{ runner.os }}-${{ github.sha }}-*
26202643
path: /${{ runner.temp }}/build
26212644
attempt_limit: 5
26222645
attempt_delay: 1000

Makefile

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -153,14 +153,15 @@ DOCKER_TARGET_PLATFORMS ?= linux/amd64
153153
comma := ,
154154

155155
define _docker_compose_build
156+
$(eval INCLUDED_SERVICES := $(filter-out $(exclude), $(SERVICES_NAMES_TO_BUILD))) \
156157
export BUILD_TARGET=$(if $(findstring -devel,$@),development,production) &&\
157158
pushd services &&\
158159
$(foreach service, $(SERVICES_NAMES_TO_BUILD),\
159160
$(if $(push),\
160161
export $(subst -,_,$(shell echo $(service) | tr a-z A-Z))_VERSION=$(shell cat services/$(service)/VERSION);\
161162
,) \
162163
)\
163-
docker buildx bake \
164+
docker buildx bake --allow=fs.read=.. \
164165
$(if $(findstring -devel,$@),,\
165166
--set *.platform=$(DOCKER_TARGET_PLATFORMS) \
166167
)\
@@ -172,7 +173,7 @@ docker buildx bake \
172173
)\
173174
)\
174175
$(if $(push),--push,) \
175-
$(if $(push),--file docker-bake.hcl,) --file docker-compose-build.yml $(if $(target),$(target),) \
176+
$(if $(push),--file docker-bake.hcl,) --file docker-compose-build.yml $(if $(target),$(target),$(INCLUDED_SERVICES)) \
176177
$(if $(findstring -nc,$@),--no-cache,\
177178
$(foreach service, $(SERVICES_NAMES_TO_BUILD),\
178179
--set $(service).cache-to=type=gha$(comma)mode=max$(comma)scope=$(service) \
@@ -183,22 +184,20 @@ endef
183184

184185
rebuild: build-nc # alias
185186
build build-nc: .env ## Builds production images and tags them as 'local/{service-name}:production'. For single target e.g. 'make target=webserver build'. To export to a folder: `make local-dest=/tmp/build`
186-
# Building service$(if $(target),,s) $(target)
187+
# Building service$(if $(target),,s) $(target) $(if $(exclude),excluding,) $(exclude)
187188
@$(_docker_compose_build)
188189
# List production images
189190
@docker images --filter="reference=local/*:production"
190191

191192
load-images: guard-local-src ## loads images from local-src
192-
# loading from images from $(local-src)...
193-
@$(foreach service, $(SERVICES_NAMES_TO_BUILD),\
194-
docker load --input $(local-src)/$(service).tar; \
195-
)
193+
# loading from any tar images from $(local-src)...
194+
@find $(local-src) -name '*.tar' -print0 | xargs -0 -n1 -P $(shell nproc) --no-run-if-empty --verbose docker load --input
196195
# all images loaded
197196
@docker images
198197

199198
build-devel build-devel-nc: .env ## Builds development images and tags them as 'local/{service-name}:development'. For single target e.g. 'make target=webserver build-devel'
200199
ifeq ($(target),)
201-
# Building services
200+
# Building services $(if $(exclude),excluding,) $(exclude)
202201
@$(_docker_compose_build)
203202
else
204203
ifeq ($(findstring static-webserver,$(target)),static-webserver)

packages/service-integration/Dockerfile

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ LABEL maintainer=pcrespov
1212
# for docker apt caching to work this needs to be added: [https://vsupalov.com/buildkit-cache-mount-dockerfile/]
1313
RUN rm -f /etc/apt/apt.conf.d/docker-clean && \
1414
echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' > /etc/apt/apt.conf.d/keep-cache
15-
RUN --mount=type=cache,target=/var/cache/apt,mode=0755,sharing=private \
16-
--mount=type=cache,target=/var/lib/apt,mode=0755,sharing=private \
15+
RUN --mount=type=cache,target=/var/cache/apt,sharing=private \
1716
set -eux \
1817
&& apt-get update \
1918
&& apt-get install -y --no-install-recommends \
@@ -54,8 +53,7 @@ ENV PATH="${VIRTUAL_ENV}/bin:$PATH"
5453

5554
FROM base AS build
5655

57-
RUN --mount=type=cache,target=/var/cache/apt,mode=0755,sharing=private \
58-
--mount=type=cache,target=/var/lib/apt,mode=0755,sharing=private \
56+
RUN --mount=type=cache,target=/var/cache/apt,sharing=private \
5957
set -eux && \
6058
apt-get update \
6159
&& apt-get install -y --no-install-recommends \

requirements/tools/Dockerfile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ FROM python:${PYTHON_VERSION}-slim-bookworm AS base
1616

1717
ENV VIRTUAL_ENV=/home/scu/.venv
1818

19-
RUN --mount=type=cache,target=/var/cache/apt,mode=0755,sharing=private \
20-
--mount=type=cache,target=/var/lib/apt,mode=0755,sharing=private \
19+
RUN --mount=type=cache,target=/var/cache/apt,sharing=private \
2120
set -eux && \
2221
apt-get update \
2322
&& apt-get -y install --no-install-recommends\

services/agent/Dockerfile

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ LABEL maintainer=GitHK
2020
# for docker apt caching to work this needs to be added: [https://vsupalov.com/buildkit-cache-mount-dockerfile/]
2121
RUN rm -f /etc/apt/apt.conf.d/docker-clean && \
2222
echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' > /etc/apt/apt.conf.d/keep-cache
23-
RUN --mount=type=cache,target=/var/cache/apt,mode=0755,sharing=private \
24-
--mount=type=cache,target=/var/lib/apt,mode=0755,sharing=private \
23+
RUN --mount=type=cache,target=/var/cache/apt,sharing=private \
2524
set -eux && \
2625
apt-get update && \
2726
apt-get install -y --no-install-recommends \
@@ -71,8 +70,7 @@ FROM base AS build
7170

7271
ENV SC_BUILD_TARGET=build
7372

74-
RUN --mount=type=cache,target=/var/cache/apt,mode=0755,sharing=private \
75-
--mount=type=cache,target=/var/lib/apt,mode=0755,sharing=private \
73+
RUN --mount=type=cache,target=/var/cache/apt,sharing=private \
7674
set -eux \
7775
&& apt-get update \
7876
&& apt-get install -y --no-install-recommends \

services/api-server/Dockerfile

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ LABEL maintainer=pcrespov
1919
# for docker apt caching to work this needs to be added: [https://vsupalov.com/buildkit-cache-mount-dockerfile/]
2020
RUN rm -f /etc/apt/apt.conf.d/docker-clean && \
2121
echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' > /etc/apt/apt.conf.d/keep-cache
22-
RUN --mount=type=cache,target=/var/cache/apt,mode=0755,sharing=private \
23-
--mount=type=cache,target=/var/lib/apt,mode=0755,sharing=private \
22+
RUN --mount=type=cache,target=/var/cache/apt,sharing=private \
2423
set -eux && \
2524
apt-get update && \
2625
apt-get install -y --no-install-recommends \
2726
gosu \
2827
&& apt-get clean -y \
28+
&& rm -rf /var/lib/apt/lists/* \
2929
# verify that the binary works
3030
&& gosu nobody true
3131

@@ -67,8 +67,7 @@ FROM base AS build
6767

6868
ENV SC_BUILD_TARGET=build
6969

70-
RUN --mount=type=cache,target=/var/cache/apt,mode=0755,sharing=private \
71-
--mount=type=cache,target=/var/lib/apt,mode=0755,sharing=private \
70+
RUN --mount=type=cache,target=/var/cache/apt,sharing=private \
7271
set -eux \
7372
&& apt-get update \
7473
&& apt-get install -y --no-install-recommends \

services/autoscaling/Dockerfile

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ ENV DOCKER_APT_VERSION="5:26.1.4-1~debian.12~bookworm"
2323
# for docker apt caching to work this needs to be added: [https://vsupalov.com/buildkit-cache-mount-dockerfile/]
2424
RUN rm -f /etc/apt/apt.conf.d/docker-clean && \
2525
echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' > /etc/apt/apt.conf.d/keep-cache
26-
RUN --mount=type=cache,target=/var/cache/apt,mode=0755,sharing=private \
27-
--mount=type=cache,target=/var/lib/apt,mode=0755,sharing=private \
26+
RUN --mount=type=cache,target=/var/cache/apt,sharing=private \
2827
set -eux; \
2928
apt-get update; \
3029
apt-get install -y --no-install-recommends \
@@ -87,8 +86,7 @@ FROM base AS build
8786

8887
ENV SC_BUILD_TARGET=build
8988

90-
RUN --mount=type=cache,target=/var/cache/apt,mode=0755,sharing=private \
91-
--mount=type=cache,target=/var/lib/apt,mode=0755,sharing=private \
89+
RUN --mount=type=cache,target=/var/cache/apt,sharing=private \
9290
set -eux \
9391
&& apt-get update \
9492
&& apt-get install -y --no-install-recommends \

services/catalog/Dockerfile

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ LABEL maintainer=pcrespov
2020
# for docker apt caching to work this needs to be added: [https://vsupalov.com/buildkit-cache-mount-dockerfile/]
2121
RUN rm -f /etc/apt/apt.conf.d/docker-clean && \
2222
echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' > /etc/apt/apt.conf.d/keep-cache
23-
RUN --mount=type=cache,target=/var/cache/apt,mode=0755,sharing=private \
24-
--mount=type=cache,target=/var/lib/apt,mode=0755,sharing=private \
23+
RUN --mount=type=cache,target=/var/cache/apt,sharing=private \
2524
set -eux && \
2625
apt-get update && \
2726
apt-get install -y --no-install-recommends \
2827
gosu \
2928
&& apt-get clean -y \
29+
&& rm -rf /var/lib/apt/lists/* \
3030
# verify that the binary works
3131
&& gosu nobody true
3232

@@ -68,8 +68,7 @@ FROM base AS build
6868

6969
ENV SC_BUILD_TARGET=build
7070

71-
RUN --mount=type=cache,target=/var/cache/apt,mode=0755,sharing=private \
72-
--mount=type=cache,target=/var/lib/apt,mode=0755,sharing=private \
71+
RUN --mount=type=cache,target=/var/cache/apt,sharing=private \
7372
set -eux \
7473
&& apt-get update \
7574
&& apt-get install -y --no-install-recommends \

services/clusters-keeper/Dockerfile

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ ENV DOCKER_APT_VERSION="5:26.1.4-1~debian.12~bookworm"
2323
# for docker apt caching to work this needs to be added: [https://vsupalov.com/buildkit-cache-mount-dockerfile/]
2424
RUN rm -f /etc/apt/apt.conf.d/docker-clean && \
2525
echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' > /etc/apt/apt.conf.d/keep-cache
26-
RUN --mount=type=cache,target=/var/cache/apt,mode=0755,sharing=private \
27-
--mount=type=cache,target=/var/lib/apt,mode=0755,sharing=private \
26+
RUN --mount=type=cache,target=/var/cache/apt,sharing=private \
2827
set -eux; \
2928
apt-get update; \
3029
apt-get install -y --no-install-recommends \
@@ -87,8 +86,7 @@ FROM base AS build
8786

8887
ENV SC_BUILD_TARGET=build
8988

90-
RUN --mount=type=cache,target=/var/cache/apt,mode=0755,sharing=private \
91-
--mount=type=cache,target=/var/lib/apt,mode=0755,sharing=private \
89+
RUN --mount=type=cache,target=/var/cache/apt,sharing=private \
9290
set -eux \
9391
&& apt-get update \
9492
&& apt-get install -y --no-install-recommends \

0 commit comments

Comments
 (0)