One non-conventional use of Juju is something I cooked up a while ago when traveling, a Juju charm that compiles
. This charm can be used to compile
on a powerful instance in your cloud rather than on your puny laptop without having to worry about finding all the various dependencies that a modern
To get started using the
charm, checkout my
repository from GitHub.
% cd $HOME % git clone https://github.com/davecheney/charms
Each Juju service (an instance of a charm) needs to be deployed into a running environment. I’ve bootstrapped an environment on Amazon AWS as they have a nice 8 core machine which will get the job done quickly.
% juju bootstrap -e ap-southeast-2
The next step is to deploy an instance of the
charm from my local charm repository. By default Juju requests the equivalent of an
so we use a deploy time constraint to request a machine with a larger number of cores. The
charm automatically adjusts itself to use all CPUs on the target machine.
% juju deploy --constraints "cpu-cores=8" --repository $HOME/charms \ local:raring/gccgo
All the magic of the build phase takes place in the
hook, so the build will stay at
until the build completes (or fails).
% juju status gccgo environment: ap-southeast-2 machines: "1": agent-state: started agent-version: 220.127.116.11 dns-name: ec2-54-253-4-102.ap-southeast-2.compute.amazonaws.com instance-id: i-22c92a1e instance-state: running series: raring hardware: arch=amd64 cpu-cores=8 cpu-power=2000 mem=7168M root-disk=8192M services: gccgo: charm: local:raring/gccgo-12 exposed: false units: gccgo/0: agent-state: installed agent-version: 18.104.22.168 machine: "1" public-address: ec2-54-253-4-102.ap-southeast-2.compute.amazonaws.com
You can also monitor the output of the build process itself using the
charm has a number of configuration variables you can use to tweak the build process if necessary. The
charm produces a tarball as its final result once the service moves to
% juju get gccgo charm: gccgo service: gccgo settings: prefix: default: true description: gccgo build prefix type: string value: /opt/gccgo tarfile: default: true description: gccgo final tarball type: string value: /home/ubuntu/gccgo.tar.bz2 work: default: true description: gccgo build directory type: string value: /home/ubuntu/work
Now we know the location of the tarball, we can use the
command to fetch it.
juju scp gccgo/0:/home/ubuntu/gccgo.tar.bz2 /tmp
8 core virtual machines don’t come cheap, don’t forget to destroy this environment (or at least destroy the service and remove the machine) once you’re done.
# destroy service and remove build machine % juju destroy-service gccgo % juju destroy-machine 1 # from the output of juju status above # or destroy the environment % juju destroy-environment -y