diff --git a/.docker/aiida-core-base/s6-assets/init/aiida-prepare.sh b/.docker/aiida-core-base/s6-assets/init/aiida-prepare.sh index 690ebff536..a36783308e 100755 --- a/.docker/aiida-core-base/s6-assets/init/aiida-prepare.sh +++ b/.docker/aiida-core-base/s6-assets/init/aiida-prepare.sh @@ -5,34 +5,19 @@ # Environment. export SHELL=/bin/bash -# Configure AiiDA. -export SETUP_DEFAULT_AIIDA_PROFILE=true -export AIIDA_PROFILE_NAME=default -export AIIDA_USER_EMAIL=aiida@localhost -export AIIDA_USER_FIRST_NAME=Giuseppe -export AIIDA_USER_LAST_NAME=Verdi -export AIIDA_USER_INSTITUTION=Khedivial -export AIIDA_PROFILE_PATH=/aiida/assets/config-quick-setup.yaml - # 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 - NEED_SETUP_PROFILE=true; -else - NEED_SETUP_PROFILE=false; -fi - -# Setup AiiDA profile if needed. -if [[ ${NEED_SETUP_PROFILE} == true ]]; then +# If the environment variable `SETUP_DEFAULT_AIIDA_PROFILE` is not set, set it to `true`. +if [[ ${SETUP_DEFAULT_AIIDA_PROFILE:-true} == true ]] && ! verdi profile show ${AIIDA_PROFILE_NAME} &> /dev/null; then # Create AiiDA profile. verdi quicksetup \ --non-interactive \ - --profile "${AIIDA_PROFILE_NAME}" \ - --email "${AIIDA_USER_EMAIL}" \ - --first-name "${AIIDA_USER_FIRST_NAME}" \ - --last-name "${AIIDA_USER_LAST_NAME}" \ - --institution "${AIIDA_USER_INSTITUTION}" \ - --config "${AIIDA_PROFILE_PATH}" + --profile "${AIIDA_PROFILE_NAME:-default}" \ + --email "${AIIDA_USER_EMAIL:-aiida@localhost}" \ + --first-name "${AIIDA_USER_FIRST_NAME:-Giuseppe}" \ + --last-name "${AIIDA_USER_LAST_NAME:-Verdi}" \ + --institution "${AIIDA_USER_INSTITUTION:-Khedivial}" \ + --config "${AIIDA_CONFIG_FILE:-/aiida/assets/config-quick-setup.yaml}" # Supress verdi version warning because we are using a development version verdi config set warnings.development_version False @@ -76,11 +61,11 @@ if [[ ${NEED_SETUP_PROFILE} == true ]]; then verdi computer configure core.local "${computer_name}" \ --non-interactive \ --safe-interval 0.0 + + # Migration will run for the default profile. + verdi storage migrate --force fi # Show the default profile verdi profile show || echo "The default profile is not set." - -# Migration will run for the default profile. -verdi storage migrate --force diff --git a/docs/source/intro/run_docker.rst b/docs/source/intro/run_docker.rst index e842d0cf28..5baa1b53b3 100644 --- a/docs/source/intro/run_docker.rst +++ b/docs/source/intro/run_docker.rst @@ -33,6 +33,22 @@ This image contains a fully pre-configured AiiDA environment which makes it part $ docker run -it --name aiida-container aiidateam/aiida-core-with-services:latest bash + By default, an AiiDA profile is automatically set up inside the container. + To disable this default profile being created, set the ``SETUP_DEFAULT_AIIDA_PROFILE`` environment variable to ``false``. + + The following environment variables can be set to configure the default AiiDA profile: + - ``AIIDA_PROFILE_NAME``: the name of the profile to be created (default: ``default``) + - ``AIIDA_USER_EMAIL``: the email of the default user to be created (default: ``aiida@localhost``) + - ``AIIDA_USER_FIRST_NAME``: the first name of the default user to be created (default: ``Giuseppe``) + - ``AIIDA_USER_LAST_NAME``: the last name of the default user to be created (default: ``Verdi``) + - ``AIIDA_USER_INSTITUTION``: the institution of the default user to be created (default: ``Khedivial``) + - ``AIIDA_CONFIG_FILE``: the path to the AiiDA configuration file used for other profile configuration parameters (default: ``/aiida/assets/config-quick-setup.yaml``). + + These environment variables can be set when starting the container with the ``-e`` option. + + Please note that the ``AIIDA_CONFIG_FILE`` variable points to a path inside the container. + Therefore, if you want to use a custom configuration file, it needs to be mounted from the host path to the container path. + .. grid-item-card:: Check setup The profile named ``default`` is created under the ``aiida`` user.