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

Having trouble installing or compiling FreeCAD? Get help here.
User avatar
kkremitzki
Posts: 1986
Joined: Thu Mar 03, 2016 9:52 pm
Location: Texas

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

Postby kkremitzki » Sun Mar 15, 2020 4:34 am

I sent a message to support about ownership of the freecad org. I wouldn't be surprised if I created it a while back and just lost the credentials for it.
Like my FreeCAD work? I'd appreciate any level of support via Patreon, Liberapay, or PayPal! Read more about what I do at my blog.
User avatar
David_D
Posts: 69
Joined: Fri Jun 29, 2018 6:43 am
Location: Christchurch, New Zealand

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

Postby David_D » Sun Mar 15, 2020 5:46 am

kkremitzki wrote:
Sun Mar 15, 2020 4:34 am
I sent a message to support about ownership of the freecad org. I wouldn't be surprised if I created it a while back and just lost the credentials for it.
Nice, thank you.
Kunda1 wrote:
Sat Mar 14, 2020 5:17 pm
@David_D have you had any experience spinning up Docker with a specific patch or pull request? There's currently a bottleneck in this area when it comes to development workflow, what I've observed is entry level developers have a hard time getting past git, building, compiling and running FC. We have something for app images, but it's still not very clear what the workflow is to generate an app image especially one from a pull request that requires certain libraries installed.

So use case would be, a developer looking through the FC GitHub repo, seeing a pool request that they're interested in testing, getting the URL or the raw .diff URL of the PR, and then throwing it into Docker. Or having some sort of Docker flag that allows for said URL to be used.
Yes, the docker container should would out of the box for this use case. As a proof, I've just chosen a pull request at random, checked it out using this stackoverflow advice, and build their pull request version of FreeCAD. It seems to function fine, and the build succeeded without errors.

Counter to your requested use case, the user would need to handle the git part of that process themselves. This is because when using this docker image, git should operate outside the docker container because the docker container has a very short lifespan. At most, the container would only last as long as a single development session. This is fine, because the docker container can launch anew in less than a second, but all state is lost within the docker container, when it is killed. Consequently, linking the git workflow to the docker container would be a bit self defeating. You'd need to pull the repo each time you start developing.

As an alternative, I'm sure we could write a light weight bash script to handle the git pulling/checking out that you've described there. Alternatively, alternatively, we could provide comprehensive documentation on this process instead. While you know better than I do, I would suspect the "building and dependency management" part of that use case you've described is the harder part of the on-boarding process, when compared to the git part of the process. Wouldn't the git part be mostly dependant on skills easily transferable from other development projects?
kizbitz
Posts: 2
Joined: Mon Mar 23, 2020 10:06 am
Contact:

Docker Hub 'freecad' account

Postby kizbitz » Mon Mar 23, 2020 9:53 pm

Hi Admins,

Please DM me if you're interested in taking ownership of the Docker Hub account 'freecad'.

Thanks,
User avatar
Kunda1
Posts: 7329
Joined: Thu Jan 05, 2017 9:03 pm

Re: Docker Hub 'freecad' account

Postby Kunda1 » Mon Mar 23, 2020 9:57 pm

kizbitz wrote:
Mon Mar 23, 2020 9:53 pm
Hi Admins,

Please DM me if you're interested in taking ownership of the Docker Hub account 'freecad'.

Thanks,
Merged thread in to per-existing thread.

Thanks. We're interested.
@kkremitzki is our infrastructure guy.
Want to contribute back to FC? Checkout:
#lowhangingfruit | Use the Source, Luke. | How to Help FreeCAD | How to report FC bugs and features
kizbitz
Posts: 2
Joined: Mon Mar 23, 2020 10:06 am
Contact:

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

Postby kizbitz » Mon Mar 23, 2020 10:10 pm

@kkremitzki - If you could DM me I'll work through the transfer with you.

Thanks
User avatar
Kunda1
Posts: 7329
Joined: Thu Jan 05, 2017 9:03 pm

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

Postby Kunda1 » 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:
Want to contribute back to FC? Checkout:
#lowhangingfruit | Use the Source, Luke. | How to Help FreeCAD | How to report FC bugs and features
User avatar
kryptokommunist
Posts: 28
Joined: Fri Mar 27, 2020 6:29 pm
Location: Berlin
Contact:

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

Postby kryptokommunist » Fri Apr 10, 2020 12:36 am

