Building Docker Image with Pre-configured AiiDA Computer?

Hi @Daniel_Marchand , great that you already started using the new image and thanks @danielhollas for pining for me.

Here is an example (Add plugin specific docker image by unkcpz · Pull Request #230 · aiidateam/aiida-sssp-workflow · GitHub) of how I prepared a plugin-specific docker image by installing the plugin and set the caching for quantumespresso.pw.

My current base is aiidateam/aiida-core-with-services:sha-56f9f6c , which, at the time of writing, is the latest (or almost the latest) build available.

This image will have a tag after we release aiida-core==2.5.0, it will then have the tag latest which always points to the stable released version of aiida-core. Now there is aiidateam/aiida-core-with-services:edge which points to the code base of main branch of the aiida-core. It is okay if you use sha-xxx tag which is associated with a commit in the main branch and, therefore, is more static than edge. But please note that you can update your Dockerfile and use the latest or version number when we make the release.

  1. Is there a recommended way to set up and configure an AiiDA computer within a Docker image during its build?

It is not recommended to configure the computer during the build phase. The reason is mainly that it makes more sense the computer/code is set after the aiida profile is ready, which happened during the “runtime”.
Here is the lifecycle of the container and the order of services running when the first time the container is running (aiida-core-with-services as an example):

  • When the container just started no services are running. But the image has aiida-core package and PostgreSQL and RMQ installed. This is everything that happened in the Dockerfile, after every other thing is started/running as “services” by using the s6-overlay which is a services management dedicated to the container.
  • PostgreSQL DB will be initialized and start the service.
  • RabbitMQ services will start.
  • After these two services are ready if the AiiDA profile is not detected in the user’s home the profile will be created.

The decision was made from the experience we got from AiiDAlab image that the user’s home is mounted to the persistent resource so the data would be lost if the container is wiped. It thus requires checking that the mounted storage has the AiiDA profile and will create if not.

  1. Looking into the future, do you think there’s potential value in providing mechanisms (or official images) to ship pre-configured AiiDA installations for certain workflows or use cases?

Thanks for bringing this up. Sure it is.
Although the computer/code setup has to happen after the profile is ready, the installation of plugins from pip is definitely feasible in the build phase. If you use the aiidateam/aiida-core-with-services as the base image in your Dockerfile and install your workflow/plugins from pip after the container starts the plugin will be ready.
We also have a plan to ship for example the aiida-quantumespresso image that has a plugin that can be used out-of-box, and also consider to have it in the plugin cookie-cutter.

  1. Has anyone successfully achieved this and can share their approach?

It is surely doable, please have a look at how we do it for aiida-quantumespresso plugin Customised docker image for running calculation out-of-box by unkcpz · Pull Request #981 · aiidateam/aiida-quantumespresso · GitHub.

3 Likes