Docker Toolchain - Running shell script before executing C++ application

Answered

Hello,

I have multiple executables that I am building using the cmake profile configured with the Docker toolchain. One of the executables requires a bash script to be run within the container before launching it. As I understand, Clion doesnt provide docker toolchain support for bash scripts yet. Are there any workarounds or suggestions for this?

5 comments
Avatar
Vasily Romanikhin
Comment actions Permalink

Could you please clarify your final goal? probably executing custom_command from cmake could help.

0
Comment actions Permalink

We have few db setup scripts that needs to be executed before running the executables. Depending on the use case these scripts may or may not need to be run before running the executables. If I add it as a custom_command in cmake then I will have to build each time I want to execute the applications and times when I dont need to run these scripts, I have to pass a cmake argument to skip that command?

0
Avatar
Vasily Romanikhin
Comment actions Permalink

Ah, I see. But to be honest I'm not sure that special script helps in case of Docker Toolchain. The reason is quite simple docker container doesn't save the state between executions (except files in attached volumes), technically for each process we run separate container.

For you case I'd better prepare several different docker images, each for different script, than create several Docker Toolchains, and map each toolchain to different CMake configuration, e.g. 

 

 

 

0
Comment actions Permalink

Thanks for the suggestion. I will try this out.

I have another question. Is it possible for to run multiple processes simultaneously (i.e one process in the background) or will both of them run on separate containers?

0
Avatar
Vasily Romanikhin
Comment actions Permalink

CLion runs each process (build app, execute app) in separate container, but this containers could be run simultaneously. 

 

0

Please sign in to leave a comment.