Skip to content

Commit

Permalink
Docker: install aiida in conda environment, fix .bashrc (#3745)
Browse files Browse the repository at this point in the history
fixes #3739 

In the latest update of the aiida-prerequisites image, python is provided
within conda environment. Respectively, this PR adapts aiida-core image
to use python from conda. Also, it fixes autocompletion enabling in user's
.bashrc file
  • Loading branch information
yakutovicha authored Feb 7, 2020
1 parent 5b892ca commit 48573df
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 10 deletions.
21 changes: 18 additions & 3 deletions .docker/opt/configure-aiida.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,26 @@
set -x

# Environment.
reentry scan
export SHELL=/bin/bash

# Activate conda.
__conda_setup="$('/opt/conda/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
eval "$__conda_setup"
else
if [ -f "/opt/conda/etc/profile.d/conda.sh" ]; then
. "/opt/conda/etc/profile.d/conda.sh"
else
export PATH="/opt/conda/bin:$PATH"
fi
fi
unset __conda_setup

# Very important to run after conda activation, otherwise AiiDA won't work.
reentry scan

# Setup AiiDA autocompletion.
grep _VERDI_COMPLETE .bash_profile &> /dev/null || echo 'eval "$(_VERDI_COMPLETE=source verdi)"' >> /home/$SYSTEM_USER/.bashrc
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
Expand Down Expand Up @@ -57,4 +72,4 @@ verdi profile show || echo "The default profile is not set."
verdi database 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."
verdi daemon start || echo "AiiDA daemon is not running."
10 changes: 5 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -176,14 +176,14 @@ jobs:
sudo apt-get update
sudo apt-get install docker-ce
- name: Build the aiida-core image and run it
run: |
- name: Build the aiida-core image
run:
docker build -t aiida-core .
docker run -d aiida-core

- name: Check that default AiiDA profile was set up
- name: Run aiida-core image and test the default aiida profile and localhost computer.
run: |
export DOCKERID=`docker ps -qf 'ancestor=aiida-core'`
export DOCKERID=`docker run -d aiida-core`
docker exec --tty $DOCKERID wait-for-services
docker logs $DOCKERID
docker exec --tty --user aiida $DOCKERID /bin/bash -l -c 'verdi profile show default'
docker exec --tty --user aiida $DOCKERID /bin/bash -l -c 'verdi computer show localhost'
2 changes: 0 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,3 @@ COPY .docker/my_init.d/configure-aiida.sh /etc/my_init.d/40_configure-aiida.sh

# Use phusion baseimage docker init system.
CMD ["/sbin/my_init"]

#EOF

0 comments on commit 48573df

Please sign in to comment.