From e92a760073809f1dc009a780c8442220f10e3498 Mon Sep 17 00:00:00 2001 From: robotrapta <79607467+robotrapta@users.noreply.github.com> Date: Sat, 9 Dec 2023 08:00:41 -0800 Subject: [PATCH] Builds images for releases (#6) * Updating readme with forward-looking build instructions. * Renaming "glmns" to "gl" and "groundlight" * First crack at GHA to build images and make releases. * Only store artifacts for releases. * Fixing problems found in PR --- .github/workflows/build-images.yaml | 79 ++++++++++++++++++++++++++ GL-README.md | 27 +++++---- dobuild.sh | 4 +- glmns-config => gl-config | 4 +- glmns-config-prod => gl-config-release | 5 +- 5 files changed, 104 insertions(+), 15 deletions(-) create mode 100644 .github/workflows/build-images.yaml rename glmns-config => gl-config (93%) rename glmns-config-prod => gl-config-release (88%) diff --git a/.github/workflows/build-images.yaml b/.github/workflows/build-images.yaml new file mode 100644 index 0000000..dfc4b73 --- /dev/null +++ b/.github/workflows/build-images.yaml @@ -0,0 +1,79 @@ +name: build-images + +on: + push: + branches: [ main ] + tags: + - '*' + pull_request: + # all branches for now while we're testing. + #branches: [ main ] + +jobs: + build: + runs-on: ubuntu-22.04 + + steps: + - uses: actions/checkout@v4 + + - name: install needed packages + run: | + sudo apt update + sudo apt install binfmt-support + sudo apt install qemu qemu-user-static + sudo update-binfmts --enable + + - name: Detect if release + run: | + if [[ $GITHUB_REF == refs/tags/* ]]; then + echo "IS_RELEASE=1" >> $GITHUB_ENV + else + echo "IS_RELEASE=0" >> $GITHUB_ENV + fi + + # Build image with docker + - name: Build the full images + run: | + if [[ ${IS_RELEASE} == "1" ]]; then + # Do a release build. + ./build-docker.sh -c gl-config-release + else + # faster test build. + ./build-docker.sh -c gl-config + fi + + # Print output directory files + - name: List output files + run: ls -lh deploy + + - name: Upload built image + if: env.IS_RELEASE == '1' + uses: actions/upload-artifact@v3 + with: + name: rpios-image + path: ./deploy/image_*.img.xz + if-no-files-found: error + + - name: Upload debug artifacts + if: env.IS_RELEASE == '1' + uses: actions/upload-artifact@v3 + with: + name: debug-files + path: | + ./deploy/*.info + ./deploy/build.log + if-no-files-found: error + + release: + if: startsWith(github.ref, 'refs/tags/') + needs: [build] + runs-on: ubuntu-22.04 + steps: + - uses: actions/download-artifact@v3 + with: + name: rpios-image + - uses: softprops/action-gh-release@v1 + with: + files: '**/*' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/GL-README.md b/GL-README.md index b8ff680..da893c7 100644 --- a/GL-README.md +++ b/GL-README.md @@ -1,20 +1,27 @@ -# Groundlight' Monitoring Notification Server (MNS) as a Raspberry Pi Appliance +# Groundlight Pi-Gen: OS images for Raspberry PI with Groundlight Tools -This repo builds the OS image for a Groundlight MNS appliance running on Raspberry Pi hardware. +This repo builds OS images for Groundlight tools and applications, including the bare python SDK, +and the Monitoring Notification Server (MNS). The OS images are available in the [releases](https://github.com/groundlight/groundlight-pi-gen/releases) and can be installed with [Raspberry Pi imager](https://www.raspberrypi.com/software/). -Use this repo to build the `.img` file which gets burned to an SD card. When that SD card is booted on the Raspberry Pi, -it runs the [Groundlight Monitoring Notification Server](https://github.com/groundlight/monitoring-notification-server). -The MNS provides a simple GUI to configure a Groundlight detector, grab images from it, and send notifications when -appropriate. +There are several different images available, depending on your needs, from smallest to largest: -This build system is based on [pi-gen](https://github.com/RPi-Distro/pi-gen). Refer to its [original README](/README.md) for how everything works. The (`glmns-config`)[glmns-config] file is the key source of control. (What is called "config" in the original.) -Also note that we're tracking the `arm64` branch, not main. (If we build off the main branch, we hit [an issue with missing `arm/v8` docker images](https://github.com/groundlight/monitoring-notification-server/issues/39) and likely others, because we make these funky machines with a 64-bit kernel, but 32-bit applications.) +- **`sdk`** - A minimal image with just the Python SDK installed. This is the smallest image, and is suitable for running the SDK on a Raspberry Pi Zero W. It is also suitable for running the SDK on a Raspberry Pi 3 or 4, if you don't need the GUI. +- **`mns`** - an image with the [Groundlight Monitoring Notification Server (MNS)](https://github.com/groundlight/monitoring-notification-server) installed for headless use. "Headless" means it runs the server, which serves HTML pages, but has no browser or GUI to use it from. You need to connect from another machine to use MNS. The MNS provides a simple way to configure cameras, Groundlight detectors, and send notifications conditions are met. +- **`full`** - an image with the Groundlight MNS installed, and a desktop GUI with a browser. This is appropriate for a Raspberry Pi which will have a screen attached to it. +- **`edge`** - Not available yet. The Edge Endpoint server is still too resource hungry to run on a Raspberry Pi. Please [leave a comment](https://github.com/groundlight/groundlight-pi-gen/issues/5) if you'd like to use this. + + +## Source Code + +This build system is based on [pi-gen](https://github.com/RPi-Distro/pi-gen). Refer to its [original README](/README.md) for how everything works. The (`gl-config`)[gl-config] file is the key source of control. (What is called "config" in the original.) + +Note that we're tracking the `arm64` branch, not main. (If we build off the main branch, we hit [an issue with missing `arm/v8` docker images](https://github.com/groundlight/monitoring-notification-server/issues/39) and likely others, because we make these funky machines with a 64-bit kernel, but 32-bit applications.) ## Building Images You should really build this on an ARM system (e.g. an m7g instance in ec2). -You _can_ build this on an x86 instance, but it will take ~3x longer, and it's not fast to start with. +You _can_ build this on an x86 instance, but it will take significantly longer, and it's not fast to start with. ### Building directly @@ -48,7 +55,7 @@ To start over try After ~10 minutes, and then look in the `deploy/` for a file with a name like `image_2023-12-06-GroundlightMNS-sdk-qemu.img.xz` which will be ~1GB for now. -(See the `COMPRESSION_LEVEL` setting in (`glmns-config`)[glmns-config] to trade speed vs size.) +(See the `COMPRESSION_LEVEL` setting in (`gl-config`)[gl-config] to trade speed vs size.) Copy this to your laptop, and then you can burn it to an SD card using the [Raspberry Pi Image](https://github.com/raspberrypi/rpi-imager). diff --git a/dobuild.sh b/dobuild.sh index 19da90f..af7c12b 100755 --- a/dobuild.sh +++ b/dobuild.sh @@ -1,7 +1,7 @@ #!/bin/bash # local build - seems like maybe it's leaking system resources sometimes? -# time sudo $@ ./build.sh -c glmns-config +# time sudo $@ ./build.sh -c gl-config # docker build - slower but more reliable. -time PRESERVE_CONTAINER=1 $@ ./build-docker.sh -c glmns-config +time PRESERVE_CONTAINER=1 $@ ./build-docker.sh -c gl-config diff --git a/glmns-config b/gl-config similarity index 93% rename from glmns-config rename to gl-config index 0e32895..ea39537 100644 --- a/glmns-config +++ b/gl-config @@ -1,7 +1,7 @@ # The config file defining the Groundlight MNS image. IMG_NAME='GroundlightMNS' TARGET_HOSTNAME=GroundlightMNS -FIRST_USER_NAME=glmns +FIRST_USER_NAME=groundlight # # core functionality @@ -20,7 +20,7 @@ STAGE_LIST="stage0 stage1 stage2 stage-gl1" # # Options used for development. -# (These get overridden by glmns-config-prod) +# (These get overridden by gl-config-release) # # Makes a qemu-compatible image - for easier testing. diff --git a/glmns-config-prod b/gl-config-release similarity index 88% rename from glmns-config-prod rename to gl-config-release index e47d7aa..682cdab 100644 --- a/glmns-config-prod +++ b/gl-config-release @@ -1,4 +1,7 @@ -source glmns-config +source gl-config + +# Turn off QEMU for release builds +USE_QEMU=0 # Higher compression takes longer, so it's turned down during dev. # We should turn it back up when we're ready to publish.