Hey there guys, very cool project! For me on Ubuntu 16.04 it only works if I run a modified version of the command in the Wiki:

Code: Select all

docker run -it --rm \
-v $fc_source:/mnt/source \
-v $fc_build:/mnt/build \
-v $other_files:/mnt/files \
--network host -e "DISPLAY" -e "QT_X11_NO_MITSHM=1" -v /tmp/.X11-unix:/tmp/.X11-unix:ro \
registry.gitlab.com/daviddaish/freecad_docker_env:latest
Without the --network host it won't run and log that FreeCAD can't connect to the DISPLAY for me. I got the solution here. I don't know exactly why this is needed, but the command shares the host network with the container (link).
User avatar
David_D
Posts: 69
Joined: Fri Jun 29, 2018 6:43 am
Location: Christchurch, New Zealand

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

Postby David_D » Sun Apr 12, 2020 1:08 am

kryptokommunist wrote:
Fri Apr 10, 2020 12:36 am
Hey there guys, very cool project! For me on Ubuntu 16.04 it only works if I run a modified version of the command in the Wiki:

Code: Select all

docker run -it --rm \
-v $fc_source:/mnt/source \
-v $fc_build:/mnt/build \
-v $other_files:/mnt/files \
--network host -e "DISPLAY" -e "QT_X11_NO_MITSHM=1" -v /tmp/.X11-unix:/tmp/.X11-unix:ro \
registry.gitlab.com/daviddaish/freecad_docker_env:latest
Without the --network host it won't run and log that FreeCAD can't connect to the DISPLAY for me. I got the solution here. I don't know exactly why this is needed, but the command shares the host network with the container (link).

Ah, sorry you ran into such a strange problem. I'll have to look into this. I'd be hesitant to slap that addition right into the standard command in the readme, because it seems like something that the security minded would think twice about. Perhaps I'll include it as a note. Anyway, thanks for the feedback, I hope you find the project useful.
User avatar
kryptokommunist
Posts: 28
Joined: Fri Mar 27, 2020 6:29 pm
Location: Berlin
Contact:

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

Postby kryptokommunist » Wed Apr 15, 2020 5:51 am

David_D wrote:
Sun Apr 12, 2020 1:08 am
Anyway, thanks for the feedback, I hope you find the project useful.
It was extremely valuable to me. Since I‘m a new to FreeCAD this saved me so much time on my Ubuntu 16.04 machine. All the compile guides in the Wiki failed me with my setup so far. So thanks for your solution!
etrombly
Posts: 80
Joined: Thu Dec 05, 2019 6:50 pm

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

Postby etrombly » 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. On whatever computer is going to be helping compile use this dockerfile:

Code: Select all

FROM registry.gitlab.com/daviddaish/freecad_docker_env:latest

RUN chmod 777 /tmp && \
  apt-get update && \
  apt-get install -y \
    distcc g++-6 gcc-6 && \
  rm -rf /var/lib/apt/lists/* 

# This is the operations port
EXPOSE 3632
# This is the statistics port
EXPOSE 3633

USER distccd

ENTRYPOINT /usr/bin/distccd --no-detach --daemon --stats --log-level info --log-stderr $OPTIONS
when you run it you have to pass in the env $OPTIONS="--allow ip_range" the ip range is for clients that are allowed to connect. Also you need to forward the exposed ports. Then on your dev machine use a dockerfile like this:

Code: Select all

FROM registry.gitlab.com/daviddaish/freecad_docker_env:latest

RUN chmod 777 /tmp && \
  apt-get update && \
  apt-get install -y \
  distcc && \
  rm -rf /var/lib/apt/lists/*

COPY hosts /etc/distcc/hosts
COPY build_debug.sh /root/build_debug.sh
the hosts file is:

Code: Select all

# As described in the distcc manpage, this file can be used for a global
# list of available distcc hosts.
#
# The list from this file will only be used, if neither the
# environment variable DISTCC_HOSTS, nor the file $HOME/.distcc/hosts
# contains a valid list of hosts.
#
# Add a list of hostnames in one line, seperated by spaces, here.
localhost 192.168.0.99
put whatever ip's the docker distcc server is running on. build_debug is just the regular build script with:

Code: Select all

-D CMAKE_C_COMPILER_LAUNCHER=distcc -D CMAKE_CXX_COMPILER_LAUNCHER=distcc \
added to the cmake options (I called it debug because I'm also using it for debug builds, you could call it build_distcc or whatever).