HomerReid / scuff-em

A comprehensive and full-featured computational physics suite for boundary-element analysis of electromagnetic scattering, fluctuation-induced phenomena (Casimir forces and radiative heat transfer), nanophotonics, RF device engineering, electrostatics, and more. Includes a core library with C++ and python APIs as well as many command-line applications.
http://www.homerreid.com/scuff-em
GNU General Public License v2.0
126 stars 50 forks source link

Docker image #77

Open jfeist opened 8 years ago

jfeist commented 8 years ago

Since I've wanted to play around with Docker for a while already, I decided to try to make a docker image with all the scuff-em programs installed, and it turned out to be pretty straightforward. The image and some very brief documentation is available at https://hub.docker.com/r/jfeist/scuff-em/.

The gist of it is that if you have docker installed, you should be able to run docker run jfeist/scuff-em and it automatically pulls the machine from the docker hub (on the first use), and when running, tells you which subprograms are available (scuff-scatter, scuff-cas3D, etc..).

An actual run should look something like this:

docker run -i -v ${PWD}:/mnt jfeist/scuff-em scatter < args

The Dockerfile needed to build this container is in this repository: https://github.com/jfeist/scuff-em-docker. I have also included a small script there (scuff) that automatically looks for all the valid scuff-xyz programs and runs them, so you can just pass scatter to the container, not scuff-scatter (and running it without arguments lists the available ones). It might be actually useful to include this script in the main scuff repository, not just in the docker image (although I guess it depends on having bash as the shell, as it uses compgen to find valid programs starting with scuff- - there may be a better solution).

jfeist commented 8 years ago

I was in a bit of a rush when writing this earlier, so here are some more comments/ideas:

  1. I think it would be great to provide a Docker image "officially", as it provides a very straightforward way for users to get scuff-em binaries without having to worry about installing the correct dependencies or the configure/make steps. On the other hand, @HomerReid, you don't have to worry about providing binaries for a large set of possible target operating systems.
  2. Along these lines, it would probably make sense to set up some kind of continuous integration, such that whenever you push a commit to github, the docker image gets built automatically and pushed to docker hub. Since we are using Travis CI already, this might be straightforward (Travis CI has some support for docker: https://docs.travis-ci.com/user/docker/).
  3. Right now, I set up the image so that it can only (easily) be used to run the command-line programs, and you don't get access to the "system inside". In this sense, it is just meant to provide a simplified distribution of the binaries. Another option would be to make it into a full-fledged development environment, i.e., give direct access to the shell in the container, to be able to compile C++ codes using scuff-em as a library etc. This would be quite straightforward, basically it would mean to change the default command to just open a shell in the container, instead of only running the presupplied scuff-em programs.
  4. I did not compile python support, so you can not run python scripts using scuff-em inside the container. Again, doing so would be straightforward, but here would also require choosing some python distribution to use. The two choices I see are to use the system python (from ubuntu in this case), which is trivial, but the packages (numpy, scipy, etc) are probably outdated, or not even available, or to use, e.g., anaconda python to provide an independent up-to-date python distribution. In both cases, you would have to choose between Python 2 or 3, although nowadays I would argue strongly for Python 3. Both of these choices (system or anaconda) make the image quite a bit larger (especially for anaconda, I think).

Anyway, I hope you find this useful, @HomerReid. We can discuss the details in "person" to decide how to proceed (if at all), if you want.

HomerReid commented 8 years ago

Thanks Johannes! This is awesome. It sounds like this will be a major improvement to the ease with which new users can get started using the codes. I am going to set aside some time this weekend to learn how it works and update my installation documentation to offer the docker image as a quick-start technique for new users who want to try things out quickly.

The choices you made seem quite reasonable---the kind of user who will benefit most from this will probably be most interested in running the command-line codes, while users interested in the C++ and python interfaces will probably be able to install the code and its dependencies on their own the traditional (hard) way.

Of course the idea of continuous integration is also crucial, since it wouldn't be very useful if the docker image weren't up to date with the latest changes. I will look into that too, and hope my attempts to get it working will also spur me finally to get some real-life working unit tests into the repository so that we can take full advantage of the work you did to enable Travis CI. (Among other things, I really need unit tests soon so that I can merge some significant changes and improvements I have been making on the development branch without fearing they will silently break things behind the scenes.)

Thanks for yet another important contribution to the ongoing viability of SCUFF-EM as a modern package that makes proper use of modern tools like TravisCI and Docker.