Package: ibt
Project- and build-oriented tool for working withDockerimages and containersWhat’s the point of this tool?Docker is great for building isolated environments for builds or
applications. For my tastes, however, there are a few usability issues
associated with it:The commands are fiddly to use and difficult to rememberDocker containers run as root by default resulting in files created
on the host as the root user, instead of the current userIt’s too easy to leave intermediate images and containers lying
aroundNote that this is a very personal list of perceived shortcomings. If
these aren’t issues for you, then don’t use this tool!IBT makes Docker images and containers more development- and
project-focused. It encourages the following workflows:Editing of source files is carried out predominantly on thehostmachineBuilding, running and debugging of targets is always carried out
within the Docker containerSource code will typically be under the control of a VCS such as GitSource files should not be copieden masseinto the containerOutput files from builds etc. should be exposed directly to the hostYou’ll notice that the commands strongly resemble those ofVagrant. This is not completely
accidental. The workflows described above strongly resemble Vagrant
workflows whereup,destroy,runcorrespond closely toup,destroyandssh.InstallationEnsure you have a workingPython
2.7installation:pipinstall--useribtYou can also clone from this repository and perform a dev install:gitclonehttps://github.com/rcook/ibt.gitcdibtpipinstall--user-e.Note that Pip installs scripts to$HOME/.local/binby default
(varies based on platform), so make sure that this path is available on
the system search path (via thePATHenvironment variable). You can
do this by appending this in your.bashrcor other shell
configuration script:echo'export PATH=$HOME/.local/bin:$PATH'>>~/.bashrcStandard commandsdestroy: destroys the project’s Docker imagehelp: display helpinfo: shows system and project informationrun: runs a command inside a Docker containerscript: runs a script inside a Docker containershell: runs an interactive shell inside a Docker containerup: creates Docker image for the project after optionally
building base Docker imageAll commands have available to them the following environment variables:IBTALIASARGS: additional arguments passed on the command line to
aliasesIBTPROJECTDIR: the current project directory in the containerIBTUSERandUSER: the user nameIbtfilesettingsConfiguration for any given project is driven by the contents of theIbtfilesettings file which should be placed in the root directory
of the project. Alternatively, an.ibtprojectsfile placed in the
user’s home directory can be used to specify the location of theIbtfilefor zero or more project root directories for situations
where the IBT configuration must be kept out of the source tree.aliases: (optional) one or more project-specific command aliasesdocker: specifies base Docker image information for project
includingenv_vars: (optional) one or more environment variables to define
inside containerimageandbuildports: (optional) one or more host port-container port pairs tocontainer-project-dir: (optional) specifies directory to which
project directory is mapped in container configure port forwardingvolumes: (optional) one or more additional volumes to mount
inside containerEnvironment variable settingsThe environment section contain multiple environment variables to be set
in the container. The key represents the environment variable to be
created. The value contains either the value or a reference to a
substitution. A Substitution value starts with a$and is resolved
against the environment variable map. If the variable is not found, the
environment variable is looked up on the host.env_vars:ARTIFACTORY_APIKEY:$ARTIFACTORY_APIKEYARTIFACTORY_USER:BOB_THE_BUILDERCOMPOSITE_KEY:$ARTIFACTORY_USER@$HOSTVolumes settingsThe volume section contains multiple keys and values. The key refers to
a path on the host and the value contains the path in the container.volumes:host-path:container-pathKey and values support variable expansion like the environment
variables.volumes:$HOME/.kube:/home/$USER/.kube$HOME/.aws:/home/$USER/.awsSample projectCreate Docker imagesAll build commands will run inside a fully isolated Debian-based Docker
container as specified by the project configuration inIbtfile.
First, create the base Docker images:cddockerpushddebian-gccmakebuildpopdpushddebian-gcc-pythonmakebuildpopdpushddebian-gcc6makebuildpopddockerimagesThis createsdebian-gccwhich contains basic build tools, CMake and
gdb anddebian-gcc-pythonwhich extends this with the addition of
Python 2.7.debian-gcc6includes the GCC 6 toolchain. The last
command will list locally available Docker images which will now includeibt/debian-gccandibt/debian-gcc-pythonetc.AliasesOnce this is done, the following commands (configured as aliases inIbtfile) can be run to configure/make/run the project code:ibt cmake: generates CMake build directoryibt make: runsmakeinside CMake build directoryibt exec: runs target binaryibt debug: starts gdb and loads target binaryExample workflowSee contents ofexamplesubdirectory.$cdexample/$ibtupBuildingDockerimageibt-789dbc504a0690d786ddd43474dfbcc5$ibtcmake--TheCcompileridentificationisGNU6.3.0--TheCXXcompileridentificationisGNU6.3.0--CheckforworkingCcompiler:/usr/bin/cc--CheckforworkingCcompiler:/usr/bin/cc--works--DetectingCcompilerABIinfo--DetectingCcompilerABIinfo-done--DetectingCcompilefeatures--DetectingCcompilefeatures-done--CheckforworkingCXXcompiler:/usr/bin/g++--CheckforworkingCXXcompiler:/usr/bin/g++--works--DetectingCXXcompilerABIinfo--DetectingCXXcompilerABIinfo-done--DetectingCXXcompilefeatures--DetectingCXXcompilefeatures-done--Configuringdone--Generatingdone--Buildfileshavebeenwrittento:/example/build$ibtmakeScanningdependenciesoftargethello-world[50%]BuildingCXXobjectCMakeFiles/hello-world.dir/hello-world.cpp.o[100%]LinkingCXXexecutablehello-world[100%]Builttargethello-world$ibtexecfirstsecondthirdHelloworldargc=4argv[0]=./hello-worldargv[1]=firstargv[2]=secondargv[3]=third$ibtinfoIBT:IsolatedBuildToolhttps://github.com/rcook/ibtSysteminformation:Docker:installedContextinformation:Workingdirectory:/home/user/src/ibt/exampleUser:user(1002)Group:group(1003)Projectinformation:Projectdirectory:/home/user/src/ibt/exampleProjectID:789dbc504a0690d786ddd43474dfbcc5Configurationfile:/home/user/src/ibt/example/IbtfileTemporarydirectory:/home/user/src/ibt/example/.ibtProjectuserinformation:User:user(1002)Group:group(1003)Dockercontainerinformation:DockerimageID:ibt-789dbc504a0690d786ddd43474dfbcc5Projectdirectory:/exampleTemporarydirectory:/example/.ibtDockerbaseimage:ibt/debian-gcc6IBTstatus:Temporarydirectory:existsDockerimage:builtProjectaliases:cmake=run'cd $IBTPROJECTDIR && mkdir -p build && cd build && cmake -DCMAKE_BUILD_TYPE=Debug ..'debug=shell/bin/sh-c'cd $IBTPROJECTDIR/build && gdb ./hello-world'exec=run'cd $IBTPROJECTDIR/build && ./hello-world'make:-cd$IBTPROJECTDIR/build-make$ibtdestroyDestroyingDockerimageibt-789dbc504a0690d786ddd43474dfbcc5Developer guideSee developer guideLicenceReleased under MIT LicenseCopyright © 2016, Richard Cook. All rights reserved.