From d5673803fd80ca1482d77f8bf67663303d8f6d0b Mon Sep 17 00:00:00 2001 From: Leopold Talirz Date: Sun, 5 Mar 2023 16:36:47 +0100 Subject: [PATCH 01/17] add devcontainer --- .devcontainer/devcontainer.json | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .devcontainer/devcontainer.json diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000000..6793795fa5 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,6 @@ +{ + "build": { + // Path is relataive to the devcontainer.json file. + "dockerfile": "../Dockerfile" + } +} \ No newline at end of file From e4d012faa2f582bd0cceec131ca06517d998004c Mon Sep 17 00:00:00 2001 From: Leopold Talirz Date: Sun, 5 Mar 2023 16:49:49 +0100 Subject: [PATCH 02/17] add further setup --- .devcontainer/devcontainer.json | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 6793795fa5..3659646274 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -2,5 +2,9 @@ "build": { // Path is relataive to the devcontainer.json file. "dockerfile": "../Dockerfile" - } + }, + "postCreateCommand": [ + "pip install ./aiida-core[test,pre-commit]", + "/opt/configure-aiida.sh" + ] } \ No newline at end of file From 0604d216e2a20a05489de0185916e2c17d1b3335 Mon Sep 17 00:00:00 2001 From: Leopold Talirz Date: Sun, 5 Mar 2023 16:08:25 +0000 Subject: [PATCH 03/17] wait for postCreateCommand --- .devcontainer/devcontainer.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 3659646274..1fe1917d15 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -4,7 +4,8 @@ "dockerfile": "../Dockerfile" }, "postCreateCommand": [ - "pip install ./aiida-core[test,pre-commit]", + "pip install ./aiida-core[tests,pre-commit]", "/opt/configure-aiida.sh" - ] + ], + "waitFor": "postCreateCommand" } \ No newline at end of file From 293c6628f34bd97c651a22622cb16675f8186cb2 Mon Sep 17 00:00:00 2001 From: Leopold Talirz Date: Sun, 5 Mar 2023 16:56:59 +0000 Subject: [PATCH 04/17] proper use of postCreate/postStart --- .devcontainer/devcontainer.json | 22 +++++++++++++--------- .devcontainer/post_create.sh | 3 +++ 2 files changed, 16 insertions(+), 9 deletions(-) create mode 100644 .devcontainer/post_create.sh diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 1fe1917d15..ab2e805288 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,11 +1,15 @@ { - "build": { - // Path is relataive to the devcontainer.json file. - "dockerfile": "../Dockerfile" - }, - "postCreateCommand": [ - "pip install ./aiida-core[tests,pre-commit]", - "/opt/configure-aiida.sh" - ], - "waitFor": "postCreateCommand" + "image": "aiidateam/aiida-core:main", + // "build": { + // // Path is relative to the devcontainer.json file. + // // "dockerfile": "../Dockerfile" + // }, + "postCreateCommand": "bash ./.devcontainer/post_create.sh", + "postStartCommand": "/sbin/my_init", + "waitFor": "postCreateCommand", + "customizations": { + "vscode": { + "extensions": ["ms-python.python", "eamodio.gitlens"] + } + } } \ No newline at end of file diff --git a/.devcontainer/post_create.sh b/.devcontainer/post_create.sh new file mode 100644 index 0000000000..6e31c71d9a --- /dev/null +++ b/.devcontainer/post_create.sh @@ -0,0 +1,3 @@ + #!/bin/bash + # Add test dependencies (not installed in image) + pip install .[tests,pre-commit] \ No newline at end of file From 69a08411389089729745595531bd8b3275ce00ff Mon Sep 17 00:00:00 2001 From: Leopold Talirz Date: Sun, 5 Mar 2023 19:18:15 +0000 Subject: [PATCH 05/17] move to docker-compose --- .devcontainer/devcontainer.json | 7 +++-- .devcontainer/docker-compose.yaml | 49 +++++++++++++++++++++++++++++++ .docker/opt/configure-aiida.sh | 3 +- 3 files changed, 55 insertions(+), 4 deletions(-) create mode 100644 .devcontainer/docker-compose.yaml diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index ab2e805288..0e9456aef9 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,12 +1,13 @@ { - "image": "aiidateam/aiida-core:main", + "dockerComposeFile": "docker-compose.yaml", + "service": "aiida", // "build": { // // Path is relative to the devcontainer.json file. // // "dockerfile": "../Dockerfile" // }, "postCreateCommand": "bash ./.devcontainer/post_create.sh", - "postStartCommand": "/sbin/my_init", - "waitFor": "postCreateCommand", + "postStartCommand": "/opt/configure-aiida.sh", + "waitFor": "postStartCommand", "customizations": { "vscode": { "extensions": ["ms-python.python", "eamodio.gitlens"] diff --git a/.devcontainer/docker-compose.yaml b/.devcontainer/docker-compose.yaml new file mode 100644 index 0000000000..e6e02f1a9c --- /dev/null +++ b/.devcontainer/docker-compose.yaml @@ -0,0 +1,49 @@ +version: '3.4' + +services: + + rabbitmq: + image: rabbitmq:3.8.3-management + container_name: aiida-rabbitmq + environment: + RABBITMQ_DEFAULT_USER: guest + RABBITMQ_DEFAULT_PASS: guest + ports: + - '5672:5672' + - '15672:15672':w + + healthcheck: + test: rabbitmq-diagnostics -q ping + interval: 30s + timeout: 30s + retries: 5 + networks: + - aiida-rmq + + postgresql: + image: postgres:12 + container_name: aiida-postgres + ports: + - '5432:5432' + networks: + - aiida-rmq + # volumes: + # - db-volume:/var/lib/postgresql/data + + aiida: + image: "aiidateam/aiida-core:main" + container_name: aiida-core + env: + DB_HOST: postgresql + BROKER_HOST: rabbitmq + # volumes: + # - db-volume:/var/lib/assets + depends_on: + - rabbitmq + - postgresql + +# volumes: +# db-volume: + +networks: + aiida-rmq: \ No newline at end of file diff --git a/.docker/opt/configure-aiida.sh b/.docker/opt/configure-aiida.sh index 371fe3ec0a..822578b4ad 100755 --- a/.docker/opt/configure-aiida.sh +++ b/.docker/opt/configure-aiida.sh @@ -29,7 +29,8 @@ if [[ ${NEED_SETUP_PROFILE} == true ]]; then --first-name "${USER_FIRST_NAME}" \ --last-name "${USER_LAST_NAME}" \ --institution "${USER_INSTITUTION}" \ - --db-backend "${AIIDADB_BACKEND}" + --db-host "${DB_HOST:localhost}" \ + --broker-host "${BROKER_HOST:localhost}" # Setup and configure local computer. computer_name=localhost From cc2ef1768b9ceaf52e47c2c1bf79e95ee42a77d5 Mon Sep 17 00:00:00 2001 From: Leopold Talirz Date: Sun, 5 Mar 2023 19:21:51 +0000 Subject: [PATCH 06/17] rename docker-compose --- .devcontainer/devcontainer.json | 2 +- .devcontainer/{docker-compose.yaml => docker-compose.yml} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename .devcontainer/{docker-compose.yaml => docker-compose.yml} (100%) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 0e9456aef9..5791e2152b 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,5 +1,5 @@ { - "dockerComposeFile": "docker-compose.yaml", + "dockerComposeFile": "docker-compose.yml", "service": "aiida", // "build": { // // Path is relative to the devcontainer.json file. diff --git a/.devcontainer/docker-compose.yaml b/.devcontainer/docker-compose.yml similarity index 100% rename from .devcontainer/docker-compose.yaml rename to .devcontainer/docker-compose.yml From 18892e869ad29f78e1d3454a89d0f466c0cffcf3 Mon Sep 17 00:00:00 2001 From: Leopold Talirz Date: Sun, 5 Mar 2023 19:26:45 +0000 Subject: [PATCH 07/17] fixes to docker-compose --- .devcontainer/docker-compose.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.devcontainer/docker-compose.yml b/.devcontainer/docker-compose.yml index e6e02f1a9c..2ec78c52e2 100644 --- a/.devcontainer/docker-compose.yml +++ b/.devcontainer/docker-compose.yml @@ -10,7 +10,7 @@ services: RABBITMQ_DEFAULT_PASS: guest ports: - '5672:5672' - - '15672:15672':w + - '15672:15672' healthcheck: test: rabbitmq-diagnostics -q ping @@ -33,7 +33,7 @@ services: aiida: image: "aiidateam/aiida-core:main" container_name: aiida-core - env: + environment: DB_HOST: postgresql BROKER_HOST: rabbitmq # volumes: From d16eb8323aec2a3ed8a88c6d7c8e090ac64a8c4c Mon Sep 17 00:00:00 2001 From: Leopold Talirz Date: Sun, 5 Mar 2023 19:39:33 +0000 Subject: [PATCH 08/17] fixes to docker-compose --- .devcontainer/devcontainer.json | 7 +------ .devcontainer/docker-compose.yml | 3 +++ .devcontainer/post_create.sh | 10 +++++++++- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 5791e2152b..e09b14d01d 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,13 +1,8 @@ { "dockerComposeFile": "docker-compose.yml", "service": "aiida", - // "build": { - // // Path is relative to the devcontainer.json file. - // // "dockerfile": "../Dockerfile" - // }, "postCreateCommand": "bash ./.devcontainer/post_create.sh", - "postStartCommand": "/opt/configure-aiida.sh", - "waitFor": "postStartCommand", + "waitFor": "postCreateCommand", "customizations": { "vscode": { "extensions": ["ms-python.python", "eamodio.gitlens"] diff --git a/.devcontainer/docker-compose.yml b/.devcontainer/docker-compose.yml index 2ec78c52e2..9842b1726c 100644 --- a/.devcontainer/docker-compose.yml +++ b/.devcontainer/docker-compose.yml @@ -33,11 +33,14 @@ services: aiida: image: "aiidateam/aiida-core:main" container_name: aiida-core + user: aiida environment: DB_HOST: postgresql BROKER_HOST: rabbitmq # volumes: # - db-volume:/var/lib/assets + networks: + - aiida-rmq depends_on: - rabbitmq - postgresql diff --git a/.devcontainer/post_create.sh b/.devcontainer/post_create.sh index 6e31c71d9a..4d34fe54f7 100644 --- a/.devcontainer/post_create.sh +++ b/.devcontainer/post_create.sh @@ -1,3 +1,11 @@ #!/bin/bash + set -e + # Add test dependencies (not installed in image) - pip install .[tests,pre-commit] \ No newline at end of file + pip install .[tests,pre-commit] + +# add aiida user +/etc/my_init.d/10_create-system-user.sh + +# configure aiida +/opt/configure-aiida.sh \ No newline at end of file From 7176fb4780f339c46be25c55633d024f3fac6e2c Mon Sep 17 00:00:00 2001 From: Leopold Talirz Date: Sun, 5 Mar 2023 19:45:40 +0000 Subject: [PATCH 09/17] back to Dockerfile --- .devcontainer/Dockerfile | 7 +++++++ .devcontainer/docker-compose.yml | 5 ++++- .devcontainer/post_create.sh | 6 ------ 3 files changed, 11 insertions(+), 7 deletions(-) create mode 100644 .devcontainer/Dockerfile diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 0000000000..d4996f63e2 --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,7 @@ +from aiidateam/aiida-core:main + +# Add test dependencies (not installed in image) +RUN pip install .[tests,pre-commit] + +# add aiida user +RUN /etc/my_init.d/10_create-system-user.sh \ No newline at end of file diff --git a/.devcontainer/docker-compose.yml b/.devcontainer/docker-compose.yml index 9842b1726c..c184e0fa95 100644 --- a/.devcontainer/docker-compose.yml +++ b/.devcontainer/docker-compose.yml @@ -31,7 +31,10 @@ services: # - db-volume:/var/lib/postgresql/data aiida: - image: "aiidateam/aiida-core:main" + #image: "aiidateam/aiida-core:main" + image: "aiida-core" + build: + dockerfile: Dockerfile container_name: aiida-core user: aiida environment: diff --git a/.devcontainer/post_create.sh b/.devcontainer/post_create.sh index 4d34fe54f7..c4939f0b84 100644 --- a/.devcontainer/post_create.sh +++ b/.devcontainer/post_create.sh @@ -1,11 +1,5 @@ #!/bin/bash set -e - # Add test dependencies (not installed in image) - pip install .[tests,pre-commit] - -# add aiida user -/etc/my_init.d/10_create-system-user.sh - # configure aiida /opt/configure-aiida.sh \ No newline at end of file From d57112640dc3c8dc77ee7ec85d390a4e125b055c Mon Sep 17 00:00:00 2001 From: Leopold Talirz Date: Sun, 5 Mar 2023 19:55:10 +0000 Subject: [PATCH 10/17] fixes --- .devcontainer/Dockerfile | 2 +- .devcontainer/docker-compose.yml | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index d4996f63e2..4ae100476c 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -1,4 +1,4 @@ -from aiidateam/aiida-core:main +FROM aiidateam/aiida-core:main # Add test dependencies (not installed in image) RUN pip install .[tests,pre-commit] diff --git a/.devcontainer/docker-compose.yml b/.devcontainer/docker-compose.yml index c184e0fa95..cf6c9d756a 100644 --- a/.devcontainer/docker-compose.yml +++ b/.devcontainer/docker-compose.yml @@ -20,7 +20,7 @@ services: networks: - aiida-rmq - postgresql: + postgres: image: postgres:12 container_name: aiida-postgres ports: @@ -34,6 +34,7 @@ services: #image: "aiidateam/aiida-core:main" image: "aiida-core" build: + context: . dockerfile: Dockerfile container_name: aiida-core user: aiida @@ -46,7 +47,7 @@ services: - aiida-rmq depends_on: - rabbitmq - - postgresql + - postgres # volumes: # db-volume: From 482ead4412dedbee31c4cbd8524eea5142fc5775 Mon Sep 17 00:00:00 2001 From: Leopold Talirz Date: Sun, 5 Mar 2023 20:19:08 +0000 Subject: [PATCH 11/17] fix Dockerfile --- .devcontainer/Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 4ae100476c..f20bf3a325 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -1,7 +1,8 @@ +# Additions for dev container FROM aiidateam/aiida-core:main # Add test dependencies (not installed in image) -RUN pip install .[tests,pre-commit] +RUN pip install ./aiida-core[tests,rest,docs,pre-commit] # add aiida user RUN /etc/my_init.d/10_create-system-user.sh \ No newline at end of file From 20a9d11a635d765fa4ac9dea640428be1bbd6d69 Mon Sep 17 00:00:00 2001 From: Leopold Talirz Date: Sun, 5 Mar 2023 21:35:24 +0100 Subject: [PATCH 12/17] fix docker-compose --- .devcontainer/devcontainer.json | 2 ++ .devcontainer/docker-compose.yml | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index e09b14d01d..93a8f0efd0 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,4 +1,6 @@ { + "workspaceFolder": "/home/aiida/aiida-core", + "workspaceMount": "/home/aiida/aiida-core", "dockerComposeFile": "docker-compose.yml", "service": "aiida", "postCreateCommand": "bash ./.devcontainer/post_create.sh", diff --git a/.devcontainer/docker-compose.yml b/.devcontainer/docker-compose.yml index cf6c9d756a..53db3c0032 100644 --- a/.devcontainer/docker-compose.yml +++ b/.devcontainer/docker-compose.yml @@ -27,6 +27,9 @@ services: - '5432:5432' networks: - aiida-rmq + environment: + POSTGRES_HOST_AUTH_METHOD: trust + POSTGRES_PASSWORD: password # volumes: # - db-volume:/var/lib/postgresql/data @@ -41,6 +44,11 @@ services: environment: DB_HOST: postgresql BROKER_HOST: rabbitmq + + #entrypoint: /opt/configure-aiida.sh + # entrypoint: "" + # tty: true + entrypoint: tail -f /dev/null # volumes: # - db-volume:/var/lib/assets networks: From 1179b2b7d1e4ab6477f43e3d1ee9070d50cf11bf Mon Sep 17 00:00:00 2001 From: Leopold Talirz Date: Sun, 5 Mar 2023 21:42:06 +0000 Subject: [PATCH 13/17] working docker-compose setup --- .devcontainer/Dockerfile | 6 ++- .devcontainer/configure-aiida.sh | 81 ++++++++++++++++++++++++++++++++ .devcontainer/devcontainer.json | 5 +- .devcontainer/docker-compose.yml | 23 ++++----- .devcontainer/post_create.sh | 1 - 5 files changed, 97 insertions(+), 19 deletions(-) create mode 100755 .devcontainer/configure-aiida.sh diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index f20bf3a325..246861fbb4 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -5,4 +5,8 @@ FROM aiidateam/aiida-core:main RUN pip install ./aiida-core[tests,rest,docs,pre-commit] # add aiida user -RUN /etc/my_init.d/10_create-system-user.sh \ No newline at end of file +RUN /etc/my_init.d/10_create-system-user.sh + +# copy updated aiida configuration script +# this line can be deleted after the new script has been merged +COPY configure-aiida.sh /opt/configure-aiida.sh \ No newline at end of file diff --git a/.devcontainer/configure-aiida.sh b/.devcontainer/configure-aiida.sh new file mode 100755 index 0000000000..822578b4ad --- /dev/null +++ b/.devcontainer/configure-aiida.sh @@ -0,0 +1,81 @@ +#!/bin/bash + +# This script is executed whenever the docker container is (re)started. + +# Debugging. +set -x + +# Environment. +export SHELL=/bin/bash + +# Setup AiiDA autocompletion. +grep _VERDI_COMPLETE /home/${SYSTEM_USER}/.bashrc &> /dev/null || echo 'eval "$(_VERDI_COMPLETE=source verdi)"' >> /home/${SYSTEM_USER}/.bashrc + +# Check if user requested to set up AiiDA profile (and if it exists already) +if [[ ${SETUP_DEFAULT_PROFILE} == true ]] && ! verdi profile show ${PROFILE_NAME} &> /dev/null; then + NEED_SETUP_PROFILE=true; +else + NEED_SETUP_PROFILE=false; +fi + +# Setup AiiDA profile if needed. +if [[ ${NEED_SETUP_PROFILE} == true ]]; then + + # Create AiiDA profile. + verdi quicksetup \ + --non-interactive \ + --profile "${PROFILE_NAME}" \ + --email "${USER_EMAIL}" \ + --first-name "${USER_FIRST_NAME}" \ + --last-name "${USER_LAST_NAME}" \ + --institution "${USER_INSTITUTION}" \ + --db-host "${DB_HOST:localhost}" \ + --broker-host "${BROKER_HOST:localhost}" + + # Setup and configure local computer. + computer_name=localhost + + # Determine the number of physical cores as a default for the number of + # available MPI ranks on the localhost. We do not count "logical" cores, + # since MPI parallelization over hyper-threaded cores is typically + # associated with a significant performance penalty. We use the + # `psutil.cpu_count(logical=False)` function as opposed to simply + # `os.cpu_count()` since the latter would include hyperthreaded (logical + # cores). + NUM_PHYSICAL_CORES=$(python -c 'import psutil; print(int(psutil.cpu_count(logical=False)))' 2>/dev/null) + LOCALHOST_MPI_PROCS_PER_MACHINE=${LOCALHOST_MPI_PROCS_PER_MACHINE:-${NUM_PHYSICAL_CORES}} + + if [ -z $LOCALHOST_MPI_PROCS_PER_MACHINE ]; then + echo "Unable to automatically determine the number of logical CPUs on this " + echo "machine. Please set the LOCALHOST_MPI_PROCS_PER_MACHINE variable to " + echo "explicitly set the number of available MPI ranks." + exit 1 + fi + + verdi computer show ${computer_name} || verdi computer setup \ + --non-interactive \ + --label "${computer_name}" \ + --description "this computer" \ + --hostname "${computer_name}" \ + --transport core.local \ + --scheduler core.direct \ + --work-dir /home/aiida/aiida_run/ \ + --mpirun-command "mpirun -np {tot_num_mpiprocs}" \ + --mpiprocs-per-machine ${LOCALHOST_MPI_PROCS_PER_MACHINE} && \ + verdi computer configure core.local "${computer_name}" \ + --non-interactive \ + --safe-interval 0.0 +fi + + +# Show the default profile +verdi profile show || echo "The default profile is not set." + +# Make sure that the daemon is not running, otherwise the migration will abort. +verdi daemon stop + +# Migration will run for the default profile. +verdi storage migrate --force || echo "Database migration failed." + +# Daemon will start only if the database exists and is migrated to the latest version. +verdi daemon start || echo "AiiDA daemon is not running." diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 93a8f0efd0..dd893de3b7 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,13 +1,12 @@ { - "workspaceFolder": "/home/aiida/aiida-core", - "workspaceMount": "/home/aiida/aiida-core", "dockerComposeFile": "docker-compose.yml", "service": "aiida", + "workspaceFolder": "/home/aiida/aiida-core", "postCreateCommand": "bash ./.devcontainer/post_create.sh", "waitFor": "postCreateCommand", "customizations": { "vscode": { - "extensions": ["ms-python.python", "eamodio.gitlens"] + "extensions": ["ms-python.python","ms-python.vscode-pylance", "eamodio.gitlens"] } } } \ No newline at end of file diff --git a/.devcontainer/docker-compose.yml b/.devcontainer/docker-compose.yml index 53db3c0032..52d1a44142 100644 --- a/.devcontainer/docker-compose.yml +++ b/.devcontainer/docker-compose.yml @@ -4,7 +4,6 @@ services: rabbitmq: image: rabbitmq:3.8.3-management - container_name: aiida-rabbitmq environment: RABBITMQ_DEFAULT_USER: guest RABBITMQ_DEFAULT_PASS: guest @@ -18,41 +17,37 @@ services: timeout: 30s retries: 5 networks: - - aiida-rmq + - aiida postgres: image: postgres:12 - container_name: aiida-postgres ports: - '5432:5432' networks: - - aiida-rmq + - aiida environment: POSTGRES_HOST_AUTH_METHOD: trust - POSTGRES_PASSWORD: password # volumes: # - db-volume:/var/lib/postgresql/data aiida: #image: "aiidateam/aiida-core:main" - image: "aiida-core" + image: "aiida-core-dev" build: context: . dockerfile: Dockerfile - container_name: aiida-core user: aiida environment: - DB_HOST: postgresql + DB_HOST: postgres BROKER_HOST: rabbitmq - #entrypoint: /opt/configure-aiida.sh - # entrypoint: "" - # tty: true + # no need for /sbin/my_init entrypoint: tail -f /dev/null - # volumes: + volumes: + - ..:/home/aiida/aiida-core:cached # - db-volume:/var/lib/assets networks: - - aiida-rmq + - aiida depends_on: - rabbitmq - postgres @@ -61,4 +56,4 @@ services: # db-volume: networks: - aiida-rmq: \ No newline at end of file + aiida: \ No newline at end of file diff --git a/.devcontainer/post_create.sh b/.devcontainer/post_create.sh index c4939f0b84..c12c4010cc 100644 --- a/.devcontainer/post_create.sh +++ b/.devcontainer/post_create.sh @@ -1,5 +1,4 @@ #!/bin/bash - set -e # configure aiida /opt/configure-aiida.sh \ No newline at end of file From 9acd368b50c25fe13129c048b015fa7517e86515 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 5 Mar 2023 21:49:25 +0000 Subject: [PATCH 14/17] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- .devcontainer/Dockerfile | 2 +- .devcontainer/devcontainer.json | 2 +- .devcontainer/docker-compose.yml | 2 +- .devcontainer/post_create.sh | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 246861fbb4..804e567955 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -9,4 +9,4 @@ RUN /etc/my_init.d/10_create-system-user.sh # copy updated aiida configuration script # this line can be deleted after the new script has been merged -COPY configure-aiida.sh /opt/configure-aiida.sh \ No newline at end of file +COPY configure-aiida.sh /opt/configure-aiida.sh diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index dd893de3b7..26eb9cd470 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -9,4 +9,4 @@ "extensions": ["ms-python.python","ms-python.vscode-pylance", "eamodio.gitlens"] } } -} \ No newline at end of file +} diff --git a/.devcontainer/docker-compose.yml b/.devcontainer/docker-compose.yml index 52d1a44142..78f7213e49 100644 --- a/.devcontainer/docker-compose.yml +++ b/.devcontainer/docker-compose.yml @@ -56,4 +56,4 @@ services: # db-volume: networks: - aiida: \ No newline at end of file + aiida: diff --git a/.devcontainer/post_create.sh b/.devcontainer/post_create.sh index c12c4010cc..71f8330853 100644 --- a/.devcontainer/post_create.sh +++ b/.devcontainer/post_create.sh @@ -1,4 +1,4 @@ #!/bin/bash # configure aiida -/opt/configure-aiida.sh \ No newline at end of file +/opt/configure-aiida.sh From c948905bf225d63cc56684427b8c8ef775ae9661 Mon Sep 17 00:00:00 2001 From: Leopold Talirz Date: Sun, 5 Mar 2023 21:57:06 +0000 Subject: [PATCH 15/17] add `locate` --- .devcontainer/Dockerfile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 804e567955..15fb9aeac3 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -3,6 +3,10 @@ FROM aiidateam/aiida-core:main # Add test dependencies (not installed in image) RUN pip install ./aiida-core[tests,rest,docs,pre-commit] +# the `locate` command is needed by many tests +RUN apt-get update \ + && apt-get install -y mlocate \ + && rm -rf /var/lib/apt/lists/* # add aiida user RUN /etc/my_init.d/10_create-system-user.sh From 10d7b83194329557033db40158bd71a1518790c9 Mon Sep 17 00:00:00 2001 From: Leopold Talirz Date: Wed, 8 Mar 2023 14:22:13 +0000 Subject: [PATCH 16/17] remove duplication of configure-aiida.sh --- .devcontainer/Dockerfile | 2 +- .devcontainer/configure-aiida.sh | 81 -------------------------------- .devcontainer/devcontainer.json | 2 +- .devcontainer/docker-compose.yml | 5 +- 4 files changed, 5 insertions(+), 85 deletions(-) delete mode 100755 .devcontainer/configure-aiida.sh diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 15fb9aeac3..bde97605f6 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -13,4 +13,4 @@ RUN /etc/my_init.d/10_create-system-user.sh # copy updated aiida configuration script # this line can be deleted after the new script has been merged -COPY configure-aiida.sh /opt/configure-aiida.sh +COPY ../.docker/opt/configure-aiida.sh /opt/configure-aiida.sh diff --git a/.devcontainer/configure-aiida.sh b/.devcontainer/configure-aiida.sh deleted file mode 100755 index 822578b4ad..0000000000 --- a/.devcontainer/configure-aiida.sh +++ /dev/null @@ -1,81 +0,0 @@ -#!/bin/bash - -# This script is executed whenever the docker container is (re)started. - -# Debugging. -set -x - -# Environment. -export SHELL=/bin/bash - -# Setup AiiDA autocompletion. -grep _VERDI_COMPLETE /home/${SYSTEM_USER}/.bashrc &> /dev/null || echo 'eval "$(_VERDI_COMPLETE=source verdi)"' >> /home/${SYSTEM_USER}/.bashrc - -# Check if user requested to set up AiiDA profile (and if it exists already) -if [[ ${SETUP_DEFAULT_PROFILE} == true ]] && ! verdi profile show ${PROFILE_NAME} &> /dev/null; then - NEED_SETUP_PROFILE=true; -else - NEED_SETUP_PROFILE=false; -fi - -# Setup AiiDA profile if needed. -if [[ ${NEED_SETUP_PROFILE} == true ]]; then - - # Create AiiDA profile. - verdi quicksetup \ - --non-interactive \ - --profile "${PROFILE_NAME}" \ - --email "${USER_EMAIL}" \ - --first-name "${USER_FIRST_NAME}" \ - --last-name "${USER_LAST_NAME}" \ - --institution "${USER_INSTITUTION}" \ - --db-host "${DB_HOST:localhost}" \ - --broker-host "${BROKER_HOST:localhost}" - - # Setup and configure local computer. - computer_name=localhost - - # Determine the number of physical cores as a default for the number of - # available MPI ranks on the localhost. We do not count "logical" cores, - # since MPI parallelization over hyper-threaded cores is typically - # associated with a significant performance penalty. We use the - # `psutil.cpu_count(logical=False)` function as opposed to simply - # `os.cpu_count()` since the latter would include hyperthreaded (logical - # cores). - NUM_PHYSICAL_CORES=$(python -c 'import psutil; print(int(psutil.cpu_count(logical=False)))' 2>/dev/null) - LOCALHOST_MPI_PROCS_PER_MACHINE=${LOCALHOST_MPI_PROCS_PER_MACHINE:-${NUM_PHYSICAL_CORES}} - - if [ -z $LOCALHOST_MPI_PROCS_PER_MACHINE ]; then - echo "Unable to automatically determine the number of logical CPUs on this " - echo "machine. Please set the LOCALHOST_MPI_PROCS_PER_MACHINE variable to " - echo "explicitly set the number of available MPI ranks." - exit 1 - fi - - verdi computer show ${computer_name} || verdi computer setup \ - --non-interactive \ - --label "${computer_name}" \ - --description "this computer" \ - --hostname "${computer_name}" \ - --transport core.local \ - --scheduler core.direct \ - --work-dir /home/aiida/aiida_run/ \ - --mpirun-command "mpirun -np {tot_num_mpiprocs}" \ - --mpiprocs-per-machine ${LOCALHOST_MPI_PROCS_PER_MACHINE} && \ - verdi computer configure core.local "${computer_name}" \ - --non-interactive \ - --safe-interval 0.0 -fi - - -# Show the default profile -verdi profile show || echo "The default profile is not set." - -# Make sure that the daemon is not running, otherwise the migration will abort. -verdi daemon stop - -# Migration will run for the default profile. -verdi storage migrate --force || echo "Database migration failed." - -# Daemon will start only if the database exists and is migrated to the latest version. -verdi daemon start || echo "AiiDA daemon is not running." diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 26eb9cd470..5bbcf39152 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -6,7 +6,7 @@ "waitFor": "postCreateCommand", "customizations": { "vscode": { - "extensions": ["ms-python.python","ms-python.vscode-pylance", "eamodio.gitlens"] + "extensions": ["ms-python.python", "eamodio.gitlens"] } } } diff --git a/.devcontainer/docker-compose.yml b/.devcontainer/docker-compose.yml index 78f7213e49..5d966bcecf 100644 --- a/.devcontainer/docker-compose.yml +++ b/.devcontainer/docker-compose.yml @@ -34,8 +34,9 @@ services: #image: "aiidateam/aiida-core:main" image: "aiida-core-dev" build: - context: . - dockerfile: Dockerfile + # need to add the parent directory to context to copy over new configure-aiida.sh + context: .. + dockerfile: .devcontainer/Dockerfile user: aiida environment: DB_HOST: postgres From 3903362d308260825254cef65376db7d37cec9d2 Mon Sep 17 00:00:00 2001 From: Leopold Talirz Date: Sun, 12 Mar 2023 01:27:01 +0100 Subject: [PATCH 17/17] Update docker-compose.yml remove comments --- .devcontainer/docker-compose.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.devcontainer/docker-compose.yml b/.devcontainer/docker-compose.yml index 5d966bcecf..380a0a4760 100644 --- a/.devcontainer/docker-compose.yml +++ b/.devcontainer/docker-compose.yml @@ -27,8 +27,6 @@ services: - aiida environment: POSTGRES_HOST_AUTH_METHOD: trust - # volumes: - # - db-volume:/var/lib/postgresql/data aiida: #image: "aiidateam/aiida-core:main" @@ -46,15 +44,11 @@ services: entrypoint: tail -f /dev/null volumes: - ..:/home/aiida/aiida-core:cached - # - db-volume:/var/lib/assets networks: - aiida depends_on: - rabbitmq - postgres -# volumes: -# db-volume: - networks: aiida: