Skip to content

Commit

Permalink
Updated README
Browse files Browse the repository at this point in the history
  • Loading branch information
bilke committed Mar 29, 2019
1 parent d4ef2da commit 39d545f
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 32 deletions.
71 changes: 44 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,35 +7,29 @@
```bash
virtualenv ~/.venv/ogs-container-maker
source ~/.venv/ogs-container-maker/bin/activate
pip install --upgrade requests hpccm
pip install ogscm
```

### Generate container definition

```bash
hpccm --recipe recipes/ogs-builder.py > Dockerfile
hpccm --recipe recipes/ogs-builder.py --format singularity > Singularity

# With user options, Use : instead of = in cmake_args!
hpccm --recipe recipes/ogs-builder.py --format singularity \
--userarg ompi=2.1.3 cmake_args="-DOGS_BUILD_PROCESSES:GroundwaterFlow"
$ ogscm
Creating 1 image definition(s)...
Created definition _out/docker/ubuntu_17.10/ogs-4c7de6a4/serial/conan/cmake-d41d8cd9/Dockerfile

# With user options
$ ogscm --format singularity --ompi 2.1.3 --cmake_args ' -DOGS_BUILD_PROCESSES=GroundwaterFlow'
Creating 1 image definition(s)...
Created definition _out/singularity/ubuntu_17.10/ogs-4c7de6a4/openmpi-2.1.3/conan/cmake-fde09bf7/Singularity.de
```

### Build image

```
docker build -t ogs-ompi-2.1.3 -f Dockerfile .
sudo singularity build ogs-ompi-2.1.3.sif Singularity
```
Add the `--build`-flag.

Convert Docker image to Singularity image:

```
mkdir _out
docker run -v /var/run/docker.sock:/var/run/docker.sock \
-v $PWD/_out:/output --privileged -t --rm \
singularityware/docker2singularity ogs-ompi-2.1.3
```
Add the `--convert`-flag (requires Singularity 3.x).

### Run

Expand All @@ -45,7 +39,7 @@ docker run --it --rm ogs-ompi-2.1.3
ogs --version
```

```
```bash
singularity shell ogs-ompi-2.1.3.sif
# in container:
ogs --version
Expand All @@ -64,26 +58,30 @@ python build.py --ogs ufz/ogs@master --ompi 2.1.2 3.1.2 --build --convert
Check help for more options:

```bash
$ python build --help
usage: build.py [-h] [--recipe RECIPE] [--out OUT] [--print]
[--format {docker,singularity} {docker,singularity}]
[--pm [{system,conan} [{system,conan} ...]]]
[--ompi [OMPI [OMPI ...]]] [--ogs [OGS [OGS ...]]]
[--cmake_args [CMAKE_ARGS [CMAKE_ARGS ...]]] [--build]
[--upload] [--convert] [--runtime-only]
$ ogscm --help
usage: ogscm [-h] [--recipe RECIPE] [--out OUT] [--file FILE] [--print]
[--format [{docker,singularity} [{docker,singularity} ...]]]
[--pm [{system,conan} [{system,conan} ...]]]
[--ompi [OMPI [OMPI ...]]] [--ogs [OGS [OGS ...]]]
[--cmake_args [CMAKE_ARGS [CMAKE_ARGS ...]]] [--build] [--upload]
[--registry REGISTRY] [--convert] [--runtime-only]
[--base_image BASE_IMAGE] [--clang] [--gui] [--docs] [--jenkins]
[--cvode] [--cppcheck] [--iwyy] [--gcovr] [--dev]
[--compiler_version COMPILER_VERSION]

Generate container image definitions.

optional arguments:
-h, --help show this help message and exit
--recipe RECIPE HPCCM recipe (default: recipes/ogs-builder.py)
--out OUT Output directory (default: _out)
--file FILE Overwrite output recipe file name (default: )
--print, -P Print the definition to stdout (default: False)

Combinatorial options:
All combinations of the given options will be generated

--format {docker,singularity} {docker,singularity}
--format [{docker,singularity} [{docker,singularity} ...]]
--pm [{system,conan} [{system,conan} ...]]
Package manager to install third-party dependencies
(default: ['conan'])
Expand All @@ -97,14 +95,33 @@ Combinatorial options:
--cmake_args [CMAKE_ARGS [CMAKE_ARGS ...]]
CMake argument sets have to be quoted and **must**
start with a space. e.g. --cmake_args ' -DFIRST=TRUE
-DFOO=BAR' ' -DSECOND=TRUE' (default: )
-DFOO=BAR' ' -DSECOND=TRUE' (default: [''])

Image build options:
--build, -B Build the images from the definition files (default:
False)
--upload, -U Upload Docker image to registry (default: False)
--registry REGISTRY The docker registry the image is tagged and uploaded
to. (default: registry.opengeosys.org/ogs/ogs)
--convert, -C Convert Docker image to Singularity image (default:
False)
--runtime-only, -R Generate multi-stage Dockerfiles for small runtime
images (default: False)

Additional options:
--base_image BASE_IMAGE
The base image. 'centos:7' is supported too. (default:
ubuntu:17.10)
--clang Use clang instead of gcc (default: False)
--gui Builds the GUI (Data Explorer) (default: False)
--docs Setup documentation requirements (Doxygen) (default:
False)
--jenkins Setup Jenkins slave (default: False)
--cvode Install and configure with cvode (default: False)
--cppcheck Install cppcheck (default: False)
--iwyy Install include-what-you-use (default: False)
--gcovr Install gcovr (default: False)
--dev Installs development tools (vim, gdb) (default: False)
--compiler_version COMPILER_VERSION
Compiler version. (default: )
```
11 changes: 6 additions & 5 deletions ogscm/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,11 +189,6 @@ def main(): # pragma: no cover
img_file += '-dev'
docker_repo = img_file
img_file += '.sif'
if __format == 'singularity':
subprocess.run(f"sudo `which singularity` build {images_out_dir}/{img_file} "
f"{definition_file}", shell=True)
subprocess.run(f"sudo chown $USER:$USER {images_out_dir}/{img_file}", shell=True)
continue

tag = f"{args.registry}/{docker_repo}"

Expand Down Expand Up @@ -370,6 +365,12 @@ def main(): # pragma: no cover
if not args.build:
continue

if __format == 'singularity':
subprocess.run(f"sudo `which singularity` build {images_out_dir}/{img_file} "
f"{definition_file}", shell=True)
subprocess.run(f"sudo chown $USER:$USER {images_out_dir}/{img_file}", shell=True)
continue

build_cmd = (f"docker build --build-arg OGS_COMMIT_HASH={commit_hash} "
f"-t {tag} .")
print(f"Running: {build_cmd}")
Expand Down

0 comments on commit 39d545f

Please sign in to comment.