8000 GitHub - sbourdelin/cqfd: cqfd - run builds inside the Docker container configured for your project
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

sbourdelin/cqfd

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

43 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

What is cqfd ?

cqfd provides a quick and convenient way to run commands in the current directory, but within a Docker container defined in a per-project config file. This becomes useful when building an application designed for another Linux system, e.g. building a RHEL7 app when your workstation runs on Ubuntu 16.04.

Using cqfd

Requirements

To use cqfd, ensure the following requirements are satisfied on your workstation:

  • Bash 4.x

  • Docker

  • A docker group in your /etc/group

  • Your username is a member of the docker group

  • Restart your docker service if you needed to create the group.

Installing/removing cqfd

The cqfd script can be installed system-wide.

Install or remove the script and its resources:

$ make install
$ make DESTDIR=/usr install
$ make uninstall

The .cqfdrc file

The .cqfdrc file at the root of your project contains the information required to support project tooling. samples/dot-cqfdrc is an example.

Here is a sample .cqfdrc file:

[project]
org='fooinc'
name='buildroot'

[build]
command='make foobar_defconfig && make && asciidoc README.FOOINC'

[release]
files='README.FOOINC output/images/sdcard.img'

Build flavors

In some cases, it may be desirable to build the project using variations of the build and release methods. This is made possible in cqfd with the build flavors feature.

In the .cqfdrc file, flavors may be listed in the build section, referencing sections prefixed with the flavor’s name.

[foo]
command='make foobar_foo_defconfig && make && asciidoc README.FOOINC'
files='README.FOOINC output/images/sdcard_foo.img'

[bar]
command='make foobar_bar_defconfig && make && asciidoc README.FOOINC'
files='README.FOOINC output/images/sdcard_bar.img'

[build]
flavors='foo bar'

Section project

project.org This is a short, lowercase name for the project’s parent organization. This name will be used in gerrit to prefix the repository paths, in docker to prefix the image names, and in various other places.

project.name This is a short, lowercase name for the project, used in gerrit as the repository name, for example buildroot or linux.

Section build

build.command The command (or list of commands). This string will be passed as an argument to a classical bash -c "commands", within the build container, to generate the build artefacts.

build.flavors List of build flavors. Each flavor has its own command just like build.command.

Section release

release.files A space-separated list of files generated by the build process that we want to include inside a standard release archive.

Section flavor

flavor.command The equivalent of build.command for a given flavor.

flavor.files The equivalent of release.files for a given flavor.

Environment variables

The following environment variables are supported by cqfd to provide the user with extra flexibility during his day-to-day development tasks:

CQFD_EXTRA_VOLUMES: A space-separated list of additional volume mappings to be configured inside the started container. Format is the same as docker-run’s -v option.

Initializing the build container

Enter your project repository and grab the provided sample files:

$ cd path/to/fooinc/barproject/
$ cp <cqfd_source_dir>/samples/dot-cqfdrc ./.cqfdrc
$ mkdir -p ./.cqfd/docker
$ cp <cqfd_source_dir>/samples/Dockerfile.trusty.nodejs5x \
      ./.cqfd/docker/Dockerfile

Once the initial configuration has been done, the cqfd helper script can be used to automate the generation of the build container, as well as executing your build commands inside the container.

The following command creates the initial build container:

$ cqfd init

cqfd will use the provided Dockerfile (which must be located in the .cqfd/docker/ directory of your project) to create a normalized runtime build environment for your project.

Using the build container

Regular builds

To build your project from the configured build environment with the default build command as configured in .cqfdrc, use:

$ cqfd

Alternatively, you may want to specify a custom build command to be executed from inside the build container.

$ cqfd run make clean
$ cqfd run "make linux-dirclean && make foobar-dirclean"

When cqfd is running, the current directory is mounted by Docker as a volume. As a result, all the build artefacts generated inside the container are still accessible in this directory.

Release

The release command behaves exactly like run, but creates a release tarball for your project additionally. The release files (as specified in your .cqfdrc) will be included inside the release archive.

$ cqfd release

The resulting release file is then called unique job name, or the string "local-build" when run from outside Jenkins, and BUILD_ID is a Jenkins-generated unique and date-based string, or the current date.

Flavor

You may also want to build a specific build flavor, for a regular build or a release. To do so use the -b option:

$ cqfd -b <flavor_name> run|release

When building with a flavor, as when building a regular project, the run option can be omitted.

Other command-line options

In some conditions you may want to use an alternate config file with cqfd. This is what the -f option is for:

$ cqfd -f .cqfdrc.test

Testing cqfd

The codebase contains tests which can be invoked using the following command, if the above requirements are met on the system:

$ make tests

Trivia

CQFD stands for "Ce qu'il fallait Dockeriser".

About

cqfd - run builds inside the Docker container configured for your project

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Shell 91.6%
  • Makefile 8.4%
0