Skip to content

Commit

Permalink
Install PostgreSQL into pgsql conda environment. (#49)
Browse files Browse the repository at this point in the history
Install PGSQL=10 into dedicated conda environment to be compatible
with the stable AiiDA/AiiDAlab images out there.
  • Loading branch information
yakutovicha committed Jul 25, 2022
1 parent 04371ed commit 47727a4
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build_and_test_on_pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:
export DOCKERID=`docker run -v $PWD/tmp:/home/aiida -d aiida-prerequisites:latest`
docker exec --tty --user root $DOCKERID wait-for-services
docker exec --tty --user aiida $DOCKERID wait-for-services
docker exec --tty --user aiida $DOCKERID /bin/bash -l -c '/usr/lib/postgresql/14/bin/pg_ctl -D /home/$SYSTEM_USER/.postgresql status' # Check that postgres is up.
docker exec --tty --user aiida $DOCKERID /bin/bash -l -c '/opt/conda/envs/pgsql/bin/pg_ctl -D /home/$SYSTEM_USER/.postgresql status' # Check that postgres is up.
docker exec --tty --user root $DOCKERID /bin/bash -l -c 'service rabbitmq-server status' # Check that rabbitmq is up.
docker exec --tty --user aiida $DOCKERID /bin/bash -l -c 'conda create -y -n test_env python=3.8' # Check that one can create a new conda environment.
docker exec --tty --user aiida $DOCKERID /bin/bash -l -c 'conda activate test_env' # Check that new environment works.
Expand Down
4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
graphviz \
locales \
less \
postgresql \
psmisc \
rabbitmq-server \
rsync \
Expand Down Expand Up @@ -93,6 +92,9 @@ RUN cd /tmp && \
conda update --all --quiet --yes && \
conda clean --all -f -y

# Install PostgreSQL in a dedicated conda environment.
RUN conda create -c conda-forge -n pgsql postgresql=10.6 && conda clean --all -f -y

# Copy the script load-singlesshagent.sh to /usr/local/bin.
COPY bin/load-singlesshagent.sh /usr/local/bin/load-singlesshagent.sh

Expand Down
12 changes: 6 additions & 6 deletions opt/start-postgres.sh
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
#!/bin/bash

PGSQL_VERSION=14
PGBIN=/usr/lib/postgresql/${PGSQL_VERSION}/bin
# Activate the conda environment with PostgreSQL installed in it.
conda activate pgsql

# -w waits until server is up
PSQL_START_CMD="${PGBIN}/pg_ctl --timeout=180 -w -D /home/${SYSTEM_USER}/.postgresql -l /home/${SYSTEM_USER}/.postgresql/logfile start"
PSQL_STOP_CMD="${PGBIN}/pg_ctl -w -D /home/${SYSTEM_USER}/.postgresql stop"
PSQL_STATUS_CMD="${PGBIN}/pg_ctl -D /home/${SYSTEM_USER}/.postgresql status"
PSQL_START_CMD="pg_ctl --timeout=180 -w -D /home/${SYSTEM_USER}/.postgresql -l /home/${SYSTEM_USER}/.postgresql/logfile start"
PSQL_STOP_CMD="pg_ctl -w -D /home/${SYSTEM_USER}/.postgresql stop"
PSQL_STATUS_CMD="pg_ctl -D /home/${SYSTEM_USER}/.postgresql status"

# make DB directory, if not existent
if [ ! -d /home/${SYSTEM_USER}/.postgresql ]; then
mkdir /home/${SYSTEM_USER}/.postgresql
${PGBIN}/initdb -D /home/${SYSTEM_USER}/.postgresql
initdb -D /home/${SYSTEM_USER}/.postgresql
echo "unix_socket_directories = '/tmp'" >> /home/${SYSTEM_USER}/.postgresql/postgresql.conf
${PSQL_START_CMD}

Expand Down

0 comments on commit 47727a4

Please sign in to comment.