Simple C++ Builder with compilers, buildtools and dependency manager.
- Pre-installed Compilers and Tools
- Ready to use
build scripts (docker-build.sh and docker-test.sh)Taskfiles
Based on archlinux:base-devel with yay.
- Compilers: clang, gcc or cross-compiler
- Buildtools: cmake, make and ninja
- Dependency Manager: conan and/or vcpkg
- More Tools: python, pip, ccache, cppcheck, doxygen and more
You can find a full C++ project example here.
- Create a
Dockerfile
in your C++ project
## build stage
FROM abeimler/simple-cppbuilder as build
COPY . .
CMD ["task", "-t", "/home/taskfiles/Taskfile.yml", "build"]
## test stage
FROM build as test
CMD ["task", "-t", "/home/taskfiles/Taskfile.yml", "test"]
- Build and run the Docker image:
$ docker build -t my-cpp-project .
$ docker run -it --rm --name my-app my-cpp-project
$ docker run -it --rm --name my-cpp-project -v "$PWD":/home/project -w /home/project abeimler/simple-cppbuilder ./docker-build.sh
Base image with gcc, buildtools and conan (dependency manager) installed.
Default image with gcc, buildtools, conan installed and vcpkg bootstrapped.
Default image with clang compiler.
Default image with gcc compiler.
Default image with clang and libc++ installed.
Default image with boost installed.
Default image with abseil installed.
Default image with some OpenGL dependencies: mesa glu glfw-x11 libx11 libxrender libxext libxcursor libxrandr libxinerama xorg-server-devel
.
Alternative Ubuntu-based image with basic compilers and tools.
Nice base image for CI/CD.
Alternative Ubuntu-based image with basic compilers and tools.
Uses setup-cpp.
Not fully tested
Default image with mingw-w64-cross-compiler: mingw-w64-gcc and toolchain.
:x64-mingw-w64-mxe
, x86-mingw-w64-mxe
, :x64-mingw-w64-mxe-static
, :x86-mingw-w64-mxe-static
(older compiler)
Default image with mxe and toolchain.
Default image with emscripten.
Default image with arm-cross-compiler: (crosstool-ng) for RaspberryPi, raspberrypi-tools and toolchain.
Default image with android-ndk and toolchain.
FROM abeimler/simple-cppbuilder as base
RUN pacman-db-upgrade && pacman -S --noconfirm \
qt5-base qt5-base-util
# build stage
FROM base as build
COPY . .
CMD ["task", "-t", "/home/taskfiles/Taskfile.yml", "build"]
FROM abeimler/simple-cppbuilder as base
# install android-sdk and android-ndk
RUN runuser -l yay -c \
"yay -Syu --noconfirm && yay -S --noconfirm \
android-sdk android-ndk"
# build stage
FROM base as build
COPY . .
CMD ["./my-android-build.sh"]
version: '3.4'
services:
# gcc Release with Ninja
gcc-release-build:
build:
context: .
dockerfile: Dockerfile
target: build
environment:
CC: gcc
CXX: g++
TARGET: all
BUILD_TYPE: Release
CMAKE_GENERATOR: Ninja
$ docker-compose up --build
version: '3.4'
services:
# gcc Debug with Ninja
gcc-debug-test:
build:
context: .
dockerfile: Dockerfile
target: test
environment:
TARGET: all
BUILD_TYPE: Debug
CMAKE_GENERATOR: Ninja
$ docker-compose up --build
Use your custom build script Better use a Taskfile
---
version: "3"
vars:
PROJECT_DIR: '{{.PROJECT_DIR | default "."}}'
TARGET: '{{.TARGET | default "all"}}'
CMAKE_GENERATOR: '{{.CMAKE_GENERATOR | default "Ninja Multi-Config"}}'
BUILD_TYPE: '{{.BUILD_TYPE | default "Release"}}'
tasks:
configure:
dir: '{{.PROJECT_DIR}}'
cmds:
- >
cmake -B build -S . -G "{{.CMAKE_GENERATOR}}" \
-DCMAKE_BUILD_TYPE="{{.BUILD_TYPE}}" \
{{.CMAKE_ARGS}}
build:
dir: '{{.PROJECT_DIR}}'
cmds:
- task: configure
- 'cmake --build build --target "{{.TARGET}}"'
test:
dir: '{{.PROJECT_DIR}}'
cmds:
- task: build
- ctest --build-test --test-dir build
# base image
FROM abeimler/simple-cppbuilder as base
# build stage
FROM base as build
COPY . .
#CMD ["./my-build.sh"]
CMD ["task", "build"]
---
version: '3.4'
services:
my-app-build:
build:
context: .
dockerfile: Dockerfile
target: build
$ docker-compose up --build
C Compiler, default: gcc
.
Can also be clang
.
C++ Compiler, default: g++
.
Can also be clang++
.
CMake Generator cmake -G
, default: Ninja
.
Can also be Unix Makefiles
.
CMake BuildType -DCMAKE_BUILD_TYPE
, default: Release
.
Can also be Debug
, RelWithDebInfo
or MinSizeRel
.
target run by cmake cmake --target
, default: all
.
CMake Toolchain File -DCMAKE_TOOLCHAIN_FILE
, default ./vcpkg/scripts/buildsystems/vcpkg.cmake
.
Custom CMake Arguments, e.g. -DENABLE_TESTING:BOOL=ON -DOPT_ENABLE_COVERAGE:BOOL=ON -DENABLE_DEVELOPER_MODE:BOOL=OFF
.
Here are some Environment Variables you can use in your build script, such as paths, scripts and programs.
make
or ninja
.
Project-Home folder, /home/project
.
Path to vcpkg, /home/project/vcpkg
.
vcpkg Toolchain, /home/project/vcpkg/scripts/buildsystems/vcpkg.cmake
.
Path to codedov uploader, /home/codecov/codecov
.
(Used in CI/CD images)
vcpkg target- and host-triplet.
(Used in cross-compiler images)
alternate CMake toolchain (for vcpkg)
(Used in cross-compiler images)
Path to CMake Toolchain, /home/cmake/x86_64-w64-mingw32.toolchain.cmake
.
(Used in cross-compiler images)
source or setup-environment-script for cross compiler tools, /usr/lib/emsdk/emsdk_env.sh
or ~/.cpprc
, ...
(Used in cross-compiler images)
Paths for emscripten, emsdk and configs.
EM_CACHE
:/usr/lib/emsdk/upstream/emscripten/cache
EM_CONFIG
:/usr/lib/emsdk/.emscripten
EMSCRIPTEN_PATH
:/usr/lib/emscripten
EMSDK
:/usr/lib/emsdk
EMSDK_PATH
:/usr/lib/emsdk
(Used in emscripten images)
View license information for this image.
As with all Docker images, these likely also contain other software which may be under other licenses (such as Bash, etc from the base distribution, along with any direct or indirect dependencies of the primary software being contained).
As for any pre-built image usage, it is the image user's responsibility to ensure that any use of this image complies with any relevant licenses for all software contained within.
- simple-cppbuilder DockerHub
- simple-cppbuilder GitHub
- cpp_starter_project
- cpp_vcpkg_project
- cppdock
- Icon made by me using C++-Icon made by Freepik from Flaticon