Simple C++ Builder with gcc/clang, cmake and dependency manager (conan and vcpkg)
4.6K
Simple C++ Builder with compilers, buildtools and dependency manager.
Based on archlinux:base-devel with yay.
You can find a full C++ project example here.
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"]
$ 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
:baseBase image with gcc, buildtools and conan (dependency manager) installed.
:<version>, :latestDefault image with gcc, buildtools, conan installed and vcpkg bootstrapped.
:clangDefault image with clang compiler.
:gcc10, :gcc9 (outdated)Default image with gcc compiler.
:libcppDefault image with clang and libc++ installed.
:boostDefault image with boost installed.
:abseil-cppDefault image with abseil installed.
:opengl-libsDefault image with some OpenGL dependencies: mesa glu glfw-x11 libx11 libxrender libxext libxcursor libxrandr libxinerama xorg-server-devel.
:ci, :ci-x64-mingw-w64Alternative Ubuntu-based image with basic compilers and tools.
Nice base image for CI/CD.
:ci-setup-cppAlternative Ubuntu-based image with basic compilers and tools.
Uses setup-cpp.
Not fully tested
:x64-mingw-w64, :x86-mingw-w64Default 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.
:emscriptenDefault image with emscripten.
:rpi4, :rpi3, :rpi2, :rpi1Default image with arm-cross-compiler: (crosstool-ng) for RaspberryPi, raspberrypi-tools and toolchain.
:arm-android, :arm64-android, :x86-android, :x64-androidDefault 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
my-build.shTaskfile.yml---
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
Dockerfile# base image
FROM abeimler/simple-cppbuilder as base
# build stage
FROM base as build
COPY . .
#CMD ["./my-build.sh"]
CMD ["task", "build"]
docker-compose.yml---
version: '3.4'
services:
my-app-build:
build:
context: .
dockerfile: Dockerfile
target: build
$ docker-compose up --build
CCC Compiler, default: gcc.
Can also be clang.
CXXC++ Compiler, default: g++.
Can also be clang++.
CMAKE_GENERATORCMake Generator cmake -G, default: Ninja.
Can also be Unix Makefiles.
BUILD_TYPECMake BuildType -DCMAKE_BUILD_TYPE, default: Release.
Can also be Debug, RelWithDebInfo or MinSizeRel.
TARGETtarget run by cmake cmake --target, default: all.
TOOLCHAIN_FILECMake Toolchain File -DCMAKE_TOOLCHAIN_FILE, default ./vcpkg/scripts/buildsystems/vcpkg.cmake.
CMAKE_ARGSCustom 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.
MAKEmake or ninja.
PROJECT_DIRProject-Home folder, /home/project.
VCPKG_ROOTPath to vcpkg, /home/project/vcpkg.
VCPKG_TOOLCHAIN_FILEvcpkg Toolchain, /home/project/vcpkg/scripts/buildsystems/vcpkg.cmake.
CODECOVPath to codedov uploader, /home/codecov/codecov.
(Used in CI/CD images)
VCPKG_DEFAULT_HOST_TRIPLET, VCPKG_DEFAULT_TRIPLETvcpkg target- and host-triplet.
(Used in cross-compiler images)
VCPKG_CHAINLOAD_TOOLCHAIN_FILEalternate CMake toolchain (for vcpkg)
(Used in cross-compiler images)
CROSS_TOOLCHAINPath to CMake Toolchain, /home/cmake/x86_64-w64-mingw32.toolchain.cmake.
(Used in cross-compiler images)
SETUP_ENV_SCRIPTsource or setup-environment-script for cross compiler tools, /usr/lib/emsdk/emsdk_env.sh or ~/.cpprc, ...
(Used in cross-compiler images)
EM_CACHE, EM_CONFIG, EMSCRIPTEN_PATH, EMSDK, EMSDK_PATHPaths for emscripten, emsdk and configs.
EM_CACHE: /usr/lib/emsdk/upstream/emscripten/cacheEM_CONFIG: /usr/lib/emsdk/.emscriptenEMSCRIPTEN_PATH: /usr/lib/emscriptenEMSDK: /usr/lib/emsdkEMSDK_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.
Content type
Image
Digest
sha256:40345c148…
Size
882.1 MB
Last updated
about 3 years ago
docker pull abeimler/simple-cppbuilder:ci-x64-mingw-w64