Ticket #3821 - Docker env build container, now with FEM!

Having trouble installing or compiling FreeCAD? Get help here.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: Ticket #3821 - Docker env build container, now with FEM!

Post by Kunda1 »

etrombly wrote: Wed Apr 15, 2020 7:44 pm It's really easy to set up distcc if you have multiple computers to speed up compiling with this too.
distcc sounds amazing and very much necessary for FC development! Should we start a separate thread for that?
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
etrombly
Posts: 144
Joined: Thu Dec 05, 2019 6:50 pm

Re: Ticket #3821 - Docker env build container, now with FEM!

Post by etrombly »

Kunda1 wrote: Wed Apr 15, 2020 8:54 pm distcc sounds amazing and very much necessary for FC development! Should we start a separate thread for that?
This is actually my first time using it. The docker container is pretty essential for me because you don't have to worry about setting up the dependencies on the distcc server if you use it. If you want we can put it in another thread though.
User avatar
David_D
Posts: 81
Joined: Fri Jun 29, 2018 6:43 am
Location: Christchurch, New Zealand

Re: Ticket #3821 - Docker env build container, now with FEM!

Post by David_D »

Kunda1 wrote: Mon Mar 23, 2020 10:17 pm
kizbitz wrote: Mon Mar 23, 2020 10:10 pm @kkremitzki - If you could DM me I'll work through the transfer with you.

Thanks
kkremitzki wrote::point_up_2:
Has there been any love with this? I'd love to get this going as an official project. :D
iyd2019
Posts: 108
Joined: Tue Oct 15, 2019 9:19 am

Re: Ticket #3821 - Docker env build container, now with FEM!

Post by iyd2019 »

hi all!

thanks for your work David, it's VERY useful! I hadn't done any work on the FreeCAD source yet because of the complexity of the "infrastructure" required... and you just totally blew that problem away!

I just installed docker, and tested your image: the building worked flawlessly!

now my concerns:
  • Python version is older :oops: than the version in use (your 3.7m vs FreeCAD team 3.8 older!)
  • QT version is newer :shock: than the version in use (your Qt_5.13 vs FreeCAD team Qt_5.12.5)
  • When I run FreeCAD in my docker, it hangs, but seems a problem with GPU drivers (link)
and why this matters? because of my work process, that some other could share:
  • My machine is an apple which is running Ubuntu 20.04
  • I do many things in this machine, so I need a "container" for separation: for example FreeCAD development
  • With your docker image, I can do just that, but I would use it only for compilation, as I'll run the compiled code in the host itself (for maximum performance, with no middle layer at all, to be the "real thing" as much as possible).
the following issues arise (for now):
  • I tend to do "small changes", so my idea was to do them on the docker image and test it on the real machine (for example, change the SketcherGui.so in my host FreeCAD installation for the "corrected version" from my Docker compilation), which I can't because of the dependencies mismatch.
  • Executing it in the Docker itself, which I can't because of the gpu-drivers problem
  • Executing the hole new compiled version on the host, which I also can't, because the app is not packed as standalone.
I don't expect solutions from you, but wanted to leave this information here in case it helps in future decisions.

In any case, any tips would be much appreciated :)

best regards!
User avatar
David_D
Posts: 81
Joined: Fri Jun 29, 2018 6:43 am
Location: Christchurch, New Zealand

Re: Ticket #3821 - Docker env build container, now with FEM!

Post by David_D »

iyd2019 wrote: Fri May 22, 2020 5:23 pm
Hello iyd, very glad to hear you're finding the project useful!

As for your GPU driver problem, I believe the problem is that the graphics drivers installed in the docker container are different to the graphics drivers on the host machine. FreeCAD is trying to communicate in one driver's language, but the host can't read them. I'm not really sure how to resolve that issue on an apple machine, but on my box, I resolved it by uninstalling the proprietary nvidia graphics drivers on my host, and instead using the open source Nouveau drivers.

As for running the compiled code on the host, I'd recommend not doing that, as it somewhat defeats the purpose of the docker container. If you're able to resolve the dependencies to run FreeCAD on your host, you're probably better served by just compiling it on the host in the first place :lol: . I think you'll find the performance difference to be not that great between running in, or outside the docker container. I'd certainly pursue the option of resolving the GPU problem, if I were you. But hey, more power to you if you figure out a way that works!

