Page 1 of 1

CL & Docker

Posted: Thu Mar 29, 2018 12:32 am
by petah
Hiya Eran, long time no see!

I'm just learning to use Docker (under debian) and was wondering if there are any tricks to configure CL so it sends its Make commands to a Docker instance, while continuing to use CL's IDE on the host. Assuming a -(v)olume mapping between a host dir with the cpp files and some target inside the Docker container, or something to that effect.

thx & cheers!

-- p

Re: CL & Docker

Posted: Thu Mar 29, 2018 9:12 am
by eranif
tbh, I never tried that. So I can't really help you with this :)
I would like to hear any thoughts you have on the matter (even one that currently don't exists in CodeLite and could be implemented)
Thanks!

Re: CL & Docker

Posted: Thu Mar 29, 2018 1:14 pm
by petah
okay, I don't know a lot yet either so let's improvise and pls take my comments with a huge grain of salt :D

my understanding is that Docker is pretty much like a lightweight type of VM like Virtualbox or Qemu except much faster; there's almost no "boot" time and runtime is way faster because binaries talk directly to the host kernel, kindof like WINE.

AFAIK you usually launch individual applications inside a Docker container. I'm not clear yet how daemons/services work inside Docker, like if you can have more than one at a time running.

It's really easy to pull down a Docker image, e.g.:

Code: Select all

 docker pull gcc:latest
and then to compile inside it by launching a command from the host.

The host file system is invisible from the container so you usually want to map a host directory (containing your source code files, say) to a path inside the Docker container, so that the compiler tools can see your files. F.ex. I'd do:

Code: Select all

 docker run -v /home/plaufenb/bshare:/bshare  -it --rm gcc:latest bash
so my files are now available inside the container at /bshare, and then it launches an interactive bash shell inside that container. From then on I can cd into my /bshare directory and compile on the command line.

The Docker instance will be alive until I exit that shell, at which point it's automatically reaped. From the host you can also run a command in an existing Docker instance with 'docker exec' or attach another shell to it with 'docker attach'.

Sooooo... in order to interface with Codelite my guess is that the simplest (brute-force) method would be to manually update CL's build settings e.g.:

Make:

Code: Select all

 /usr/bin/make
 /docker run --rm $(DOCKER_NAME) /usr/bin/make
C++ compiler

Code: Select all

 /usr/bin/clang++
 /docker run --rm $(DOCKER_NAME) /usr/bin/clang++
I assume it'd be faster to launch the Docker instance only once at the beginning of the buid and then use 'docker exec' for individual build commands.

Note that while Docker image names do not change (in [name]:[tag] format), Docker instances have dynamic names, although those can also be set on the command line.

I will try to automate this somehow using CL env variables and see if Codelite can handle Docker just fine as-is. I'll let you know how that goes & any new CL features that I think would make interfacing with Docker easier, maybe to have a 'prefix' command in the build settings.

Debugging an app running inside Docker is a different problem but I'm guessing it's similar to cross-debugging where you expose the GDB server port.

Thx!

-- p

Re: CL & Docker

Posted: Thu Mar 29, 2018 6:12 pm
by petah
so I found this:

https://github.com/domeide/doclipser

Eclipse is a piece of crap, of course, but maybe the Docker integration could serve as inspiration?

Cheers,

-- p

Re: CL & Docker

Posted: Fri Mar 30, 2018 7:27 pm
by eranif
I will play with docker a bit and see what can be done

Re: CL & Docker

Posted: Sat Mar 31, 2018 4:21 am
by petah
cool