Skip to content
Snippets Groups Projects
Commit 070eede1 authored by B13nch3n's avatar B13nch3n
Browse files

Describe running the container as app

parent 2b63d804
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](
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 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.
This section describes four use cases of the Docker container (including build instructions per use case) but starts with a short primer of what is common to all scenarios described here.
### Prerequisites
......@@ -24,13 +24,13 @@ $ cd modelcif-converters.git/projects
$
```
Since the Docker container will run as a dedicated, non-root user, it is advisable to create this user with the ID of your local user. That way, file permission issues will be avoided. Get your user ID with the following command and note it down - it will be needed in the build steps:
Since the Docker container will run a dedicated, non-root user internally, it is advisable to create this user with the ID of your local user. That way, file permission issues will be avoided. Get your user ID with the following command and write it down - it will be needed in the build steps:
```terminal
$ whoami
localuser
$ id
uid=(localuser) ...
uid=1234(localuser) ...
$
```
......@@ -48,7 +48,7 @@ This use case comes closest to having a Docker container that works like a [Mode
- turn into a [Singularity](https://sylabs.io/singularity/) image
and it works out of the box.
and the conversion to ModelCIF 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/).
......@@ -58,10 +58,18 @@ The following command will build a Docker image named `converter` (with tag `lat
```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 .
$ DOCKER_BUILDKIT=1 docker build -f docker/Dockerfile --build-arg MMCIF_USER_ID=1234 --build-arg CONVERTERSCRIPT=USDA-ASFVG/translate2modelcif.py -t converter:latest .
$
```
After building the Docker image, its time to run the translation command. To do so, we need to make the data available inside the Docker container. This is achieved by [mounting]((https://docs.docker.com/storage/bind-mounts/)) the model-data directory into the Docker container. In the following example, the local `/home/user/models` directory of the host machine is made available as `/data` inside the container. So the command send to `docker run` has to use `/data` as it is executed inside the container:
```terminal
$ docker run --rm -v /home/user/models:/data -t converter:latest convert2modelcif /data/ /data/proteome_accessions.csv
$
```
<!--
- Do single example call
......
#!/bin/bash
## exit immediately on commands with a non-zero exit status.
set -euo pipefail
## When started without any arguments, "-h", "--help", "-help" or "help", print
## usage.
if [ $# -eq 0 ] || [ x$1 == x"-h" ] || [ x$1 == x"--help" ] ||
[ x$1 == x"-help" ] || [ x$1 == x"help" ]; then
echo " ModelCIF file converter"
echo "----------------------------------------"
echo "Provided by SWISS-MODEL / Schwede group"
echo "(swissmodel.expasy.org / schwedelab.org)"
echo ""
/usr/local/bin/convert2modelcif --help
exit 1
fi
if [ x$1 == x"convert2modelcif" ] || [ x$1 == x"2cif" ]; then
shift
# take over the process, make translate2modelcif run on PID 1
exec /usr/local/bin/convert2modelcif $@
exit $?
fi
exec "$@"
# LocalWords: euo pipefail eq Schwede schwedelab mmcif fi
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