FBAD
FBAD is a commandline tool for projects requiring multiple docker images.
Features
- easily build projects with multiple docker images
- build on remote server
- automatically push build images to registry
- select a subset of images to build
- build images in parallel on multiple buildservers
- you can also build all images on each buildserver (useful for different os architectures)
- run command before each image build (useful for generating dockerfiles before the build)
- automatically format tags (e.g.
myproject-{arch}
->myproject-x86
) - show build output live
- ...
Recommended directory structure
myproject/
imagea/
DOCKERFILE
...
imageb/
DOCKERFILE
...
...
project.py
project.py
Example """example fbad build file"""
from fbad import Project, Image
# the project contains all project and image data
project = Project(
# name of the project
name="Project",
# list of images of the project
images=[
# most simple form
# build the dockerfile in 'cachserver/'
# use 'cachserver/Dockerfile' as dockerfile
# build cwd is 'cachserver/'
# name and tag are 'cachserver'
Image(
path="cacheserver/",
),
# build image from the directory which contains 'project.py'
# everything like above, but cwd is different
# this is useful if you have shared files, like a package for common functionality
# please note that all files being contained in the buildpath will be send to the buildserver.
Image(
path="webserver/",
buildpath="",
),
# build image with auto-formated tag and auto-generated dockerfile
# the tag will be formated on the buildserver (e.g. 'worker-x86')
# the dockerfile will also be generated on the buildserver
# this is useful for building architecture specific images or
# images with architecture-specific dependencies
# this example also uses a custom buildpath
Image(
path="worker/",
tag="worker-{arch}",
buildpath="",
preexec_command=["/usr/bin/python", "worker/generate_dockerfile.py"],
),
# build image with a dockerfile having a different name.
# dockerfile will be 'db/dbdockerfile.txt'
Image(
path="db/",
dockerfile="dbdockerfile.txt",
),
],
)
if __name__ == "__main__":
# run the cli
project.main()
Buildserver
A buildserver is available using the fbad-server
command.
You can also access import the buildserver as fbad.server.FBADServerFactory
.
If no custom buildserver is specified when building a project, another buildserver is temporarly started.
Installation
Requirements FBAD requires python2 (most implementations should work) and twisted. The buildserver also requires docker to be installed.
Install via pip
pip install fbad
- Done
Install from source
git clone https://github.com/bennr01/fbad.git
cd fbad
-
python setup.py install
(sudo
may be required, depending on your python configuration) - Done.