This is a simple C++ project that can be built both on Windows and in a Docker container.
- Make sure you have CMake and a C++ compiler (like MSVC or MinGW) installed
- Open a terminal in the project directory
- Create and enter the build directory:
mkdir build cd build - Generate build files and build the project:
cmake .. cmake --build . - Run the executable:
.\Debug\cpp_example.exe
The project uses a multi-stage Dockerfile which:
- First stage (builder) - Compiles the code with all necessary build tools
- Second stage (runtime) - Contains only the compiled executable, resulting in a smaller, more secure final image
To build and run:
- Make sure you have Docker installed
- Open a terminal in the project directory
- Build the Docker image:
docker build -t cpp-example . - Run the container:
docker run cpp-example
The multi-stage build approach ensures the final container image is minimal, containing only what's needed to run the application, without build tools or source code.
src/main.cpp: Main source file containing the example codeCMakeLists.txt: CMake configuration file for building the projectDockerfile: Docker configuration for containerized building and running.gitignore: Specifies which files Git should ignore