Template files for creating a container for a build environment
As a template, the basic files needed to create a container for housing a particular build environment are:
- The container recipe (
Dockerfile
) itself - A build script that builds the image. This may be as simple as the
build
command, but can get more complex with complex build environments. - An install script that at least sets as alias up for invoking the container image (since
the
run
command has so many options to remember). But also it may setup the corresponding environment on the Host for persistent build data if it cannot be done with the host setup script run inside the container (eg, cloning source code that requires the user's credentials). - A Host initialization script that may do further one-time Host setup, but run within the container (eg, the source code you are building that you will also want to modify).
- An initialization script to be run each time the container image is invoked. At least, this is setting up the user id so that the owner of the build artifacts is the same as the host user invoking the container. It may also initialize anything else needed before a build.
To create a containerized build environment from these templates:
- Set names for the container and what it builds (
_what_i_build
,autoSDbuilder
) inbuild_docker_image.sh
andinstall.sh
- Update
Dockerfile
to use the desired base OS, install the necessary packages, and anything else that can be statically installed for the build environment. - Update the Host install script
install.sh
to do any non-container installations, like clone git repos. - Update the container based Host setup script
hostsetup.sh
with any remaining one-time Host setup. - Add any setup needed each time the container is invoked in
entrypoint.sh
. - Update the README.md with build and usage instructions for this particular build environment.
./build_docker_image.sh
./install.sh
In the installation directory (specified in the installation step):
- Source the .alias file
source .alias
- Build the project:
<build_container> make [-C <sub_dir>]
- Or enter the container and execute commands directly: `<build_container>``
If working inside the container, any pushes to the repo need to be made outside the container, as the container does not have the user's push credentials.