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

Install PostgreSQL into pgsql conda environment. #49

Merged
merged 3 commits into from
Jul 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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