diff --git a/.github/workflows/sensor-raspi-build-docker-wrap-push-ghcr.yml b/.github/workflows/sensor-raspi-build-docker-wrap-push-ghcr.yml new file mode 100644 index 000000000..f9e8f2f80 --- /dev/null +++ b/.github/workflows/sensor-raspi-build-docker-wrap-push-ghcr.yml @@ -0,0 +1,97 @@ +name: sensor-raspi-build-docker-wrap-push-ghcr + +on: + push: + branches: + - main + - development + paths: + - 'sensor-raspi/**' + - '.github/workflows/sensor-raspi-build-docker-wrap-push-ghcr.yml' + workflow_dispatch: + repository_dispatch: + +jobs: + build: + runs-on: ubuntu-22.04 + permissions: + actions: write + packages: write + contents: read + security-events: write + defaults: + run: + shell: bash + steps: + - + name: Cancel previous run in progress + uses: styfle/cancel-workflow-action@0.12.0 + with: + ignore_sha: true + all_but_latest: true + access_token: ${{ secrets.GITHUB_TOKEN }} + - + name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - + name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + with: + driver-opts: | + image=moby/buildkit:master + - + name: Build environment setup + run: | + sudo apt-get -q update + sudo env DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y -q \ + binfmt-support \ + bmap-tools \ + ca-certificates \ + debootstrap \ + dosfstools \ + kpartx \ + python3 \ + qemu-user-static \ + qemu-utils \ + time \ + vmdb2 \ + zerofree + - + name: Checkout + uses: actions/checkout@v4 + - + name: Extract branch name + shell: bash + run: echo "branch=$(echo ${GITHUB_REF#refs/heads/})" >> $GITHUB_OUTPUT + id: extract_branch + - + name: Extract commit SHA + shell: bash + run: echo "sha=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT + id: extract_commit_sha + - + name: Extract Malcolm version + shell: bash + run: echo "mversion=$(grep -P "^\s+image:.*/malcolm/" docker-compose.yml | awk '{print $2}' | cut -d':' -f2 | uniq -c | sort -nr | awk '{print $2}' | head -n 1)" >> $GITHUB_OUTPUT + id: extract_malcolm_version + - + name: Build image + run: | + pushd ./sensor-raspi + sudo make raspi_4_bookworm.img + sudo chmod 644 ./raspi_4_bookworm*.* + popd + - + name: ghcr.io login + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + - + name: Build and push IMG image + uses: docker/build-push-action@v5 + with: + context: ./sensor-raspi + push: true + tags: ghcr.io/${{ github.repository_owner }}/malcolm/hedgehog-raspi:${{ steps.extract_branch.outputs.branch }} diff --git a/sensor-raspi/Dockerfile b/sensor-raspi/Dockerfile new file mode 100644 index 000000000..000d726c5 --- /dev/null +++ b/sensor-raspi/Dockerfile @@ -0,0 +1,20 @@ +FROM ghcr.io/mmguero/qemu-live-iso:latest + +# Copyright (c) 2024 Battelle Energy Alliance, LLC. All rights reserved. + +LABEL maintainer="malcolm@inl.gov" +LABEL org.opencontainers.image.authors='malcolm@inl.gov' +LABEL org.opencontainers.image.url='https://github.com/idaholab/Malcolm' +LABEL org.opencontainers.image.documentation='https://github.com/idaholab/Malcolm/blob/main/sensor-iso/README.md' +LABEL org.opencontainers.image.source='https://github.com/idaholab/Malcolm' +LABEL org.opencontainers.image.vendor='Idaho National Laboratory' +LABEL org.opencontainers.image.title='ghcr.io/idaholab/malcolm/hedgehog-raspi' +LABEL org.opencontainers.image.description='Hedgehog Linux network sensor Raspberry Pi image wrapped in a Docker image' + +ARG QEMU_CPU=4 +ARG QEMU_RAM=4096 +ENV QEMU_CPU $QEMU_CPU +ENV QEMU_RAM $QEMU_RAM + +ADD --chown=${DEFAULT_UID}:${DEFAULT_GID} https://raw.githubusercontent.com/idaholab/Malcolm/main/docs/images/hedgehog/logo/favicon.ico /image/favicon.ico +ADD --chown=${DEFAULT_UID}:${DEFAULT_GID} raspi_4_bookworm*.* /image/