[SOLVED] Local compile with Docker

I’ve been looking at the https://github.com/spark/particle-dev-local-compiler project and it’s use of Docker to get local compiles working for Atom/ParticleDev.

I’m fairly familiar with docker and docker-machine so I don’t really need help trying to figure out what https://github.com/spark/particle-dev-local-compiler/blob/master/lib/docker-manager.coffee does.

But I’m having a hard time figuring out what “compile:” in https://github.com/spark/particle-dev-local-compiler/blob/master/lib/main.coffee is actually doing.

I’m curious if there are any instructions anywhere on just doing command line builds using the same Docker images that are used for the particle-dev-local-compiler?

It’s running a series of stuff here: https://github.com/spark/buildpack-hal/tree/master/hooks

I have the commands to run the Docker image and do a compile directly but you will have to give me till the weekend to retrieve the script. It’s in the linux box running at home that i have no access to right now :smiley:

Basically a set of env var needs to be passed along to tell the image where the source files are and where to dump the output, the device to compile against etc.

ok. thanks. i’ll check back later.

I think it’s something like:

 docker run --rm \
  -v $PROJECT_DIR:/input \
  -v $PROJECT_DIR:/output \

Be sure to export VERSION=v0.4.7

1 Like


From a Mac (meaning including docker-machine) here’s the shortest path to a local build:

docker-machine create --driver=virtualbox default
eval "$(docker-machine env default)"
docker pull particle/buildpack-particle-firmware:v0.4.7
docker run -v `pwd`:/input -v `pwd`:/output -e PLATFORM_ID=6 particle/buildpack-particle-firmware:v0.4.7

(The above, on the Mac, assumes your projects are under your user home directory /Users/[username]/somewhere because your user home directory is mounted automatically by docker-machine to the same name. That is how/why the pwd in the above docker run command works.)

Assuming this is run from a directory containing your .ino file (I’m just building blink.ino for this test) this should result in 3 bin files and 4 logs files:


The firmware.bin can then be flashed to the device (assuming your device is already on system 0.4.7):

particle flash --usb firmware.bin

Subsequent build just need the docker run command and particle flash. It is helpful to move the build artifacts to a subdirectory:

mkdir target
docker run -v `pwd`:/input -v `pwd`/target:/output -e PLATFORM_ID=6 particle/buildpack-particle-firmware:v0.4.7
particle flash --usb target/firmware.bin

This is great to be able to do this all locally now, it is so much faster than the cloud build.

Thanks for your help.