In terms of having the most similar experience to the end user by running on the host, in my poorly informed opinion, I think the end user experience of FreeCAD is very dependant on how FreeCAD is packaged and distributed. The visual difference between FreeCAD installed from source, as an appimage, or installed from packages is stark. So if you're looking for the true FreeCAD UX experience, I don't believe such a thing exists.

Also, thanks for pointing out that version mismatch! I'll have to come up with a more rigorous method for choosing versions. I typically just go for whatever is newest at the time I'm refreshing the dependencies. :shock:
iyd2019
Posts: 108
Joined: Tue Oct 15, 2019 9:19 am

Re: Ticket #3821 - Docker env build container, now with FEM!

Post by iyd2019 »

David_D wrote: Fri May 22, 2020 8:57 pm As for your GPU driver problem, I believe the problem is that the graphics drivers installed in the docker container are different to the graphics drivers on the host machine. FreeCAD is trying to communicate in one driver's language, but the host can't read them. I'm not really sure how to resolve that issue on an apple machine, but on my box, I resolved it by uninstalling the proprietary nvidia graphics drivers on my host, and instead using the open source Nouveau drivers.
I managed to solve it a few minutes ago, doing the other way around :D (installing native drivers on the Docker image)

Code: Select all

apt install kmod mesa-utils
wget http://us.download.nvidia.com/XFree86/Linux-x86_64/390.132/NVIDIA-Linux-x86_64-390.132.run
chmod +x NVIDIA-Linux-x86_64-390.132.run
./NVIDIA-Linux-x86_64-390.132.run -a -N --ui=none --no-kernel-module
glxinfo
I put this information together from different pieces, but mostly this one.

As for running the compiled code on the host, I'd recommend not doing that, as it somewhat defeats the purpose of the docker container. If you're able to resolve the dependencies to run FreeCAD on your host, you're probably better served by just compiling it on the host in the first place :lol: . I think you'll find the performance difference to be not that great between running in, or outside the docker container. I'd certainly pursue the option of resolving the GPU problem, if I were you. But hey, more power to you if you figure out a way that works!
your docker is very useful to keep my host system as clean as possible (I love FreeCAD, but only now I'm starting to hack into it and didn't want to put all that stuff in my system...) and you were right: the easier choice was to figure out the gpu driver part.

In terms of having the most similar experience to the end user by running on the host, in my poorly informed opinion, I think the end user experience of FreeCAD is very dependant on how FreeCAD is packaged and distributed. The visual difference between FreeCAD installed from source, as an appimage, or installed from packages is stark. So if you're looking for the true FreeCAD UX experience, I don't believe such a thing exists.
I disagree: I use FreeCAD at work on a daily basis, and for me, in this context, UX means "how it really works everyday for me in my own computer" (a macBookPro with retina display) more than the install part (which only happens once). And just a few minutes ago I discovered one of those behaviors that annoy me the most: screen resolution in 2x displays (i.e. using the display at half resolution for more clearness to look after my poor getting-older eyes) --> your docker image is doing weird stuff with my display, showing a little tiny cursor, that is normal on my host because I have activated the 200% resolution mode of Ubuntu 20.04, pretty similar to the retina display behavior when using MacOS).

Also, thanks for pointing out that version mismatch! I'll have to come up with a more rigorous method for choosing versions. I typically just go for whatever is newest at the time I'm refreshing the dependencies. :shock:
you're welcome: minor stuff compared to your work. In any case, it would be nice to have the exact same configuration that is used to deploy the (0.19) releases.

best regards!
User avatar
David_D
Posts: 81
Joined: Fri Jun 29, 2018 6:43 am
Location: Christchurch, New Zealand

Re: Ticket #3821 - Docker env build container, now with FEM!

Post by David_D »

iyd2019 wrote: Fri May 22, 2020 10:44 pm I managed to solve it a few minutes ago, doing the other way around :D (installing native drivers on the Docker image)

Code: Select all

apt install kmod mesa-utils
wget http://us.download.nvidia.com/XFree86/Linux-x86_64/390.132/NVIDIA-Linux-x86_64-390.132.run
chmod +x NVIDIA-Linux-x86_64-390.132.run
./NVIDIA-Linux-x86_64-390.132.run -a -N --ui=none --no-kernel-module
glxinfo
I put this information together from different pieces, but mostly this one.
Oooh, very nice, I'll have to look into creating a separate image for nvidia! Pretty busy rn though.
iyd2019 wrote: Fri May 22, 2020 10:44 pm I disagree: I use FreeCAD at work on a daily basis, and for me, in this context, UX means "how it really works everyday for me in my own computer" (a macBookPro with retina display) more than the install part (which only happens once). And just a few minutes ago I discovered one of those behaviors that annoy me the most: screen resolution in 2x displays (i.e. using the display at half resolution for more clearness to look after my poor getting-older eyes) --> your docker image is doing weird stuff with my display, showing a little tiny cursor, that is normal on my host because I have activated the 200% resolution mode of Ubuntu 20.04, pretty similar to the retina display behavior when using MacOS).
Interesting, that's something I hadn't considered. I wonder if there's a better way to transfer host configurations to the docker container... There may be a series of config files on the host that can be mounted to the container in the same place to ensure configurations are transferred.
iyd2019
Posts: 108
Joined: Tue Oct 15, 2019 9:19 am

