Building a Docker image to run Metabrik… from Metabrik

Tweet about this on TwitterDigg thisShare on RedditShare on Google+Share on FacebookEmail this to someoneShare on LinkedIn

Today, we will show how we can use the system::docker Brik to build a Metabrik Docker image. Of course, you have to have installed Metabrik first, but it is as easy as following the online guide. Alternatively, you can use the publicly available Docker image, which is quite an inception concept.

Installing the Docker image from the hub

Installing Docker is also simple. Run the following command as a standard user:

wget -qO- https://get.docker.com/ | sh

Then, you may fetch the Metabrik Docker image and run it:

docker pull metabrik/metabrik
docker run -it metabrik/metabrik

And building your own image from your system

You may also start from a fresh Metabrik installation. If you want to customize your very own Docker image, you can download the Dockerfile from the trac server. Once you have it, put it in its own directory and start Metabrik.

$ mkdir ~/docker-metabrik
$ mv ~/Downloads/Dockerfile ~/docker-metabrik/
$ metabrik.sh
messiah:~>

Once Metabrik is running, you have to use the system::docker Brik and change to the docker directory.

messiah:~> cd ~/docker-metabrik
messiah:~/docker-metabrik> use system::docker
[-] system::docker: brik_check_require_binaries: binary [wget] not found in PATH
[-] system::docker: brik_preinit: brik_checks failed
[-] core::context: call: use: unable to use Brik [system::docker]

But you got an error, cause some dependencies are not available yet. No worries, there is a dependencies handling feature in Metabrik for every Brik. Load the brik::tool Brik and install the system::docker one like:

messiah:~/docker-metabrik> use brik::tool 
[-] core::context: call: use: Brik [brik::tool] already used
messiah:~/docker-metabrik> run brik::tool install $USE
[..]
messiah:~/docker-metabrik> use system::docker
messiah:~/docker-metabrik> run system::docker install
[!] system::docker: brik_init: you have to execute install Command now
apparmor is enabled in the kernel, but apparmor_parser missing
+ sh -c sleep 3; apt-get update
[..]

Ready to build the Docker image

Everything is set-up, we can start building.

get system::docker
set system::docker username $username
set system::docker password $password
set system::docker email $email
run system::docker login

run system::docker get_image_id metabrik
run system::docker delete $RUN # Delete previous latest tag
run system::docker build metabrik .
run system::docker tag $RUN metabrik/metabrik:latest

run system::docker push metabrik/metabrik:latest

Automating it from a Metascript

If you have to repeat this task, you will of course want to write a script. And you can do it as a Metascript. Create a file called build-metabrik-docker-image.meta containing:

use system::file
use system::docker

my $email = 'EMAIL'
my $username = 'USERNAME'
my $password = 'PASSWORD'

set system::docker email $email
set system::docker username $username
set system::docker password $password
run system::docker login
if ($ERR) { exit 0; }

get core::global homedir
my $dir = $GET."/metabrik-docker/"
run system::file mkdir $dir
get core::global repository
my $file = $GET."/../Dockerfile"
run system::file copy $file $dir

run system::docker get_image_id metabrik
run system::docker delete $RUN # Delete previous latest tag
run system::docker build metabrik $dir
run system::docker tag metabrik metabrik/metabrik:latest

run system::docker push metabrik/metabrik:latest

exit 1

And run it:

metabrik --script metabrik-docker-image.meta

 

Tweet about this on TwitterDigg thisShare on RedditShare on Google+Share on FacebookEmail this to someoneShare on LinkedIn

Leave a Reply

Your email address will not be published. Required fields are marked *