From b4a85d729496ec581b108d2636d257dc086a2196 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89rico=20Nogueira?= Date: Wed, 4 Dec 2024 16:53:20 -0300 Subject: [PATCH 1/4] base: use flag as default value for JOBS. This way, it isn't necessary to pass the JOBS variable to speed up the build when it is okay to use all machine resources (indicated by JOBS=-1). --- base/docker-compose.yml | 2 +- base/install-functions.sh | 5 +++++ base/musl/docker-compose.yml | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/base/docker-compose.yml b/base/docker-compose.yml index c387099..ef8c1e9 100644 --- a/base/docker-compose.yml +++ b/base/docker-compose.yml @@ -9,5 +9,5 @@ services: org.opencontainers.image.source: ${SOURCE:-https://github.com/cnpem/epics-in-docker} org.opencontainers.image.description: "EPICS base and modules build image" args: - JOBS: ${JOBS:-1} + JOBS: ${JOBS:--1} DEBIAN_VERSION: 11.9 diff --git a/base/install-functions.sh b/base/install-functions.sh index 4d5855a..b8b23b8 100644 --- a/base/install-functions.sh +++ b/base/install-functions.sh @@ -1,3 +1,8 @@ +if [ "$JOBS" -eq "-1" ]; then + JOBS=$(nproc) + echo "Setting JOBS to $JOBS" >&2 +fi + get_module_path() { for module in $@; do if [ -n "$module" ]; then diff --git a/base/musl/docker-compose.yml b/base/musl/docker-compose.yml index 085e22c..240eb95 100644 --- a/base/musl/docker-compose.yml +++ b/base/musl/docker-compose.yml @@ -9,5 +9,5 @@ services: org.opencontainers.image.source: ${SOURCE:-https://github.com/cnpem/epics-in-docker} org.opencontainers.image.description: "EPICS base and modules build image for fully static executables" args: - JOBS: ${JOBS:-1} + JOBS: ${JOBS:--1} ALPINE_VERSION: 3.20.3 From 6875165b30fe585a224d2c3c83900f9c1a839a8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89rico=20Nogueira?= Date: Wed, 4 Dec 2024 17:31:18 -0300 Subject: [PATCH 2/4] images: use unique service names. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is necessary for the docker buildx bake action to píck up all of them. --- images/docker-compose-mca.yml | 2 +- images/docker-compose-motorpigcs2.yml | 2 +- images/docker-compose-opcua.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/images/docker-compose-mca.yml b/images/docker-compose-mca.yml index a4fe1d5..66f3c48 100644 --- a/images/docker-compose-mca.yml +++ b/images/docker-compose-mca.yml @@ -1,5 +1,5 @@ services: - ioc: + mca: image: ghcr.io/cnpem/mca-epics-ioc:$TAG build: context: ./ diff --git a/images/docker-compose-motorpigcs2.yml b/images/docker-compose-motorpigcs2.yml index a8cfc19..26011df 100644 --- a/images/docker-compose-motorpigcs2.yml +++ b/images/docker-compose-motorpigcs2.yml @@ -1,5 +1,5 @@ services: - ioc: + motor-pigcs2: image: ghcr.io/cnpem/motor-pigcs2-epics-ioc:$TAG build: context: ./ diff --git a/images/docker-compose-opcua.yml b/images/docker-compose-opcua.yml index b7322c9..3ea3aef 100644 --- a/images/docker-compose-opcua.yml +++ b/images/docker-compose-opcua.yml @@ -1,5 +1,5 @@ services: - ioc: + opcua: image: ghcr.io/cnpem/opcua-epics-ioc:$TAG build: context: ./ From 5b6dcca9a0d5d7c8e5350c398a974551023e36d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89rico=20Nogueira?= Date: Wed, 4 Dec 2024 17:35:14 -0300 Subject: [PATCH 3/4] ci: update bake-action to v5. --- .github/workflows/base-image.yml | 2 +- .github/workflows/ioc-images.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/base-image.yml b/.github/workflows/base-image.yml index f082c66..acf6de1 100644 --- a/.github/workflows/base-image.yml +++ b/.github/workflows/base-image.yml @@ -35,7 +35,7 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - name: Build and push tagged image - uses: docker/bake-action@v4 + uses: docker/bake-action@v5 with: workdir: ${{ matrix.image.dir }} files: docker-compose.yml diff --git a/.github/workflows/ioc-images.yml b/.github/workflows/ioc-images.yml index 1dd3a74..880ca78 100644 --- a/.github/workflows/ioc-images.yml +++ b/.github/workflows/ioc-images.yml @@ -25,7 +25,7 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - name: Build and push tagged image - uses: docker/bake-action@v4 + uses: docker/bake-action@v5 with: workdir: ./ files: docker-compose.yml From d3756d9ee49f0bd9f5f725c244249c70ffcf24d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89rico=20Nogueira?= Date: Wed, 4 Dec 2024 11:24:01 -0300 Subject: [PATCH 4/4] ci: fix building included images. The included-images workflow was never triggered, probably due to workflow_run only really working on branches. In order to simplify things, we move the step of building those images to the same workflow as the base images. With the help of an additional step, this also allows us to build the IOC images for PRs. It was also necessary to add a conditional for building the included images, since they only use the Debian base image, not the Alpine one. In order to use the just-built base image, it was necessary to build it with "load: true". And, in order to enable the included image builds to locate the base image at all, it was necessary to set up a new builder, with "driver: docker" [1]. The "docker" driver doesn't support caching, so it's reserved for the included images. [1] https://github.com/docker/buildx/issues/159#issuecomment-539238262 --- .github/workflows/base-image.yml | 20 +++++++++++++++ .github/workflows/included-images.yml | 36 --------------------------- 2 files changed, 20 insertions(+), 36 deletions(-) delete mode 100644 .github/workflows/included-images.yml diff --git a/.github/workflows/base-image.yml b/.github/workflows/base-image.yml index acf6de1..e94a2f2 100644 --- a/.github/workflows/base-image.yml +++ b/.github/workflows/base-image.yml @@ -39,7 +39,27 @@ jobs: with: workdir: ${{ matrix.image.dir }} files: docker-compose.yml + load: true set: | *.cache-from=type=gha,scope=${{ matrix.image.name }} *.cache-to=type=gha,mode=max,scope=${{ matrix.image.name }} push: ${{ github.event_name == 'push' && vars.PUSH_TO_REGISTRY == 'true' && github.ref_type == 'tag' }} + - name: Point IOC Dockerfile to image that was just built + run: sed -i "s/v.*-dev/$TAG/" Dockerfile + - name: Configure builder using docker driver + uses: docker/setup-buildx-action@v3 + id: dockerbuilder + with: + driver: docker + - name: Build and push included IOC images + if: ${{ matrix.image.name == 'lnls-debian-11-epics-7' }} + uses: docker/bake-action@v5 + with: + workdir: images/ + builder: ${{ steps.dockerbuilder.outputs.name }} + allow: fs.read=../Dockerfile + files: | + docker-compose-opcua.yml + docker-compose-motorpigcs2.yml + docker-compose-mca.yml + push: ${{ github.event_name == 'push' && vars.PUSH_TO_REGISTRY == 'true' && github.ref_type == 'tag' }} diff --git a/.github/workflows/included-images.yml b/.github/workflows/included-images.yml deleted file mode 100644 index 952d566..0000000 --- a/.github/workflows/included-images.yml +++ /dev/null @@ -1,36 +0,0 @@ -name: Build included image -on: - workflow_run: - workflows: ["build_and_push (base, lnls-debian-11-epics-7)"] - tags: - - 'v*' - types: - - completed - -jobs: - build_and_push: - runs-on: ubuntu-latest - permissions: - packages: write - contents: read - env: - REGISTRY: ghcr.io/${{ github.repository_owner }} - TAG: ${{ github.ref_name }} - steps: - - uses: actions/checkout@v4 - - uses: docker/setup-buildx-action@v3 - - name: Log in to registry - uses: docker/login-action@v3 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - name: Build and push tagged image - uses: docker/bake-action@v4 - with: - workdir: images/ - files: | - docker-compose-opcua.yml - docker-compose-motorpigcs2.yml - docker-compose-mca.yml - push: true