Skip to content

A set of scripts building `buildpack-particle-firmware` Docker image out of `firmware` repository

Notifications You must be signed in to change notification settings

particle-iot/firmware-buildpack-builder

Repository files navigation

Particle Firmware buildpack scripts

This repo is used by DeviceOS Travis CI build to build, test and push images to Docker Hub.

Particle firmware (you are here)
HAL / Legacy
Base

Running scripts locally when developing a buildpack

First clone and set up this repo:

$ git clone [email protected]:particle-iot/firmware-buildpack-builder.git
$ cd firmware-buildpack-builder
$ export FIRMWARE_PATH=path/to/particle/firmware
$ export DOCKER_IMAGE_NAME=particle/your-firmware-name
$ export TAG=a.b.c-rc.X

Build sanitized DeviceOS source image

$ scripts/build-deviceos

To build a firmware buildpack (containing just toolchain + firmware) run:

$ scripts/build-image

Note: the firmware buildpack inherits BUILDPACK_VARIATION image specified in .buildpackrc file in your firmware. If you need to use different toolchain it is recommended to create a different variation and specify it in the .buildpackrc file.

To build a buildpack with precompiled intermediate files for a platform used by the cloud compiler (same as firmware buildpack + it runs make in all important dirs)

Make sure the platform is in RELEASE_PLATFORMS array in .buildpackrc. Then run:

$ scripts/build-platform-images

Once the images are built you can test them with:

$ export PLATFORM=argon
$ docker run --rm -it -v EXAMPLE_APP_DIRECTORY:/input -e PLATFORM_ID=EXAMPLE_PLATFORM_ID $DOCKER_IMAGE_NAME:$TAG-$PLATFORM

Flow inside Travis CI

When doing a Travis CI job following scripts should be executed in order:

  1. scripts/ci which will:
  2. Build DeviceOS source image particle/device-os:$TAG, excluding anything unnecessary using the .dockerignore in DeviceOS sources
  3. Build base image $DOCKER_IMAGE_NAME:$REF-$BUILDPACK_VERSION-$BUILDPACK_VARIATION adding scripts from bin folder to the base buildpack containing the toolchain (usually buildpack-hal)
  4. Build main image $DOCKER_IMAGE_NAME:$TAG-$REF-$BUILDPACK_VERSION-$BUILDPACK_VARIATION adding DeviceOS sources from $FIRMWARE_PATH
  5. Build test image $DOCKER_IMAGE_NAME:$TAG-$REF-$BUILDPACK_VERSION-$BUILDPACK_VARIATION-test for running unit tests, adding host gcc compiler and other necessary tools
  6. Run /bin/run-tests inside the container created from test image
  7. (Optional, only if Travis is responsible for pushing prebuilt platform images to Docker Hub) scripts/push-image, which will:
  8. Push main image to Docker Hub
  9. Create prebuild platform images for each platform specified in .buildpackrc RELEASE_PLATFORMS and PRERELEASE_PLATFORMS (deprecated)
  10. Push platform images to Docker Hub

Flow inside Concourse

We are no longer building and releasing platform buildpacks for particle-iot/device-os repository on Travis and moved this functionality to Concourse. The rough outline of the flow in Concourse is to:

  1. Add a task to run scripts/generate-args-tags and collect all the generated files
  2. Pass build argument files and necessary tag files to subsequent stages when building buildpack containers

Example .travis.yml file

If you're forking our DeviceOS repository you can build your own images with firmware. To do so, edit .travis.yml file to include:

sudo: required  
services:  
  - docker
install:  
  - echo "$DOCKER_HUB_PASSWORD" | docker login --email=$DOCKER_HUB_EMAIL --username=$DOCKER_HUB_USERNAME --password-stdin
  - wget https://github.com/particle-iot/firmware-buildpack-builder/archive/%VERSION%.tar.gz -O - | tar -xz -C ../ --strip-components 1
script:  
  - ../scripts/ci
after_success: ../scripts/push-image
env:  
  - DOCKER_IMAGE_NAME=username/my-image

Note: remember to change DOCKER_IMAGE_NAME to your image name.

After this add DOCKER_HUB_EMAIL, DOCKER_HUB_USERNAME and DOCKER_HUB_PASSWORD environment variables to Travis CI setting.

Having done all this, Travis should build image every time a change is pushed. It will also push the images to Docker Hub when a git tag is set if git origin is not particle-iot/device-os.

About

A set of scripts building `buildpack-particle-firmware` Docker image out of `firmware` repository

Resources

Stars

Watchers

Forks

Packages

No packages published