A production-ready, optimized C++ development container with comprehensive tooling for modern C++ development, cross-compilation, and CI/CD integration.
| Image Tag | Size | Use Case |
|---|---|---|
latest-runtime | ~520MB | Production builds, CI/CD pipelines |
latest-development | ~760MB | Full development environment |
# Pull the runtime image
docker pull bmigeri/cpp-dev:latest-runtime
# Run interactive shell
docker run -it --rm \
-v $(pwd):/workspace \
bmigeri/cpp-dev:latest-runtime
Note
See example devcontainer.json for usage.
# Using Make
make build # Build runtime image
make build-dev # Build development image
make test # Run validation tests
# Using Docker directly
docker build --target runtime -t cpp-dev:runtime .
docker build --target development -t cpp-dev:development .
# Create and build a simple project
mkdir my-project && cd my-project
docker run -it --rm -v $(pwd):/workspace bmigeri/cpp-dev:latest-runtime bash
# Inside container
cat > main.cpp << 'EOF'
#include <iostream>
int main() {
std::cout << "Hello, World!" << std::endl;
return 0;
}
EOF
g++ main.cpp -o hello
./hello
# Inside container
mkdir build && cd build
cmake .. -GNinja
ninja
# Inside container
mkdir build-arm && cd build-arm
# For ARM 32-bit
cmake .. -GNinja \
-DCMAKE_TOOLCHAIN_FILE=/opt/toolchains/arm-linux-gnueabihf.cmake
# For ARM 64-bit
cmake .. -GNinja \
-DCMAKE_TOOLCHAIN_FILE=/opt/toolchains/aarch64-linux-gnu.cmake
ninja
// example.cpp
#include <grpcpp/grpcpp.h>
#include <iostream>
int main() {
auto channel = grpc::CreateChannel(
"localhost:50051",
grpc::InsecureChannelCredentials()
);
std::cout << "gRPC channel created" << std::endl;
return 0;
}
# Compile with gRPC
g++ example.cpp -o example \
$(pkg-config --cflags --libs grpc++ protobuf)
// test_example.cpp
#include <gtest/gtest.h>
TEST(ExampleTest, BasicAssertion) {
EXPECT_EQ(2 + 2, 4);
}
int main(int argc, char **argv) {
testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
# Compile and run tests
g++ test_example.cpp -o test \
$(pkg-config --cflags --libs gtest) \
-pthread
./test
The container includes pre-configured CMake kits at /opt/toolchains/cmake-kits.json:
{
"cmake.additionalKits": ["/opt/toolchains/cmake-kits.json"]
}
Available kits:
PKG_CONFIG_PATH=/opt/grpc/lib/pkgconfig:/opt/gtest/lib/pkgconfig:/opt/pcl/lib/pkgconfig
LD_LIBRARY_PATH=/opt/grpc/lib:/opt/gtest/lib:/opt/pcl/lib
CMAKE_PREFIX_PATH=/opt/grpc:/opt/gtest:/opt/pcl
The repository includes a complete GitHub Actions workflow for automated builds:
# Triggered on push to main/develop
- Builds both runtime and development images
- Multi-architecture support (amd64, arm64)
- Layer caching for faster builds
- Security scanning with Trivy
- SBOM generation
- Automatic Docker Hub updates
# .gitlab-ci.yml example
build:
image: docker:latest
services:
- docker:dind
script:
- docker build --target runtime -t $CI_REGISTRY_IMAGE:latest .
- docker push $CI_REGISTRY_IMAGE:latest
// Jenkinsfile example
pipeline {
agent any
stages {
stage('Build') {
steps {
sh 'make build'
}
}
stage('Test') {
steps {
sh 'make test'
}
}
stage('Push') {
steps {
sh 'make push'
}
}
}
}
developer) for safer operationThis Dockerfile uses several optimization techniques:
# Check image sizes
make size
# Expected results:
# runtime: ~800MB
# development: ~1.2GB
# Clear Docker cache
make clean
# Deep clean (removes all Docker data)
make prune
# Check Docker disk usage
docker system df
If building locally fails due to storage:
export DOCKER_BUILDKIT=1make build-cached with registry caching# If you encounter permission issues in the container
docker run --user root ... # Run as root temporarily
Contributions are welcome! Please follow these guidelines:
This project is licensed under the MIT License - see the LICENSE file for details.
Built with ❤️ for C++ developers
Content type
Buildkit_cache
Digest
sha256:7caa87d0d…
Size
1.7 GB
Last updated
8 months ago
docker pull bmigeri/cpp-dev:buildcache-runtime