Re: Ticket #3821 - Docker env build container, now with FEM!

Post by iyd2019 »

Hi there!

I have just finished configuring MacOS to get David's FreeCAD Docker image successfully running in my macbookpro, including GUI!!. It was not straight forward, so here are the steps that maybe could be included in the Compile_on_Docker#Mac_OS_users:

basically you have to follow this guide that David already mentions in his repository, but with a couple extra steps:
  1. Install XQuartz
  2. EXTRA --> update this XQuartz switch to allow OpenGL features enabled at your X11's
  3. Install Docker for Mac
  4. Run XQuartz
  5. Host Machine IP
  6. Running a container (EXTRA: see my launching script)
for step (#2), I found the solution here, that you should write in a terminal and reboot your machine after:

Code: Select all

defaults write org.macosforge.xquartz.X11 enable_iglx -bool true
for step (#6) I leave here my final bash script used to launch David's Docker image with all the tids'n'bits:

docker.sh

Code: Select all

#!/usr/bin/env bash

# config
fc_source=~/projects/FreeCAD/source
fc_build=~/projects/FreeCAD/build
other_files=~/projects/FreeCAD

# mac and XQuartz
IP=$(ifconfig en0 | grep inet | awk '$1=="inet" {print $2}')
xhost + $IP

docker run -it --rm \
-v $fc_source:/mnt/source \
-v $fc_build:/mnt/build \
-v $other_files:/mnt/files \
-e "DISPLAY=$IP:0" \
-e "QT_X11_NO_MITSHM=1" \
-e "QT_DEBUG_PLUGINS=1" \
-v /tmp/.X11-unix:/tmp/.X11-unix \
registry.gitlab.com/daviddaish/freecad_docker_env:latest
note the additional optional line

Code: Select all

-e "QT_DEBUG_PLUGINS=1"
which enables QT debugging (useful to troubleshoot some things, like GL not working :mrgreen:)

note also that it's not necessary to launch XQuartz before launching the script: it's automatically invoqued by the system.

hope this helps someone.
regards!
iyd2019
Posts: 108
Joined: Tue Oct 15, 2019 9:19 am

Re: Ticket #3821 - Docker env build container, now with FEM!

Post by iyd2019 »

sorry, but my last answer is not working properly... :oops:

yes, you get a GUI, but as soon as you try to start a new document, it hangs... I'm looking into it.

any other mac users that could help to test this?

regards!
Menfin
Posts: 4
Joined: Mon Jun 08, 2020 6:43 am

Re: Ticket #3821 - Docker env build container, now with FEM!

Post by Menfin »

Thank's for all this work ...
I'm new on Docker and when I try your tuto https://wiki.freecadweb.org/Compile_on_Docker/fr with the commands :

Code: Select all

fc_source=~/media/xxx/86ff3cff-2537-4ef6-8bd4-d73e652442b0/BackUpGIT/Freecad/freecad-source/
fc_build=~/media/xxx/86ff3cff-2537-4ef6-8bd4-d73e652442b0/BackUpGIT/Freecad/freecad-build/
other_files=~/
and

Code: Select all

docker run -it --rm \
-v $fc_source:/mnt/source \
-v $fc_build:/mnt/build \
-v $other_files:/mnt/files \
-e "DISPLAY" -e "QT_X11_NO_MITSHM=1" -v /tmp/.X11-unix:/tmp/.X11-unix:ro \
registry.gitlab.com/daviddaish/freecad_docker_env:latest
and

Code: Select all

root@b9aaa4749fe8:~# /root/build_script.sh
It doesn't works ... In fact, there's nothing in mnt/source directory. The error message is :

Code: Select all

CMake Error: The source directory "/mnt/source" does not appear to contain CMakeLists.txt.
There's a mistake somewhere but I don't know where, could you help me ?
Post Reply