From f48a799ae1ef22bd240b7175b256f8199813bd2d Mon Sep 17 00:00:00 2001 From: Daniel Hollas Date: Thu, 25 Apr 2024 18:48:46 +0100 Subject: [PATCH 01/33] Reduce number of verdi invocations on startup --- .../base/before-notebook.d/40_prepare-aiida.sh | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/stack/base/before-notebook.d/40_prepare-aiida.sh b/stack/base/before-notebook.d/40_prepare-aiida.sh index 869aa3d5..41053b6c 100755 --- a/stack/base/before-notebook.d/40_prepare-aiida.sh +++ b/stack/base/before-notebook.d/40_prepare-aiida.sh @@ -48,7 +48,8 @@ if [[ ${NEED_SETUP_PROFILE} == true ]]; then exit 1 fi - verdi computer show ${computer_name} || verdi computer setup \ + # TODO: Load config from YAML file + verdi computer setup \ --non-interactive \ --label "${computer_name}" \ --description "this computer" \ @@ -61,17 +62,15 @@ if [[ ${NEED_SETUP_PROFILE} == true ]]; then 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." +else -# 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 -# Migration will run for the default profile. -verdi storage migrate --force + # Show the default profile + verdi profile show +fi # Daemon will start only if the database exists and is migrated to the latest version. verdi daemon start || echo "AiiDA daemon is not running." From bdd8ef13cdc4e8f179cf6a3bf44ee8e2983dbbcd Mon Sep 17 00:00:00 2001 From: Daniel Hollas Date: Thu, 25 Apr 2024 19:06:32 +0100 Subject: [PATCH 02/33] Set debug outputs --- .../base-with-services/before-notebook.d/20_start-postgresql.sh | 1 + .../before-notebook.d/30_start-rabbitmq-amd64.sh | 2 +- .../before-notebook.d/30_start-rabbitmq-arm64.sh | 2 +- .../before-notebook.d/41_suppress-rabbitmq-version-warning.sh | 2 +- stack/base/before-notebook.d/10_prepare-home-config.sh | 1 + 5 files changed, 5 insertions(+), 3 deletions(-) diff --git a/stack/base-with-services/before-notebook.d/20_start-postgresql.sh b/stack/base-with-services/before-notebook.d/20_start-postgresql.sh index 0eb685e7..fd7623ae 100644 --- a/stack/base-with-services/before-notebook.d/20_start-postgresql.sh +++ b/stack/base-with-services/before-notebook.d/20_start-postgresql.sh @@ -1,4 +1,5 @@ #!/bin/bash +set -x # Activate the conda environment with PostgreSQL installed in it. # conda activate pgsql diff --git a/stack/base-with-services/before-notebook.d/30_start-rabbitmq-amd64.sh b/stack/base-with-services/before-notebook.d/30_start-rabbitmq-amd64.sh index 5c55fff3..c4b40a6e 100644 --- a/stack/base-with-services/before-notebook.d/30_start-rabbitmq-amd64.sh +++ b/stack/base-with-services/before-notebook.d/30_start-rabbitmq-amd64.sh @@ -1,5 +1,5 @@ #!/bin/bash -set -em +set -emx RABBITMQ_DATA_DIR="/home/${NB_USER}/.rabbitmq" diff --git a/stack/base-with-services/before-notebook.d/30_start-rabbitmq-arm64.sh b/stack/base-with-services/before-notebook.d/30_start-rabbitmq-arm64.sh index 95830a49..b73be1d7 100644 --- a/stack/base-with-services/before-notebook.d/30_start-rabbitmq-arm64.sh +++ b/stack/base-with-services/before-notebook.d/30_start-rabbitmq-arm64.sh @@ -1,5 +1,5 @@ #!/bin/bash -set -em +set -emx RABBITMQ_DATA_DIR="/home/${NB_USER}/.rabbitmq" diff --git a/stack/base-with-services/before-notebook.d/41_suppress-rabbitmq-version-warning.sh b/stack/base-with-services/before-notebook.d/41_suppress-rabbitmq-version-warning.sh index f778bbb5..df77710b 100644 --- a/stack/base-with-services/before-notebook.d/41_suppress-rabbitmq-version-warning.sh +++ b/stack/base-with-services/before-notebook.d/41_suppress-rabbitmq-version-warning.sh @@ -1,5 +1,5 @@ #!/bin/bash -set -em +set -emx # Supress rabbitmq version warning for arm64 since # it is built using latest version rabbitmq from apt install. diff --git a/stack/base/before-notebook.d/10_prepare-home-config.sh b/stack/base/before-notebook.d/10_prepare-home-config.sh index a4d0ab70..fa9ecc3b 100644 --- a/stack/base/before-notebook.d/10_prepare-home-config.sh +++ b/stack/base/before-notebook.d/10_prepare-home-config.sh @@ -1,4 +1,5 @@ #!/bin/bash +set -x # If the container is start by spawner and the home is remounted. # The .bashrc in HOME won't be set properly. From f02bc2843ebd125609c16b4c39723db3c0b3b053 Mon Sep 17 00:00:00 2001 From: Daniel Hollas Date: Thu, 25 Apr 2024 21:42:19 +0100 Subject: [PATCH 03/33] Cleanup 20_start-postgresql.sh --- .../before-notebook.d/20_start-postgresql.sh | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/stack/base-with-services/before-notebook.d/20_start-postgresql.sh b/stack/base-with-services/before-notebook.d/20_start-postgresql.sh index fd7623ae..6d7ea108 100644 --- a/stack/base-with-services/before-notebook.d/20_start-postgresql.sh +++ b/stack/base-with-services/before-notebook.d/20_start-postgresql.sh @@ -1,9 +1,6 @@ #!/bin/bash set -x -# Activate the conda environment with PostgreSQL installed in it. -# conda activate pgsql - # -w waits until server is up PSQL_START_CMD="pg_ctl --timeout=180 -w -D /home/${NB_USER}/.postgresql -l /home/${NB_USER}/.postgresql/logfile start" PSQL_STOP_CMD="pg_ctl -w -D /home/${NB_USER}/.postgresql stop" @@ -18,19 +15,15 @@ if [ ! -d /home/${NB_USER}/.postgresql ]; then echo "unix_socket_directories = '/tmp'" >> /home/${NB_USER}/.postgresql/postgresql.conf ${MAMBA_RUN} ${PSQL_START_CMD} -# else don't else # Fix problem with kubernetes cluster that adds rws permissions to the group # for more details see: https://github.com/materialscloud-org/aiidalab-z2jh-eosc/issues/5 chmod g-rwxs /home/${NB_USER}/.postgresql -R - # stores return value in $? - running=true - ${MAMBA_RUN} ${PSQL_STATUS_CMD} || running=false - - # Postgresql was probably not shutdown properly. Cleaning up the mess... - if ! $running ; then - echo "" > /home/${NB_USER}/.postgresql/logfile # empty log files + if ! ${MAMBA_RUN} ${PSQL_STATUS_CMD}; then + # Cleaning up the mess if Postgresql was not shutdown properly. + # TODO: Rotate logfile + echo "" > /home/${NB_USER}/.postgresql/logfile rm -vf /home/${NB_USER}/.postgresql/postmaster.pid ${MAMBA_RUN} ${PSQL_START_CMD} fi From 6f639aa2c012dc3e138d70ea00ef6fbaa742136e Mon Sep 17 00:00:00 2001 From: Daniel Hollas Date: Fri, 17 May 2024 10:29:12 +0100 Subject: [PATCH 04/33] More tweaks --- stack/base/before-notebook.d/40_prepare-aiida.sh | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/stack/base/before-notebook.d/40_prepare-aiida.sh b/stack/base/before-notebook.d/40_prepare-aiida.sh index 41053b6c..5242d4e0 100755 --- a/stack/base/before-notebook.d/40_prepare-aiida.sh +++ b/stack/base/before-notebook.d/40_prepare-aiida.sh @@ -1,15 +1,12 @@ #!/bin/bash # This script is executed whenever the docker container is (re)started. - -# Debugging. set -x -# Environment. export SHELL=/bin/bash # Check if user requested to set up AiiDA profile (and if it exists already) -if [[ ${SETUP_DEFAULT_AIIDA_PROFILE} == true ]] && ! verdi profile show ${AIIDA_PROFILE_NAME} &> /dev/null; then +if [[ ${SETUP_DEFAULT_AIIDA_PROFILE} == true ]] && ! verdi profile show ${AIIDA_PROFILE_NAME} 2> /dev/null; then NEED_SETUP_PROFILE=true; else NEED_SETUP_PROFILE=false; @@ -48,7 +45,6 @@ if [[ ${NEED_SETUP_PROFILE} == true ]]; then exit 1 fi - # TODO: Load config from YAML file verdi computer setup \ --non-interactive \ --label "${computer_name}" \ @@ -68,9 +64,7 @@ else # Migration will run for the default profile. verdi storage migrate --force - # Show the default profile - verdi profile show fi # Daemon will start only if the database exists and is migrated to the latest version. -verdi daemon start || echo "AiiDA daemon is not running." +verdi daemon start || echo "ERROR: AiiDA daemon is not running!" From da9cffdecf6ec54b464b1bbe8849ca77c2132392 Mon Sep 17 00:00:00 2001 From: Daniel Hollas Date: Tue, 21 May 2024 00:34:27 +0100 Subject: [PATCH 05/33] Prepare DB during build --- stack/base-with-services/Dockerfile | 2 +- stack/full-stack/Dockerfile | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/stack/base-with-services/Dockerfile b/stack/base-with-services/Dockerfile index 99f0331e..70aa01ba 100644 --- a/stack/base-with-services/Dockerfile +++ b/stack/base-with-services/Dockerfile @@ -58,4 +58,4 @@ USER ${NB_USER} WORKDIR "/home/${NB_USER}" # Initialize the database -RUN mamba run -n aiida-core-services initdb -D aiida_db -U aiida +RUN mamba run -n aiida-core-services initdb -D /home/${NB_USER}/.postgresql diff --git a/stack/full-stack/Dockerfile b/stack/full-stack/Dockerfile index aefe2a82..cd21b413 100644 --- a/stack/full-stack/Dockerfile +++ b/stack/full-stack/Dockerfile @@ -8,9 +8,10 @@ USER root COPY --from=base /opt/config-quick-setup.yaml /opt/ COPY --from=base "${CONDA_DIR}/envs/aiida-core-services" "${CONDA_DIR}/envs/aiida-core-services" COPY --from=base /usr/local/bin/before-notebook.d /usr/local/bin/before-notebook.d +COPY --from=base /home/${NB_USER}/.postgresql /home/${NB_USER}/.postgresql RUN fix-permissions "${CONDA_DIR}" -RUN fix-permissions "/home/${NB_USER}/.aiida" +RUN fix-permissions "/home/${NB_USER}" USER ${NB_USER} From 79231b6dfbb22ffafa16912ee62eec4b8d8b6c93 Mon Sep 17 00:00:00 2001 From: Daniel Hollas Date: Tue, 21 May 2024 00:56:18 +0100 Subject: [PATCH 06/33] Try without root --- stack/full-stack/Dockerfile | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/stack/full-stack/Dockerfile b/stack/full-stack/Dockerfile index cd21b413..99326664 100644 --- a/stack/full-stack/Dockerfile +++ b/stack/full-stack/Dockerfile @@ -3,15 +3,10 @@ FROM base-with-services as base FROM lab -USER root - COPY --from=base /opt/config-quick-setup.yaml /opt/ COPY --from=base "${CONDA_DIR}/envs/aiida-core-services" "${CONDA_DIR}/envs/aiida-core-services" COPY --from=base /usr/local/bin/before-notebook.d /usr/local/bin/before-notebook.d -COPY --from=base /home/${NB_USER}/.postgresql /home/${NB_USER}/.postgresql - -RUN fix-permissions "${CONDA_DIR}" -RUN fix-permissions "/home/${NB_USER}" +COPY --from=base "/home/${NB_USER}/.postgresql" "/home/${NB_USER}/.postgresql" USER ${NB_USER} From a6320de878be2f2371e0cf1dcb8c957a86d8f0c4 Mon Sep 17 00:00:00 2001 From: Daniel Hollas Date: Tue, 21 May 2024 01:41:13 +0100 Subject: [PATCH 07/33] Use PGDATA --- stack/base-with-services/Dockerfile | 5 ++++- .../before-notebook.d/20_start-postgresql.sh | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/stack/base-with-services/Dockerfile b/stack/base-with-services/Dockerfile index 70aa01ba..5954d825 100644 --- a/stack/base-with-services/Dockerfile +++ b/stack/base-with-services/Dockerfile @@ -9,6 +9,9 @@ WORKDIR /opt/ ARG AIIDA_VERSION ARG PGSQL_VERSION ARG TARGETARCH +# Location of the Postgresql DB +# This variable is automatically picked up by initdb +ARG ENV PGDATA=/home/${NB_USER}/.posgresql # Install RabbitMQ and PostgreSQL in a dedicated conda environment. # @@ -58,4 +61,4 @@ USER ${NB_USER} WORKDIR "/home/${NB_USER}" # Initialize the database -RUN mamba run -n aiida-core-services initdb -D /home/${NB_USER}/.postgresql +RUN mamba run -n aiida-core-services initdb diff --git a/stack/base-with-services/before-notebook.d/20_start-postgresql.sh b/stack/base-with-services/before-notebook.d/20_start-postgresql.sh index 6d7ea108..e4466cf3 100644 --- a/stack/base-with-services/before-notebook.d/20_start-postgresql.sh +++ b/stack/base-with-services/before-notebook.d/20_start-postgresql.sh @@ -11,7 +11,7 @@ MAMBA_RUN="mamba run -n aiida-core-services" # make DB directory, if not existent if [ ! -d /home/${NB_USER}/.postgresql ]; then mkdir /home/${NB_USER}/.postgresql - ${MAMBA_RUN} initdb -D /home/${NB_USER}/.postgresql + ${MAMBA_RUN} initdb echo "unix_socket_directories = '/tmp'" >> /home/${NB_USER}/.postgresql/postgresql.conf ${MAMBA_RUN} ${PSQL_START_CMD} From fac06ff02f6fd85db3ddfe756ce16d02f93391f3 Mon Sep 17 00:00:00 2001 From: Daniel Hollas Date: Tue, 21 May 2024 01:53:27 +0100 Subject: [PATCH 08/33] Revert "Try without root" This reverts commit 79231b6dfbb22ffafa16912ee62eec4b8d8b6c93. --- stack/full-stack/Dockerfile | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/stack/full-stack/Dockerfile b/stack/full-stack/Dockerfile index 99326664..cd21b413 100644 --- a/stack/full-stack/Dockerfile +++ b/stack/full-stack/Dockerfile @@ -3,10 +3,15 @@ FROM base-with-services as base FROM lab +USER root + COPY --from=base /opt/config-quick-setup.yaml /opt/ COPY --from=base "${CONDA_DIR}/envs/aiida-core-services" "${CONDA_DIR}/envs/aiida-core-services" COPY --from=base /usr/local/bin/before-notebook.d /usr/local/bin/before-notebook.d -COPY --from=base "/home/${NB_USER}/.postgresql" "/home/${NB_USER}/.postgresql" +COPY --from=base /home/${NB_USER}/.postgresql /home/${NB_USER}/.postgresql + +RUN fix-permissions "${CONDA_DIR}" +RUN fix-permissions "/home/${NB_USER}" USER ${NB_USER} From b4e61457bc9206e8283f7787bee7a4672baa0ffd Mon Sep 17 00:00:00 2001 From: Daniel Hollas Date: Tue, 21 May 2024 02:00:06 +0100 Subject: [PATCH 09/33] PGDATA everywhere --- stack/base-with-services/Dockerfile | 2 +- .../before-notebook.d/20_start-postgresql.sh | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/stack/base-with-services/Dockerfile b/stack/base-with-services/Dockerfile index 5954d825..88afa65c 100644 --- a/stack/base-with-services/Dockerfile +++ b/stack/base-with-services/Dockerfile @@ -11,7 +11,7 @@ ARG PGSQL_VERSION ARG TARGETARCH # Location of the Postgresql DB # This variable is automatically picked up by initdb -ARG ENV PGDATA=/home/${NB_USER}/.posgresql +ENV PGDATA=/home/${NB_USER}/.posgresql # Install RabbitMQ and PostgreSQL in a dedicated conda environment. # diff --git a/stack/base-with-services/before-notebook.d/20_start-postgresql.sh b/stack/base-with-services/before-notebook.d/20_start-postgresql.sh index e4466cf3..0a696354 100644 --- a/stack/base-with-services/before-notebook.d/20_start-postgresql.sh +++ b/stack/base-with-services/before-notebook.d/20_start-postgresql.sh @@ -2,29 +2,29 @@ set -x # -w waits until server is up -PSQL_START_CMD="pg_ctl --timeout=180 -w -D /home/${NB_USER}/.postgresql -l /home/${NB_USER}/.postgresql/logfile start" -PSQL_STOP_CMD="pg_ctl -w -D /home/${NB_USER}/.postgresql stop" -PSQL_STATUS_CMD="pg_ctl -D /home/${NB_USER}/.postgresql status" +PSQL_START_CMD="pg_ctl --timeout=180 -w -l ${PGDATA}/logfile start" +PSQL_STOP_CMD="pg_ctl -w stop" +PSQL_STATUS_CMD="pg_ctl status" MAMBA_RUN="mamba run -n aiida-core-services" # make DB directory, if not existent -if [ ! -d /home/${NB_USER}/.postgresql ]; then - mkdir /home/${NB_USER}/.postgresql +if [ ! -d ${PGDATA} ]; then + mkdir ${PGDATA} ${MAMBA_RUN} initdb - echo "unix_socket_directories = '/tmp'" >> /home/${NB_USER}/.postgresql/postgresql.conf + echo "unix_socket_directories = '/tmp'" >> ${PGDATA}/postgresql.conf ${MAMBA_RUN} ${PSQL_START_CMD} else # Fix problem with kubernetes cluster that adds rws permissions to the group # for more details see: https://github.com/materialscloud-org/aiidalab-z2jh-eosc/issues/5 - chmod g-rwxs /home/${NB_USER}/.postgresql -R + chmod g-rwxs ${PGDATA} -R if ! ${MAMBA_RUN} ${PSQL_STATUS_CMD}; then # Cleaning up the mess if Postgresql was not shutdown properly. # TODO: Rotate logfile - echo "" > /home/${NB_USER}/.postgresql/logfile - rm -vf /home/${NB_USER}/.postgresql/postmaster.pid + echo "" > ${PGDATA}/logfile + rm -vf ${PGDATA}/postmaster.pid ${MAMBA_RUN} ${PSQL_START_CMD} fi fi From ac248db16ac3543e191bef39108b40b8754bec63 Mon Sep 17 00:00:00 2001 From: Daniel Hollas Date: Tue, 21 May 2024 02:16:11 +0100 Subject: [PATCH 10/33] back --- stack/full-stack/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stack/full-stack/Dockerfile b/stack/full-stack/Dockerfile index cd21b413..86d9430a 100644 --- a/stack/full-stack/Dockerfile +++ b/stack/full-stack/Dockerfile @@ -8,7 +8,7 @@ USER root COPY --from=base /opt/config-quick-setup.yaml /opt/ COPY --from=base "${CONDA_DIR}/envs/aiida-core-services" "${CONDA_DIR}/envs/aiida-core-services" COPY --from=base /usr/local/bin/before-notebook.d /usr/local/bin/before-notebook.d -COPY --from=base /home/${NB_USER}/.postgresql /home/${NB_USER}/.postgresql +#COPY --from=base /home/${NB_USER}/.postgresql /home/${NB_USER}/.postgresql RUN fix-permissions "${CONDA_DIR}" RUN fix-permissions "/home/${NB_USER}" From 2e5ba4667c9b84393e6cccf6cd4d572786af606d Mon Sep 17 00:00:00 2001 From: Daniel Hollas Date: Tue, 21 May 2024 02:47:37 +0100 Subject: [PATCH 11/33] Fix? --- stack/base-with-services/Dockerfile | 2 +- .../base-with-services/before-notebook.d/20_start-postgresql.sh | 2 +- stack/full-stack/Dockerfile | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/stack/base-with-services/Dockerfile b/stack/base-with-services/Dockerfile index 88afa65c..7cd8bf86 100644 --- a/stack/base-with-services/Dockerfile +++ b/stack/base-with-services/Dockerfile @@ -11,7 +11,7 @@ ARG PGSQL_VERSION ARG TARGETARCH # Location of the Postgresql DB # This variable is automatically picked up by initdb -ENV PGDATA=/home/${NB_USER}/.posgresql +ENV PGDATA=/home/${NB_USER}/.postgresql # Install RabbitMQ and PostgreSQL in a dedicated conda environment. # diff --git a/stack/base-with-services/before-notebook.d/20_start-postgresql.sh b/stack/base-with-services/before-notebook.d/20_start-postgresql.sh index 0a696354..b17ca038 100644 --- a/stack/base-with-services/before-notebook.d/20_start-postgresql.sh +++ b/stack/base-with-services/before-notebook.d/20_start-postgresql.sh @@ -18,7 +18,7 @@ if [ ! -d ${PGDATA} ]; then else # Fix problem with kubernetes cluster that adds rws permissions to the group # for more details see: https://github.com/materialscloud-org/aiidalab-z2jh-eosc/issues/5 - chmod g-rwxs ${PGDATA} -R + chmod -R g-rwxs ${PGDATA} if ! ${MAMBA_RUN} ${PSQL_STATUS_CMD}; then # Cleaning up the mess if Postgresql was not shutdown properly. diff --git a/stack/full-stack/Dockerfile b/stack/full-stack/Dockerfile index 86d9430a..cd21b413 100644 --- a/stack/full-stack/Dockerfile +++ b/stack/full-stack/Dockerfile @@ -8,7 +8,7 @@ USER root COPY --from=base /opt/config-quick-setup.yaml /opt/ COPY --from=base "${CONDA_DIR}/envs/aiida-core-services" "${CONDA_DIR}/envs/aiida-core-services" COPY --from=base /usr/local/bin/before-notebook.d /usr/local/bin/before-notebook.d -#COPY --from=base /home/${NB_USER}/.postgresql /home/${NB_USER}/.postgresql +COPY --from=base /home/${NB_USER}/.postgresql /home/${NB_USER}/.postgresql RUN fix-permissions "${CONDA_DIR}" RUN fix-permissions "/home/${NB_USER}" From 50e2611456fc2338f2b64115b91ca765feeb9868 Mon Sep 17 00:00:00 2001 From: Daniel Hollas Date: Tue, 21 May 2024 03:01:17 +0100 Subject: [PATCH 12/33] Pass PGDATA for full-stack --- stack/base-with-services/Dockerfile | 3 ++- stack/full-stack/Dockerfile | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/stack/base-with-services/Dockerfile b/stack/base-with-services/Dockerfile index 7cd8bf86..7d13ef78 100644 --- a/stack/base-with-services/Dockerfile +++ b/stack/base-with-services/Dockerfile @@ -11,7 +11,8 @@ ARG PGSQL_VERSION ARG TARGETARCH # Location of the Postgresql DB # This variable is automatically picked up by initdb -ENV PGDATA=/home/${NB_USER}/.postgresql +ARG PGDATA_FOLDER=/home/${NB_USER}/.postgresql +ENV PGDATA=${PGDATA_FOLDER} # Install RabbitMQ and PostgreSQL in a dedicated conda environment. # diff --git a/stack/full-stack/Dockerfile b/stack/full-stack/Dockerfile index cd21b413..4f64907f 100644 --- a/stack/full-stack/Dockerfile +++ b/stack/full-stack/Dockerfile @@ -1,14 +1,17 @@ # syntax=docker/dockerfile:1 FROM base-with-services as base +ARG PGDATA_FOLDER FROM lab +ARG PGDATA_FOLDER +ENV PGDATA=${PGDATA_FOLDER} USER root COPY --from=base /opt/config-quick-setup.yaml /opt/ COPY --from=base "${CONDA_DIR}/envs/aiida-core-services" "${CONDA_DIR}/envs/aiida-core-services" COPY --from=base /usr/local/bin/before-notebook.d /usr/local/bin/before-notebook.d -COPY --from=base /home/${NB_USER}/.postgresql /home/${NB_USER}/.postgresql +COPY --from=base ${PGDATA} ${PGDATA} RUN fix-permissions "${CONDA_DIR}" RUN fix-permissions "/home/${NB_USER}" From be5846d926a57f41c4a456515f78cb16e64e4e28 Mon Sep 17 00:00:00 2001 From: Daniel Hollas Date: Tue, 21 May 2024 16:27:45 +0100 Subject: [PATCH 13/33] This? --- stack/full-stack/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stack/full-stack/Dockerfile b/stack/full-stack/Dockerfile index 4f64907f..6219aeb3 100644 --- a/stack/full-stack/Dockerfile +++ b/stack/full-stack/Dockerfile @@ -3,7 +3,7 @@ FROM base-with-services as base ARG PGDATA_FOLDER FROM lab -ARG PGDATA_FOLDER + ENV PGDATA=${PGDATA_FOLDER} USER root From e89f505f21aae5544973fb92faf886a0c450e37f Mon Sep 17 00:00:00 2001 From: Daniel Hollas Date: Fri, 24 May 2024 13:30:37 +0100 Subject: [PATCH 14/33] Update stack/full-stack/Dockerfile --- stack/full-stack/Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/stack/full-stack/Dockerfile b/stack/full-stack/Dockerfile index 6219aeb3..e07c3a3c 100644 --- a/stack/full-stack/Dockerfile +++ b/stack/full-stack/Dockerfile @@ -1,4 +1,5 @@ # syntax=docker/dockerfile:1 +ARG PGDATA_FOLDER FROM base-with-services as base ARG PGDATA_FOLDER From 9aaa20dfb8edd398f0659ff407644d3a59d3a290 Mon Sep 17 00:00:00 2001 From: Daniel Hollas Date: Fri, 24 May 2024 13:40:26 +0100 Subject: [PATCH 15/33] Update stack/full-stack/Dockerfile --- stack/full-stack/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stack/full-stack/Dockerfile b/stack/full-stack/Dockerfile index e07c3a3c..be605241 100644 --- a/stack/full-stack/Dockerfile +++ b/stack/full-stack/Dockerfile @@ -15,7 +15,7 @@ COPY --from=base /usr/local/bin/before-notebook.d /usr/local/bin/before-notebook COPY --from=base ${PGDATA} ${PGDATA} RUN fix-permissions "${CONDA_DIR}" -RUN fix-permissions "/home/${NB_USER}" +RUN fix-permissions "/home/${NB_USER}/.aiida" USER ${NB_USER} From 163e4f29f79cac914be061401fbdd72c539c5574 Mon Sep 17 00:00:00 2001 From: Daniel Hollas Date: Fri, 24 May 2024 13:55:25 +0100 Subject: [PATCH 16/33] Update stack/full-stack/Dockerfile --- stack/full-stack/Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/stack/full-stack/Dockerfile b/stack/full-stack/Dockerfile index be605241..4ec9b19b 100644 --- a/stack/full-stack/Dockerfile +++ b/stack/full-stack/Dockerfile @@ -5,6 +5,7 @@ ARG PGDATA_FOLDER FROM lab +ARG PGDATA_FOLDER ENV PGDATA=${PGDATA_FOLDER} USER root From e4c45e120150762295adc9840883d00ccd67391e Mon Sep 17 00:00:00 2001 From: Daniel Hollas Date: Thu, 23 May 2024 12:45:18 +0100 Subject: [PATCH 17/33] Add comment about Erlang --- stack/base-with-services/Dockerfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/stack/base-with-services/Dockerfile b/stack/base-with-services/Dockerfile index 7d13ef78..0e5eab0c 100644 --- a/stack/base-with-services/Dockerfile +++ b/stack/base-with-services/Dockerfile @@ -21,6 +21,8 @@ ENV PGDATA=${PGDATA_FOLDER} # Instead we need install erlang via apt and RabbitMQ as a "Generic Unix Build", see: # https://www.rabbitmq.com/install-generic-unix.html # Note that this version must be compatible with system's erlang version. +# Currently installed Erlang version is 23.3, so the latest supported RMQ version is 3.9.21 +# https://www.rabbitmq.com/docs/which-erlang#old-timers # Note that system erlang from arm64 is already installed in the base image, # together with other APT dependencies to save build time. RUN if [ "$TARGETARCH" = "amd64" ]; then \ From 1ac56fbc50f422b30bb60c779861bdf0e7d315a5 Mon Sep 17 00:00:00 2001 From: Daniel Hollas Date: Fri, 24 May 2024 14:50:23 +0100 Subject: [PATCH 18/33] Come on! --- stack/full-stack/Dockerfile | 1 - 1 file changed, 1 deletion(-) diff --git a/stack/full-stack/Dockerfile b/stack/full-stack/Dockerfile index 4ec9b19b..be605241 100644 --- a/stack/full-stack/Dockerfile +++ b/stack/full-stack/Dockerfile @@ -5,7 +5,6 @@ ARG PGDATA_FOLDER FROM lab -ARG PGDATA_FOLDER ENV PGDATA=${PGDATA_FOLDER} USER root From bdf390755a25291b4d273d8fcbe7872f7c7cea26 Mon Sep 17 00:00:00 2001 From: Daniel Hollas Date: Fri, 24 May 2024 14:53:03 +0100 Subject: [PATCH 19/33] Remove meta targets --- docker-bake.hcl | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/docker-bake.hcl b/docker-bake.hcl index 46d8225b..44d74a55 100644 --- a/docker-bake.hcl +++ b/docker-bake.hcl @@ -54,22 +54,8 @@ group "default" { targets = "${TARGETS}" } -target "base-meta" { - tags = tags("base") -} -target "base-with-services-meta" { - tags = tags("base-with-services") -} -target "lab-meta" { - tags = tags("lab") -} - -target "full-stack-meta" { - tags = tags("full-stack") -} - target "base" { - inherits = ["base-meta"] + tags = tags("base") context = "stack/base" platforms = "${PLATFORMS}" args = { @@ -78,7 +64,7 @@ target "base" { } } target "base-with-services" { - inherits = ["base-with-services-meta"] + tags = tags("base-with-services") context = "stack/base-with-services" contexts = { base = "target:base" @@ -90,7 +76,7 @@ target "base-with-services" { } } target "lab" { - inherits = ["lab-meta"] + tags = tags("lab") context = "stack/lab" contexts = { base = "target:base" @@ -103,7 +89,7 @@ target "lab" { } } target "full-stack" { - inherits = ["full-stack-meta"] + tags = tags("full-stack") context = "stack/full-stack" contexts = { base-with-services = "target:base-with-services" From c8c1cef172ccdde65c81e08c88dd4b1ad0b04720 Mon Sep 17 00:00:00 2001 From: Daniel Hollas Date: Fri, 24 May 2024 17:03:14 +0100 Subject: [PATCH 20/33] Preserve logfile --- .../before-notebook.d/20_start-postgresql.sh | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/stack/base-with-services/before-notebook.d/20_start-postgresql.sh b/stack/base-with-services/before-notebook.d/20_start-postgresql.sh index b17ca038..d6d50b50 100644 --- a/stack/base-with-services/before-notebook.d/20_start-postgresql.sh +++ b/stack/base-with-services/before-notebook.d/20_start-postgresql.sh @@ -3,7 +3,6 @@ set -x # -w waits until server is up PSQL_START_CMD="pg_ctl --timeout=180 -w -l ${PGDATA}/logfile start" -PSQL_STOP_CMD="pg_ctl -w stop" PSQL_STATUS_CMD="pg_ctl status" MAMBA_RUN="mamba run -n aiida-core-services" @@ -17,13 +16,11 @@ if [ ! -d ${PGDATA} ]; then else # Fix problem with kubernetes cluster that adds rws permissions to the group - # for more details see: https://github.com/materialscloud-org/aiidalab-z2jh-eosc/issues/5 chmod -R g-rwxs ${PGDATA} if ! ${MAMBA_RUN} ${PSQL_STATUS_CMD}; then # Cleaning up the mess if Postgresql was not shutdown properly. - # TODO: Rotate logfile - echo "" > ${PGDATA}/logfile + mv ${PGDATA}/logfile ${PGDATA/logfile.1 && gzip ${PGDATA}/logfile.1 rm -vf ${PGDATA}/postmaster.pid ${MAMBA_RUN} ${PSQL_START_CMD} fi From 2ddeac02cee37cf0e000fc341454e5854660dfd5 Mon Sep 17 00:00:00 2001 From: Daniel Hollas Date: Fri, 24 May 2024 17:18:09 +0100 Subject: [PATCH 21/33] sigh --- stack/full-stack/Dockerfile | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/stack/full-stack/Dockerfile b/stack/full-stack/Dockerfile index be605241..5f684a02 100644 --- a/stack/full-stack/Dockerfile +++ b/stack/full-stack/Dockerfile @@ -2,17 +2,16 @@ ARG PGDATA_FOLDER FROM base-with-services as base ARG PGDATA_FOLDER +ENV PGDATA=${PGDATA_FOLDER} FROM lab -ENV PGDATA=${PGDATA_FOLDER} - USER root COPY --from=base /opt/config-quick-setup.yaml /opt/ COPY --from=base "${CONDA_DIR}/envs/aiida-core-services" "${CONDA_DIR}/envs/aiida-core-services" COPY --from=base /usr/local/bin/before-notebook.d /usr/local/bin/before-notebook.d -COPY --from=base ${PGDATA} ${PGDATA} +COPY --from=base ${PGDATA_FOLDER} ${PGDATA_FOLDER} RUN fix-permissions "${CONDA_DIR}" RUN fix-permissions "/home/${NB_USER}/.aiida" From 7e9c91cfed40277ab5232a51cd5484eb81df11bf Mon Sep 17 00:00:00 2001 From: Daniel Hollas Date: Sat, 25 May 2024 12:43:30 +0100 Subject: [PATCH 22/33] fix --- .../base-with-services/before-notebook.d/20_start-postgresql.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stack/base-with-services/before-notebook.d/20_start-postgresql.sh b/stack/base-with-services/before-notebook.d/20_start-postgresql.sh index d6d50b50..c79fba1b 100644 --- a/stack/base-with-services/before-notebook.d/20_start-postgresql.sh +++ b/stack/base-with-services/before-notebook.d/20_start-postgresql.sh @@ -20,7 +20,7 @@ else if ! ${MAMBA_RUN} ${PSQL_STATUS_CMD}; then # Cleaning up the mess if Postgresql was not shutdown properly. - mv ${PGDATA}/logfile ${PGDATA/logfile.1 && gzip ${PGDATA}/logfile.1 + mv ${PGDATA}/logfile ${PGDATA}/logfile.1 && gzip ${PGDATA}/logfile.1 rm -vf ${PGDATA}/postmaster.pid ${MAMBA_RUN} ${PSQL_START_CMD} fi From 2d0e8f47e545e4f30f2261f4530ae5284474e639 Mon Sep 17 00:00:00 2001 From: Daniel Hollas Date: Sun, 26 May 2024 17:53:36 +0100 Subject: [PATCH 23/33] remove pg_ctl status --- .../before-notebook.d/20_start-postgresql.sh | 37 +++++++++++-------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/stack/base-with-services/before-notebook.d/20_start-postgresql.sh b/stack/base-with-services/before-notebook.d/20_start-postgresql.sh index c79fba1b..3c9a443c 100644 --- a/stack/base-with-services/before-notebook.d/20_start-postgresql.sh +++ b/stack/base-with-services/before-notebook.d/20_start-postgresql.sh @@ -1,27 +1,32 @@ #!/bin/bash set -x +if [[ -z $PGDATA ]]; then + echo "ERROR: PGDATA variable not set, cannot start PostgreSQL!" + exit 1 +fi + +PSQL_LOGFILE="${PGDATA}/logfile" # -w waits until server is up -PSQL_START_CMD="pg_ctl --timeout=180 -w -l ${PGDATA}/logfile start" -PSQL_STATUS_CMD="pg_ctl status" +PSQL_START_CMD="pg_ctl --timeout=180 -w -l ${PSQL_LOGFILE} start" MAMBA_RUN="mamba run -n aiida-core-services" -# make DB directory, if not existent -if [ ! -d ${PGDATA} ]; then - mkdir ${PGDATA} - ${MAMBA_RUN} initdb - echo "unix_socket_directories = '/tmp'" >> ${PGDATA}/postgresql.conf - ${MAMBA_RUN} ${PSQL_START_CMD} - +# Initialize DB directory if it does not exist +if [[ ! -d ${PGDATA} ]]; then + mkdir "${PGDATA}" + ${MAMBA_RUN} initdb + echo "unix_socket_directories = '/tmp'" >> "${PGDATA}/postgresql.conf" else # Fix problem with kubernetes cluster that adds rws permissions to the group - chmod -R g-rwxs ${PGDATA} + chmod -R g-rwxs "${PGDATA}" - if ! ${MAMBA_RUN} ${PSQL_STATUS_CMD}; then - # Cleaning up the mess if Postgresql was not shutdown properly. - mv ${PGDATA}/logfile ${PGDATA}/logfile.1 && gzip ${PGDATA}/logfile.1 - rm -vf ${PGDATA}/postmaster.pid - ${MAMBA_RUN} ${PSQL_START_CMD} - fi + if [[ -f ${PGDATA}/logfile ]]; then + mv "${PSQL_LOGFILE}" "${PSQL_LOGFILE}.1" && gzip "${PSQL_LOGFILE}.1" + fi + # Cleaning up the mess if Postgresql was not shutdown properly. + rm -vf "${PGDATA}/postmaster.pid" fi + +# Start the server +${MAMBA_RUN} ${PSQL_START_CMD} From d03f11b4afd806a84dcb2200421fd2ecb6027356 Mon Sep 17 00:00:00 2001 From: Daniel Hollas Date: Sun, 26 May 2024 18:10:17 +0100 Subject: [PATCH 24/33] To hell with it --- stack/base-with-services/Dockerfile | 7 ++++--- stack/full-stack/Dockerfile | 8 ++++---- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/stack/base-with-services/Dockerfile b/stack/base-with-services/Dockerfile index 0e5eab0c..d941153d 100644 --- a/stack/base-with-services/Dockerfile +++ b/stack/base-with-services/Dockerfile @@ -9,10 +9,11 @@ WORKDIR /opt/ ARG AIIDA_VERSION ARG PGSQL_VERSION ARG TARGETARCH + # Location of the Postgresql DB -# This variable is automatically picked up by initdb -ARG PGDATA_FOLDER=/home/${NB_USER}/.postgresql -ENV PGDATA=${PGDATA_FOLDER} +# This variable is automatically picked up by initdb and pg_ctl +# WARNING: If you change this, you have to change it in full-stack as well! +ENV PGDATA=/home/${NB_USER}/.postgresql # Install RabbitMQ and PostgreSQL in a dedicated conda environment. # diff --git a/stack/full-stack/Dockerfile b/stack/full-stack/Dockerfile index 5f684a02..2a10f234 100644 --- a/stack/full-stack/Dockerfile +++ b/stack/full-stack/Dockerfile @@ -1,17 +1,17 @@ # syntax=docker/dockerfile:1 -ARG PGDATA_FOLDER FROM base-with-services as base -ARG PGDATA_FOLDER -ENV PGDATA=${PGDATA_FOLDER} FROM lab +# WARNING: If you change this, you have to change it in base-with-services as well +ENV PGDATA="/home/${NB_USER}/.postgresql" + USER root COPY --from=base /opt/config-quick-setup.yaml /opt/ COPY --from=base "${CONDA_DIR}/envs/aiida-core-services" "${CONDA_DIR}/envs/aiida-core-services" COPY --from=base /usr/local/bin/before-notebook.d /usr/local/bin/before-notebook.d -COPY --from=base ${PGDATA_FOLDER} ${PGDATA_FOLDER} +COPY --from=base ${PGDATA} ${PGDATA} RUN fix-permissions "${CONDA_DIR}" RUN fix-permissions "/home/${NB_USER}/.aiida" From 94ab0411b923f7b5a3d2a37545d053819dbf7947 Mon Sep 17 00:00:00 2001 From: Daniel Hollas Date: Sun, 26 May 2024 18:50:09 +0100 Subject: [PATCH 25/33] Try thisA --- stack/full-stack/Dockerfile | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/stack/full-stack/Dockerfile b/stack/full-stack/Dockerfile index 2a10f234..a58e8096 100644 --- a/stack/full-stack/Dockerfile +++ b/stack/full-stack/Dockerfile @@ -6,15 +6,13 @@ FROM lab # WARNING: If you change this, you have to change it in base-with-services as well ENV PGDATA="/home/${NB_USER}/.postgresql" -USER root - COPY --from=base /opt/config-quick-setup.yaml /opt/ COPY --from=base "${CONDA_DIR}/envs/aiida-core-services" "${CONDA_DIR}/envs/aiida-core-services" COPY --from=base /usr/local/bin/before-notebook.d /usr/local/bin/before-notebook.d COPY --from=base ${PGDATA} ${PGDATA} -RUN fix-permissions "${CONDA_DIR}" -RUN fix-permissions "/home/${NB_USER}/.aiida" +#RUN fix-permissions "${CONDA_DIR}" +#RUN fix-permissions "/home/${NB_USER}/.aiida" USER ${NB_USER} From ae59bdb161b7afcdffabb195caa21bdf199900f2 Mon Sep 17 00:00:00 2001 From: Daniel Hollas Date: Sun, 26 May 2024 19:07:56 +0100 Subject: [PATCH 26/33] ? --- stack/full-stack/Dockerfile | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/stack/full-stack/Dockerfile b/stack/full-stack/Dockerfile index a58e8096..be9ed577 100644 --- a/stack/full-stack/Dockerfile +++ b/stack/full-stack/Dockerfile @@ -3,6 +3,8 @@ FROM base-with-services as base FROM lab +USER root + # WARNING: If you change this, you have to change it in base-with-services as well ENV PGDATA="/home/${NB_USER}/.postgresql" @@ -11,8 +13,9 @@ COPY --from=base "${CONDA_DIR}/envs/aiida-core-services" "${CONDA_DIR}/envs/aiid COPY --from=base /usr/local/bin/before-notebook.d /usr/local/bin/before-notebook.d COPY --from=base ${PGDATA} ${PGDATA} -#RUN fix-permissions "${CONDA_DIR}" -#RUN fix-permissions "/home/${NB_USER}/.aiida" +RUN fix-permissions "${CONDA_DIR}" +RUN fix-permissions "/home/${NB_USER}/.aiida" +RUN fix-permissions "/home/${NB_USER}/.postgresql" USER ${NB_USER} From 8378fa50fd67ef06794b4b812451adbd86f1ffb8 Mon Sep 17 00:00:00 2001 From: Daniel Hollas Date: Sun, 26 May 2024 19:24:26 +0100 Subject: [PATCH 27/33] Sigh --- stack/full-stack/Dockerfile | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/stack/full-stack/Dockerfile b/stack/full-stack/Dockerfile index be9ed577..997aebe2 100644 --- a/stack/full-stack/Dockerfile +++ b/stack/full-stack/Dockerfile @@ -5,18 +5,15 @@ FROM lab USER root -# WARNING: If you change this, you have to change it in base-with-services as well -ENV PGDATA="/home/${NB_USER}/.postgresql" - COPY --from=base /opt/config-quick-setup.yaml /opt/ COPY --from=base "${CONDA_DIR}/envs/aiida-core-services" "${CONDA_DIR}/envs/aiida-core-services" COPY --from=base /usr/local/bin/before-notebook.d /usr/local/bin/before-notebook.d -COPY --from=base ${PGDATA} ${PGDATA} RUN fix-permissions "${CONDA_DIR}" -RUN fix-permissions "/home/${NB_USER}/.aiida" -RUN fix-permissions "/home/${NB_USER}/.postgresql" USER ${NB_USER} +# WARNING: If you change this, you have to change it in base-with-services as well +ENV PGDATA="/home/${NB_USER}/.postgresql" +COPY --from=base ${PGDATA} ${PGDATA} WORKDIR "/home/${NB_USER}" From 236902b80a0ddb95695633ce81e68fbe3239c14f Mon Sep 17 00:00:00 2001 From: Daniel Hollas Date: Sun, 26 May 2024 19:37:32 +0100 Subject: [PATCH 28/33] pretty print json output --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 56c5f7f7..39ad0a30 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -74,6 +74,6 @@ jobs: - name: Set output variables id: bake_metadata run: | - .github/workflows/extract-image-names.sh | tee -a "${GITHUB_OUTPUT}" + .github/workflows/extract-image-names.sh | tee -a "${GITHUB_OUTPUT}" | jq env: BAKE_METADATA: ${{ steps.build-upload.outputs.metadata }} From 5b2d0bd46a2b1d4d1abfde6b32ade7f3136b8f61 Mon Sep 17 00:00:00 2001 From: Daniel Hollas Date: Sun, 26 May 2024 19:43:41 +0100 Subject: [PATCH 29/33] Pretty please --- stack/full-stack/Dockerfile | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/stack/full-stack/Dockerfile b/stack/full-stack/Dockerfile index 997aebe2..acde2ce9 100644 --- a/stack/full-stack/Dockerfile +++ b/stack/full-stack/Dockerfile @@ -3,17 +3,18 @@ FROM base-with-services as base FROM lab +# WARNING: If you change this, you have to change it in base-with-services as well +ENV PGDATA="/home/${NB_USER}/.postgresql" USER root COPY --from=base /opt/config-quick-setup.yaml /opt/ COPY --from=base "${CONDA_DIR}/envs/aiida-core-services" "${CONDA_DIR}/envs/aiida-core-services" COPY --from=base /usr/local/bin/before-notebook.d /usr/local/bin/before-notebook.d +COPY --from=base ${PGDATA} ${PGDATA} +RUN fix-permissions "${CONDA_DIR}" RUN fix-permissions "${CONDA_DIR}" USER ${NB_USER} -# WARNING: If you change this, you have to change it in base-with-services as well -ENV PGDATA="/home/${NB_USER}/.postgresql" -COPY --from=base ${PGDATA} ${PGDATA} WORKDIR "/home/${NB_USER}" From 2cfe15a1e0bc076416d8856451e43f4ba04e7e5e Mon Sep 17 00:00:00 2001 From: Daniel Hollas Date: Sun, 26 May 2024 19:53:09 +0100 Subject: [PATCH 30/33] hmm --- .github/workflows/build.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 39ad0a30..8a39a2ea 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -74,6 +74,7 @@ jobs: - name: Set output variables id: bake_metadata run: | - .github/workflows/extract-image-names.sh | tee -a "${GITHUB_OUTPUT}" | jq + .github/workflows/extract-image-names.sh | tee -a "${GITHUB_OUTPUT}" + echo $images | jq env: BAKE_METADATA: ${{ steps.build-upload.outputs.metadata }} From d480087ab0dea9a650a642447948b7a0ecab0296 Mon Sep 17 00:00:00 2001 From: Daniel Hollas Date: Sun, 26 May 2024 20:07:13 +0100 Subject: [PATCH 31/33] ... --- .github/workflows/build.yml | 3 +-- stack/full-stack/Dockerfile | 3 ++- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8a39a2ea..bc4ec1e3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -74,7 +74,6 @@ jobs: - name: Set output variables id: bake_metadata run: | - .github/workflows/extract-image-names.sh | tee -a "${GITHUB_OUTPUT}" - echo $images | jq + .github/workflows/extract-image-names.sh | tee -a "${GITHUB_OUTPUT}" | awk -F'=' '{print $2}' | jq env: BAKE_METADATA: ${{ steps.build-upload.outputs.metadata }} diff --git a/stack/full-stack/Dockerfile b/stack/full-stack/Dockerfile index acde2ce9..1266b3a5 100644 --- a/stack/full-stack/Dockerfile +++ b/stack/full-stack/Dockerfile @@ -10,7 +10,8 @@ USER root COPY --from=base /opt/config-quick-setup.yaml /opt/ COPY --from=base "${CONDA_DIR}/envs/aiida-core-services" "${CONDA_DIR}/envs/aiida-core-services" COPY --from=base /usr/local/bin/before-notebook.d /usr/local/bin/before-notebook.d -COPY --from=base ${PGDATA} ${PGDATA} +COPY --from=base "${PGDATA}" "${PGDATA}" +RUN chown "${NB_USER}" "${PGDATA}" RUN fix-permissions "${CONDA_DIR}" RUN fix-permissions "${CONDA_DIR}" From daa56eaa626efe62b21e802abd73e7f273ceddc3 Mon Sep 17 00:00:00 2001 From: Daniel Hollas Date: Sun, 26 May 2024 20:28:40 +0100 Subject: [PATCH 32/33] Getting closer --- stack/full-stack/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stack/full-stack/Dockerfile b/stack/full-stack/Dockerfile index 1266b3a5..5035af7f 100644 --- a/stack/full-stack/Dockerfile +++ b/stack/full-stack/Dockerfile @@ -11,10 +11,10 @@ COPY --from=base /opt/config-quick-setup.yaml /opt/ COPY --from=base "${CONDA_DIR}/envs/aiida-core-services" "${CONDA_DIR}/envs/aiida-core-services" COPY --from=base /usr/local/bin/before-notebook.d /usr/local/bin/before-notebook.d COPY --from=base "${PGDATA}" "${PGDATA}" -RUN chown "${NB_USER}" "${PGDATA}" RUN fix-permissions "${CONDA_DIR}" -RUN fix-permissions "${CONDA_DIR}" +RUN fix-permissions "/home/${NB_USER}/.aiida" +RUN chown "${NB_USER}" "${PGDATA}" USER ${NB_USER} From c08dd3dc759f63dd453bfe593acb226ff2802e4c Mon Sep 17 00:00:00 2001 From: Daniel Hollas Date: Sun, 26 May 2024 20:58:06 +0100 Subject: [PATCH 33/33] Screw this --- stack/full-stack/Dockerfile | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/stack/full-stack/Dockerfile b/stack/full-stack/Dockerfile index 5035af7f..61ea23a5 100644 --- a/stack/full-stack/Dockerfile +++ b/stack/full-stack/Dockerfile @@ -3,19 +3,21 @@ FROM base-with-services as base FROM lab -# WARNING: If you change this, you have to change it in base-with-services as well -ENV PGDATA="/home/${NB_USER}/.postgresql" USER root COPY --from=base /opt/config-quick-setup.yaml /opt/ COPY --from=base "${CONDA_DIR}/envs/aiida-core-services" "${CONDA_DIR}/envs/aiida-core-services" COPY --from=base /usr/local/bin/before-notebook.d /usr/local/bin/before-notebook.d -COPY --from=base "${PGDATA}" "${PGDATA}" RUN fix-permissions "${CONDA_DIR}" RUN fix-permissions "/home/${NB_USER}/.aiida" -RUN chown "${NB_USER}" "${PGDATA}" USER ${NB_USER} +# WARNING: If you change this, you have to change it in base-with-services as well +ENV PGDATA="/home/${NB_USER}/.postgresql" + +# Initialize the database +RUN mamba run -n aiida-core-services initdb + WORKDIR "/home/${NB_USER}"