Skip to content
Snippets Groups Projects
Commit 7989bb14 authored by Bienchen's avatar Bienchen
Browse files

Describe how to build the Docker image.

parent b60518b9
No related branches found
No related tags found
No related merge requests found
......@@ -11,7 +11,7 @@ A specific project's translation script can be executed either in an app like ma
This is a quick tour on how to build and run the Docker container through different scenarios. This is not a lecture on containerisation in general, nor Linux/ Unix, shell scripting or programming. But if you encounter a specific problem, feel free to ping the [MA team](https://modelarchive.org/contact).
This section describes three use cases of the Docker container (including a build-how to per use case) but starts with a short primer of what is common to all scenarios described here.
This section describes four use cases of the Docker container (including a build-how to per use case) but starts with a short primer of what is common to all scenarios described here.
### Prerequisites
......@@ -30,25 +30,51 @@ Since the Docker container will run as a dedicated, non-root user, it is advisab
$ whoami
localuser
$ id
uid=12345(localuser) ...
uid=(localuser) ...
$
```
Look for the `uid` in the output of `id`. In the example above, `12345` is the ID of user `localuser`, currently logged in and executing the commands.
Look for the `uid` in the output of `id`. In the example above, `1234` is the ID of user `localuser`, currently logged in and executing the commands.
One last thing that is needed for the example runs of the Docker container is data. For simplicity, we assume that a directory `/home/user/models` exists on the local computer executing a converter, full of modelling data.
### Run a fixed converter from within the Docker container (app-like)
This use case comes closest to having a Docker container that works like a [ModelCIF](https://mmcif.wwpdb.org/dictionaries/mmcif_ma.dic/Index/) converter app, that you can
- hand over to others
- send to a compute cluster
- turn into a [Singularity](https://sylabs.io/singularity/) image
and it works out of the box.
The idea is to copy a translation script from one of the [projects](projects/) into the Docker image along with all the software needed to run it. That enables you to start the script as a command with [`docker run`](https://docs.docker.com/engine/reference/run/).
The whole build of the Docker image, including installing necessary software and copying the translation script, is covered by our [Dockerfile](./Dockerfile). You just need to specify the translation script by [build time argument](https://docs.docker.com/engine/reference/commandline/build/#set-build-time-variables---build-arg) `CONVERTERSCRIPT` during [`docker build`](https://docs.docker.com/engine/reference/commandline/build/). By default, the translation script is renamed to `convert2modelcif` to be called as a command. This can be overwritten using build time argument `CONVERTERCMD`. There is also an alias `2cif` to the converter command, which is immutable.
The following command will build a Docker image named `converter` (with tag `latest`). The translation script will be copied from [`USDA-ASFVG/translate2modelcif.py`](projects/USDA-ASFVG/translate2modelcif.py) and made available as `convert2modelcif` in the Docker image/ `docker run`. By `MMCIF_USER_ID`, we use UID `1234` for the internal user of the Docker image, so mounted files have the right owner inside and outside of the Docker container (assuming the example user from above). Pay attention to the alternative Dockerfile location specified by `-f docker/Dockerfile`, as we are calling `docker build` from the [projects](projects/) subdirectory to get the right build context:
```terminal
$ # DOCKER_BUILDKIT=1 is only needed for older versions of Docker.
$ DOCKER_BUILDKIT=1 docker build -f docker/Dockerfile --build-arg MMCIF_USER_ID=1234 --build-arg CONVERTERSCRIPT=USDA-ASFVG/translate2modelcif.py -t converter .
$
```
<!--
- Do single example call
- show how to loop
- all build use local UID!
1. App like
- special build
- own run command
2. Local copy
- works with every build
- own run command
- still has a default script installed as in 1.
- can be overwritten by mounting
3. Interactive shell
- works with every build
- most complicated run bit
......@@ -59,12 +85,11 @@ One last thing that is needed for the example runs of the Docker container is da
<!--
build:
- go into repo projects dir
- execute: docker build -f docker/Dockerfile -t mmcifconverter:20220427 .
- execute: docker build -f docker/Dockerfile -t converter .
- explain how to install a dedicated converter script in the container
- mention how to change user
- mention dev stuff
- mention script is copied to a unified name for the container to work with a single entrypoint script
- mention .dockerignore in projects readme, like when adding projects consider..., add a reference to it, here
run interactive shell for development:
- make sure files exist: /Users/stefan/Projects/ma-converters.git/projects/pointmutations-haddock/.docker-bash-history
......@@ -73,5 +98,6 @@ docker run --rm -i -v /Users/stefan/.bash_profile:/home/mmcif/.bash_profile -v /
-->
<!-- LocalWords: TOC modelcif cd whoami localuser uid
<!-- LocalWords: TOC modelcif cd whoami localuser uid arg CONVERTERSCRIPT
LocalWords: CONVERTERCMD cif ASFVG BUILDKIT
-->
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment