diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 72c8b84..2a476bd 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,8 +1,12 @@ { - "name": "C++", + "name": "4beumer.nl C++", "build": { - "dockerfile": "../devcontainer.Dockerfile" + "dockerfile": "../devcontainer.Dockerfile", + "args": { + "BUILD_TYPE": "Debug" + } }, + "postCreateCommand": "${containerWorkspaceFolder}/.devcontainer/postcreate.py --build_type=Debug", // Configure tool-specific properties. "customizations": { "vscode": { @@ -14,6 +18,7 @@ }, "extensions": [ "ms-vscode.cpptools", + "ms-python.python", "twxs.cmake", "ms-vscode.cmake-tools", "konicy.conan-extension" diff --git a/.devcontainer/postcreate.py b/.devcontainer/postcreate.py new file mode 100755 index 0000000..2e5d200 --- /dev/null +++ b/.devcontainer/postcreate.py @@ -0,0 +1,10 @@ +#! /usr/bin/python +import argparse +import os + +parser = argparse.ArgumentParser() +parser.add_argument('--build_type') +args = parser.parse_args() + +print ('Executing post-create steps. Build type ', args.build_type) +os.system('conan install /workspaces/network-experiment -of /workspaces/build -s build_type=' + args.build_type) diff --git a/devcontainer.Dockerfile b/devcontainer.Dockerfile index 62a86f9..5cc586f 100644 --- a/devcontainer.Dockerfile +++ b/devcontainer.Dockerfile @@ -1,5 +1,12 @@ -FROM alpine:3.21.3 AS build +FROM alpine:3.21.3 +# Build type used by conan. "Debug" and "Release" are supported. +ARG BUILD_TYPE=Debug + +RUN mkdir -p /root/.local/bin +ENV PATH="${PATH}:/root/.local/bin" + +# Install packages needed in both building and running. RUN apk update && \ apk add --no-cache \ libstdc++ @@ -20,23 +27,25 @@ RUN apk add --no-cache \ m4 \ perl \ python3 \ - py3-pip && \ - pip install --break-system-packages conan && \ + pipx && \ + pipx ensurepath +RUN pipx install conan && \ conan profile detect # Pre-build some conan packages we require and take a lot of time to build. This to # avoid expensive rebuilding everytime we need a fresh dev container.. RUN mkdir -p /workspaces/tmp WORKDIR /workspaces/tmp -RUN conan install -s build_type=Debug -b=* --requires=boost/1.89.0 -RUN conan install -s build_type=Debug -b=* --requires=libmagic/5.45 -RUN conan install -s build_type=Debug -b=* --requires=freetype/2.14.1 -RUN conan install -s build_type=Debug -b=missing --requires=gtest/1.14.0 -RUN conan install -s build_type=Debug -b=missing --requires=libjpeg/9f - -# Remove the temporary workspace, build results for the conan packages remain cached. +RUN conan install -s build_type=${BUILD_TYPE} -b=* --requires=boost/1.89.0 +RUN conan install -s build_type=${BUILD_TYPE} -b=* --requires=libmagic/5.45 +RUN conan install -s build_type=${BUILD_TYPE} -b=* --requires=freetype/2.14.1 +RUN conan install -s build_type=${BUILD_TYPE} -b=missing --requires=gtest/1.14.0 +RUN conan install -s build_type=${BUILD_TYPE} -b=missing --requires=libjpeg/9f WORKDIR /workspaces -RUN rm -rf tmp && \ - mkdir network-experiment && \ - mkdir build && \ - mkdir install +RUN rm -rf tmp + +RUN apk add --no-cache \ + clang \ + clang-extra-tools \ + gdb \ + git diff --git a/http-mandelbrot.Dockerfile b/http-mandelbrot.Dockerfile index 2f291c2..51396e5 100644 --- a/http-mandelbrot.Dockerfile +++ b/http-mandelbrot.Dockerfile @@ -1,5 +1,12 @@ FROM alpine:3.21.3 AS build +# Build type used by conan. "Debug" and "Release" are supported. +ARG BUILD_TYPE=Release + +RUN mkdir -p /root/.local/bin +ENV PATH="${PATH}:/root/.local/bin" + +# Install packages needed in both building and running. RUN apk update && \ apk add --no-cache \ libstdc++ @@ -20,19 +27,22 @@ RUN apk add --no-cache \ m4 \ perl \ python3 \ - py3-pip && \ - pip install --break-system-packages conan && \ + pipx && \ + pipx ensurepath +RUN pipx install conan && \ conan profile detect # Pre-build some conan packages we require and take a lot of time to build. This to # avoid expensive rebuilding everytime we need a fresh dev container.. RUN mkdir -p /workspaces/tmp WORKDIR /workspaces/tmp -RUN conan install -s build_type=Release -b=* --requires=boost/1.89.0 -RUN conan install -s build_type=Release -b=* --requires=libmagic/5.45 -RUN conan install -s build_type=Release -b=* --requires=freetype/2.14.1 -RUN conan install -s build_type=Release -b=missing --requires=gtest/1.14.0 -RUN conan install -s build_type=Release -b=missing --requires=libjpeg/9f +RUN conan install -s build_type=${BUILD_TYPE} -b=* --requires=boost/1.89.0 +RUN conan install -s build_type=${BUILD_TYPE} -b=* --requires=libmagic/5.45 +RUN conan install -s build_type=${BUILD_TYPE} -b=* --requires=freetype/2.14.1 +RUN conan install -s build_type=${BUILD_TYPE} -b=missing --requires=gtest/1.14.0 +RUN conan install -s build_type=${BUILD_TYPE} -b=missing --requires=libjpeg/9f +WORKDIR /workspaces +RUN rm -rf tmp # Remove the temporary workspace, build results for the conan packages remain cached. WORKDIR /workspaces @@ -41,16 +51,16 @@ RUN rm -rf tmp && \ mkdir build && \ mkdir install - # Build and install WORKDIR /workspaces/network-experiment ADD . . -RUN conan install /workspaces/network-experiment -of /workspaces/build -s build_type=Release -RUN cmake -DCMAKE_POLICY_DEFAULT_CMP0091=NEW -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake -S . -B /workspaces/build --install-prefix=/workspaces/install +RUN conan install /workspaces/network-experiment -of /workspaces/build -s build_type=${BUILD_TYPE} +RUN cmake -DCMAKE_POLICY_DEFAULT_CMP0091=NEW -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake -S . -B /workspaces/build --install-prefix=/workspaces/install RUN cmake --build /workspaces/build --parallel RUN cmake --install /workspaces/build + FROM alpine:3.21.3 RUN apk update && \