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 |
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
$ scripts/build-deviceos
$ 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
When doing a Travis CI job following scripts should be executed in order:
scripts/ci
which will:- Build DeviceOS source image
particle/device-os:$TAG
, excluding anything unnecessary using the.dockerignore
in DeviceOS sources - Build base image
$DOCKER_IMAGE_NAME:$REF-$BUILDPACK_VERSION-$BUILDPACK_VARIATION
adding scripts frombin
folder to the base buildpack containing the toolchain (usuallybuildpack-hal
) - Build main image
$DOCKER_IMAGE_NAME:$TAG-$REF-$BUILDPACK_VERSION-$BUILDPACK_VARIATION
adding DeviceOS sources from$FIRMWARE_PATH
- 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 - Run
/bin/run-tests
inside the container created from test image - (Optional, only if Travis is responsible for pushing prebuilt platform images to Docker Hub)
scripts/push-image
, which will: - Push main image to Docker Hub
- Create prebuild platform images for each platform specified in
.buildpackrc
RELEASE_PLATFORMS
andPRERELEASE_PLATFORMS
(deprecated) - Push platform images to Docker Hub
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:
- Add a task to run
scripts/generate-args-tags
and collect all the generated files - Pass build argument files and necessary tag files to subsequent stages when building buildpack containers
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
.