Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build docker image based on aiida-prerequisites #3722

Merged
merged 10 commits into from
Jan 25, 2020
4 changes: 4 additions & 0 deletions .docker/my_init.d/configure-aiida.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash
set -em

su -c /opt/configure-aiida.sh $SYSTEM_USER
60 changes: 60 additions & 0 deletions .docker/opt/configure-aiida.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#!/bin/bash

# This script is executed whenever the docker container is (re)started.

# Debugging.
set -x

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

# Setup AiiDA autocompletion.
grep _VERDI_COMPLETE .bash_profile &> /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-backend "${AIIDADB_BACKEND}"

# Setup and configure local computer.
computer_name=localhost
verdi computer show $computer_name || verdi computer setup \
--non-interactive \
--label "${computer_name}" \
--description "${this computer}" \
--hostname "${computer_name}" \
--transport local \
--scheduler direct \
--work-dir /home/aiida/aiida_run/ \
--mpirun-command "mpirun -np {tot_num_mpiprocs}" \
--mpiprocs-per-machine 1 && \
verdi computer configure local "${computer_name}" \
--non-interactive \
--safe-interval 0.0
fi


# Show the default profile
verdi profile show || echo "The default profile is not set."

# Migration will run for the default profile.
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."
27 changes: 27 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -159,3 +159,30 @@ jobs:
run: |
verdi devel check-load-time
.github/workflows/verdi.sh

docker:
runs-on: ubuntu-latest
timeout-minutes: 30

steps:
- uses: actions/checkout@v1

- name: Install docker
run: |
sudo apt-get update
sudo apt-get install apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
sudo apt-get update
sudo apt-get install docker-ce

- name: Build the aiida-core image and run it
run: |
docker build -t aiida-core .
docker run -d aiida-core

- name: Check that default AiiDA profile was set up
run: |
export DOCKERID=`docker ps -qf 'ancestor=aiida-core'`
docker exec --tty $DOCKERID wait-for-services
docker exec --tty --user aiida $DOCKERID /bin/bash -l -c 'verdi profile show default'
25 changes: 25 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
FROM aiidateam/aiida-prerequisites:latest

USER root

ENV SETUP_DEFAULT_PROFILE true

ENV PROFILE_NAME default
ENV USER_EMAIL aiida@localhost
ENV USER_FIRST_NAME Giuseppe
ENV USER_LAST_NAME Verdi
ENV USER_INSTITUTION Khedivial
ENV AIIDADB_BACKEND django

# Copy and install AiiDA
COPY . aiida-core
yakutovicha marked this conversation as resolved.
Show resolved Hide resolved
RUN pip install ./aiida-core

# Configure aiida for the user
COPY .docker/opt/configure-aiida.sh /opt/configure-aiida.sh
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