Buildpacks inherit and extend other images to separate common flow and logic in OOP manner. This image provides main flow/protocol and some helper functions that can be used by other images by inheriting it.
Particle firmware |
HAL / Legacy |
Base (you are here) |
$ docker-compose build
Image entrypoint is /bin/run. It will:
- Load helper functions from lib directory
- Init environment variables with defaults
- Setup logging
- Copy input files to workspace directory
- Execute build (by calling
/bin/build
script) - Cleanup output
FROM particle/buildpack-base
# ...
COPY foo /foo
When running container use -v
argument to specify local dirs which will be mapped to those volumes.
/input
- should contain all project files/output
- after build will contain logs and build artifacts/cache
- temp directory to store intermediate files/log
- directory containing run logs/ssh
- directory containing SSH keys (will be copied to~/.ssh
)
Outputed firmware binary should be named firmware.bin
unless compile produces more binaries and their filenames have to be preserved.
stderr
file paths should start with $WORKSPACE_DIR/
(this should be the root of a project).
find-and-replace-in
function can be used to replace whatever root dir is.
Will clone REPO_URL
to CLONE_DIR
if it doesn't exist.
REPO_URL
can target tags or branches by using hash notation i.e.: https://github.com/particle-iot/core-common-lib.git#compile-server2
If FROM
file exists copy it to TO
.
Copy all files matching GLOB
to output dir.
Replaces all occurrences of FROM
to TO
in FILE
.
Logs arm-none-eabi-size
of ELF_FILE
to memory-use.log
file in output dir.
Setting it to true
will wait on STDIN
for a tar gzipped file which will be extracted into /input
.
Setting it to true
will tar gzip /output
directory into /output.tar.gz
archive inside of container.
Both variables are used when buildpack is run by Dray.
Buildpacks can define tests by overriding /test
directory with BATS tests. The tests should:
- Propagate
/input
with test data - Run
/bin/run
- Inspect
/output
and assert when incorrect
Before each BATS file, the /input
, /workspace
and /output
will be cleared.
BATS can use different languages to do the actual tests (i.e. run mocha
).
Running tests itself is done by running container without mounted volumes and overriding CMD
:
$ docker run --rm \
particle/buildpack-foo \
/bin/run-tests
Use following .travis.yml
:
sudo: required
services:
- docker
install:
- docker login --email=$DOCKER_HUB_EMAIL --username=$DOCKER_HUB_USERNAME --password=$DOCKER_HUB_PASSWORD
before_script:
- docker build -t $DOCKER_IMAGE_NAME .
script:
- docker run --rm $DOCKER_IMAGE_NAME /bin/run-tests
after_success:
- if [ ! -z "$TRAVIS_TAG" ]; then docker tag $DOCKER_IMAGE_NAME:latest $DOCKER_IMAGE_NAME:$TRAVIS_TAG; fi && docker push $DOCKER_IMAGE_NAME
env:
- DOCKER_IMAGE_NAME=particle/foo