Thanks to Ravi Chandran for providing input and templates
This repo contains simple docker files, container creation scripts, and build scripts to build most C/C++ (and other) systems.
See official Docker documentation for instructions on how to install docker on a Debian/Ubuntu box.
-
Copy and modify docker file template
Create a copy of the templatedocker-build/template-build-container.dockerfile
and add apt packages and additional setup commands as needed. -
Create a docker image
Run the docker image build script with your customized docker file as a single argument:cd docker-build ./build-docker.image.sh my-docker-image.dockerfile
The docker image will be named
my-docker-image:v1
-
Launch the docker image with a shell
Run thebuild.sh
script with your docker image name and source code directory on your local machine:./build.sh my-docker-image ~/work/my-source-code /bin/bash
(The
/bin/bash
command argument is optional since that is the default command if nothing is specified)The docker image will launch and drop you into an interactive bash shell.
The current directory of the shell is
/src/
, which is mounted as a docker volume to the local machine's~/work/my-source-code
directory/ -
Do trial builds inside docker
Do a test build from inside the container and note any missing packages and setups needed to successfully build the code in~/work/my-source-code
-
Update docker file and re-create docker image
Exit the docker container (ctrl-d) and update the docker file with the necessary changes. Recreate the docker image and test again as described in step 2-4.
Run the build script, providing docker image, source dir and build command
./build.sh my-docker-image ~/work/my-source-code make all
The make all
command will be exceuted inside the docker container in the
/src/
directory mapped to ~/work/my-source-code
.