spirit-code / spirit

Atomistic Spin Simulation Framework
http://spirit-code.github.io
MIT License
117 stars 52 forks source link

Added a Dockerfile #484

Closed JRSuckert closed 5 years ago

JRSuckert commented 5 years ago

First time contributor checklist

Contributor checklist


Description

I created a Dockerfile that downloads all dependencies and compiles the qt5 Version (at the moment assuming it stays the default CMake option) of the code.

Building the image can be done by going into the spirit directory and running docker build -t spirit . It may also not be a bad idea to add the Docker image to Docker Hub for easier access.

The container can then be run using docker run -ti --rm --device=/dev/dri:/dev/dri -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix spirit which uses the users X11 sessions (assuming that uid and gid of the host are 1000).

I've compiled the Image using both the develop and master branch. The current version compiles the develop branch.

The current size of the image is 712MB, which may be slimmed down by only installing the necessary qt components instead of qt5-default.

coveralls commented 5 years ago

Coverage Status

Coverage remained the same at 84.454% when pulling db20a8262dd66614c78e382506baf14a0da96403 on JRSuckert:feature-docker into 2aa7e071d222ce1dc61211e5b5b6e9377368b21e on spirit-code:develop.

codecov[bot] commented 5 years ago

Codecov Report

Merging #484 into develop will not change coverage. The diff coverage is n/a.

@@           Coverage Diff            @@
##           develop     #484   +/-   ##
========================================
  Coverage    51.43%   51.43%           
========================================
  Files           82       82           
  Lines         9454     9454           
========================================
  Hits          4863     4863           
  Misses        4591     4591
GPMueller commented 5 years ago

Thanks for this PR, this is a very good idea! This should make it a lot easier for some people to run the GUI and especially to distribute it to machines with older compilers etc. Sorry I was too busy to respond sooner.

As I am not familiar with docker, it would be great if you could add a line to the Readme and a short explanation how to run the GUI using docker to docs/Build.

Would it make sense to use the CI to push an image to docker hub whenever a release (i.e. a commit on master) is made?

I have finally tried it out now and unfortunately ran into the following error during the build of the GUI:

Scanning dependencies of target Spirit_UI_CPP_autogen
[ 74%] Automatic MOC for target Spirit_UI_CPP
[ 74%] Built target Spirit_UI_CPP_autogen
[ 74%] Automatic RCC for resources.qrc

AutoRcc subprocess error
------------------------
The rcc process failed to compile
  "/home/developer/spirit/ui-cpp/resources.qrc"
into
  "/home/developer/spirit/build/ui-cpp/Spirit_UI_CPP_autogen/EWIEGA46WW/qrc_resources.cpp"

Command
-------
/usr/lib/qt5/bin/rcc -name resources -o /home/developer/spirit/build/ui-cpp/Spirit_UI_CPP_autogen/EWIEGA46WW/qrc_resources.cpp /home/developer/spirit/ui-cpp/resources.qrc

Output
------
RCC: Error in '/home/developer/spirit/ui-cpp/resources.qrc': Cannot find file 'res/AppIcon32.png'

make[2]: *** [ui-cpp/CMakeFiles/Spirit_UI_CPP.dir/build.make:117: ui-cpp/Spirit_UI_CPP_autogen/EWIEGA46WW/qrc_resources.cpp] Error 1
make[1]: *** [CMakeFiles/Makefile2:817: ui-cpp/CMakeFiles/Spirit_UI_CPP.dir/all] Error 2
make: *** [Makefile:163: all] Error 2
The command '/bin/sh -c cd $HOME/spirit &&     mkdir -p build &&     cd build &&     cmake .. &&     cd .. &&     ./make.sh' returned a non-zero code: 2

It looks like the problem described here https://stackoverflow.com/a/52084936/4069571 but appears on my OSX machine even when using docker 18.09, so I'm not sure how it could be avoided.