Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save unkcpz/3846735193f9ddacadc598000aab9da1 to your computer and use it in GitHub Desktop.
Save unkcpz/3846735193f9ddacadc598000aab9da1 to your computer and use it in GitHub Desktop.
AiiDA production setup with containerized Postgresql & Rabbitmq

Why?

As of May 4th, 2021, erlang is not available from macports for the ARM (Apple Silicon) platform. Docker containers make it super easy to install postgresql and rabbitmq.

The M1 chips have great parallelism, so I'd hope to be able to run docker without noticing the overhead too much. I could use conda as well, but docker provides the neat docker-compose.yaml that makes it possible to start up and shut down all the services required with a single command.

Task

Switch from previous setup with rabbitmq and postgresql installed via macports (could also be brew, manual compilation, ...) to a setup with containerized services.

  1. Copy your postgresql database directory to a new directory db
  2. Add the following lines to the pg_hba.conf file:
    # Note: the order is relevant! The first line that matches applies
    # TYPE  DATABASE  USER  ADDRESS     METHOD
    host all postgres host.docker.internal trust   # give passwordless access to postgres user to your host
    host all all host.docker.internal md5          # password-protected access to all other users
    
    Note: If not on MacOS, host.docker.internal may not work (you can just try all)
  3. docker-compose.yaml
version: '3.4'

services:

  rabbit:
    image: rabbitmq:3.8.3-management
    container_name: aiida-rmq
    environment:
        RABBITMQ_DEFAULT_USER: guest
        RABBITMQ_DEFAULT_PASS: guest
    ports:
      - '5672:5672'
      - '15672:15672'
    healthcheck:
      test: rabbitmq-diagnostics -q ping
      interval: 30s
      timeout: 30s
      retries: 5
    networks:
      - aiida-rmq

  postgresql:
    image: postgres:9
    container_name: aiida-postgres
    ports:
      - '5432:5432'
    networks:
      - aiida-rmq
    volumes:
      - ./db:/var/lib/postgresql/data

networks:
  aiida-rmq:
  1. docker-compose up -d
  2. Install psql binaries (if not yet present). Try psql -h localhost -U postgres (should work without password)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment