0

I'm creating a docker image as a build environment where I can mount a project and build it. For build I use cmake and conan. The dockerfile of this image:

FROM alpine:3.9

RUN ["apk", "add", "--no-cache", "gcc", "g++", "make", "cmake", "python3", "python3-dev", "linux-headers", "musl-dev"]
RUN ["pip3", "install", "--upgrade", "pip"]
RUN ["pip3", "install", "conan"]
WORKDIR /project

Files like

~/.conan/profiles/default

are created after I call

conan install ..

so that these files are created in the container and not in the image. The default behavior of conan is to set

compiler.libcxx=libstdc++

I'd like to run something like

RUN ["sed", "-i", "s/compiler.libcxx=libstdc++/compiler.libcxx=libstdc++11/", "~/.conan/profiles/default"]

to change the libcxx value but this file does not exist at this point. The only way I found to create the default profile by conan would be to install something.

Currently I'm running this container with

docker run --rm -v $(dirname $(realpath $0))/project:/project build-environment /bin/sh -c "\
rm -rf build && \
mkdir build && \
cd build && \
conan install -s compiler.libcxx=libstdc++11 .. --build missing && \
cmake .. && \
cmake --build . ; \
chown -R $(id -u):$(id -u) /project/build \
"

but I need to remove -s compiler.libcxx=libstdc++11 as it should be dependent on the image and not fixed by the build script.

Is there a way to initialize conan inside the image and edit the configuration without installing something? Currently I'm planning to write the whole configuration by myself but that seems a little too much as I want to use the default configuration and change only one line.

Thomas Sablik
  • 16,127
  • 7
  • 34
  • 62

1 Answers1

1

You can also create an image from a running container. Try installing conan in running container and then create an image of it. As it is being installed in running container it will have all dependencies only for it. To create that image you can follow this link

https://docs.docker.com/engine/reference/commandline/commit/

tushar_ecmc
  • 186
  • 2
  • 21