Skip to content

Commit

Permalink
build[build.yml]: Extend build statges and parallelism
Browse files Browse the repository at this point in the history
  • Loading branch information
sidey79 committed Mar 4, 2024
1 parent 45c5a87 commit 95da28a
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 30 deletions.
48 changes: 45 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,44 @@ jobs:
name: cpanfile-FHEM
path: cpanfile
overwrite: true


base_build:
strategy:
matrix:
dockerfile: [Dockerfile-bullseye]
platform: [arm/v7, amd64, arm64, 386]
runs-on: ubuntu-latest
steps:
- name: Checkout this repository
uses: actions/checkout@v4

- name: Prepare docker for build and publish
id: prepareDOCKER
uses: ./.github/workflows/prepare-docker
with:
DOCKER_HUB_USERNAME: ${{ secrets.DOCKER_HUB_USERNAME }}
DOCKER_HUB_ACCESS_TOKEN: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
GHCR_OWNER: ${{ github.repository_owner }}
GHCR_ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DOCKERFILE: ${{ matrix.dockerfile }}

- name: Build for bats with fhem base layer ${{ matrix.platform }}
uses: docker/build-push-action@v5
with:
context: .
load: true
file: ./${{ matrix.dockerfile }}
platforms: linux/${{ matrix.platform }}
push: false
target: base
cache-from: |
type=gha,scope=base_linux/${{ matrix.platform }}-${{ matrix.dockerfile }}
cache-to: type=gha,mode=max,scope=base_linux/${{ matrix.platform }}-${{ matrix.dockerfile }}
tags: baseonly

test_build:
# The type of runner that the job will run on
needs: get_dependencies
needs: [get_dependencies, base_build]
runs-on: ubuntu-latest
strategy:
matrix:
Expand Down Expand Up @@ -143,7 +177,8 @@ jobs:
push: false
target: with-fhem-bats
cache-from: |
type=gha,scope=full_linux/amd64-${{ matrix.dockerfile }}
type=gha,scope=base_linux/amd64-${{ matrix.dockerfile }}
type=gha,scope=full_linux/amd64-${{ matrix.dockerfile }}
cache-to: type=gha,mode=max,scope=full_linux/amd64-${{ matrix.dockerfile }}
tags: bats-withfhem
labels: ${{ steps.meta.outputs.labels }}
Expand All @@ -170,6 +205,7 @@ jobs:
push: false
target: with-fhem-python-nodejs
cache-from: |
type=gha,scope=base_linux/amd64-${{ matrix.dockerfile }}
type=gha,scope=full_linux/amd64-${{ matrix.dockerfile }}
cache-to: type=gha,mode=max,scope=full_linux/amd64-${{ matrix.dockerfile }}
tags: ${{ steps.meta.outputs.tags }}
Expand Down Expand Up @@ -268,6 +304,9 @@ jobs:
push: ${{ github.event_name != 'pull_request' }}
target: with-fhem-python-nodejs
cache-from: |
type=gha,scope=base_linux/arm64-${{ matrix.dockerfile }}
type=gha,scope=base_linux/amd64-${{ matrix.dockerfile }}
type=gha,scope=base_linux/armv7-${{ matrix.dockerfile }}
type=gha,scope=full_linux/amd64-${{ matrix.dockerfile }}
type=gha,scope=full_linux/cross-${{ matrix.dockerfile }}
cache-to: type=gha,mode=max,scope=full_linux/cross-${{ matrix.dockerfile }}
Expand Down Expand Up @@ -309,6 +348,9 @@ jobs:
push: ${{ github.event_name != 'pull_request' }}
target: with-fhem
cache-from: |
type=gha,scope=base_linux/arm64-${{ matrix.dockerfile }}
type=gha,scope=base_linux/amd64-${{ matrix.dockerfile }}
type=gha,scope=base_linux/armv7-${{ matrix.dockerfile }}
type=gha,scope=full_linux/amd64-${{ matrix.dockerfile }}
type=gha,scope=full_linux/cross-${{ matrix.dockerfile }}
type=gha,scope=base_linux/cross-${{ matrix.dockerfile }}
Expand Down
57 changes: 30 additions & 27 deletions Dockerfile-bullseye
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,35 @@ RUN <<EOF
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* ~/.[^.] ~/.??* ~/*
EOF

# Add extended system layer
RUN <<EOF
LC_ALL=C DEBIAN_FRONTEND=noninteractive apt-get update
LC_ALL=C DEBIAN_FRONTEND=noninteractive apt-get install -qqy --no-install-recommends \
alsa-utils \
dfu-programmer \
espeak \
ffmpeg \
lame \
libnmap-parser-perl \
libttspico-utils \
mp3wrap \
mpg123 \
mplayer \
nmap \
normalize-audio \
snmp \
snmp-mibs-downloader \
sox \
vorbis-tools \
gstreamer1.0-tools \
libsox-fmt-all \
libsodium-dev
LC_ALL=C apt-get autoremove -qqy && LC_ALL=C apt-get clean
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* ~/.[^.] ~/.??* ~/*
EOF


FROM base as base-cpan
# Install all CPAN Modules, needed from FHEM and standard modules
COPY cpanfile /root/cpanfile
# Fixup modules which do not work on all platforms and install afterwards
Expand Down Expand Up @@ -111,37 +140,11 @@ RUN <<EOF
EOF


# Add extended system layer
RUN <<EOF
LC_ALL=C DEBIAN_FRONTEND=noninteractive apt-get update
LC_ALL=C DEBIAN_FRONTEND=noninteractive apt-get install -qqy --no-install-recommends \
alsa-utils \
dfu-programmer \
espeak \
ffmpeg \
lame \
libnmap-parser-perl \
libttspico-utils \
mp3wrap \
mpg123 \
mplayer \
nmap \
normalize-audio \
snmp \
snmp-mibs-downloader \
sox \
vorbis-tools \
gstreamer1.0-tools \
libsox-fmt-all \
libsodium-dev
LC_ALL=C apt-get autoremove -qqy && LC_ALL=C apt-get clean
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* ~/.[^.] ~/.??* ~/*
EOF

#
# Standard FHEM Layer
#
FROM base as with-fhem
FROM base-cpan as with-fhem

# Install base environment, cache is invalidated here, because we set a BUILD_DATE Variable which changes every run.
COPY src/entry.sh src/health-check.sh src/ssh_known_hosts.txt /
Expand Down

0 comments on commit 95da28a

Please sign in to comment.