Docker - How is it possible to make/make install an extension in a Docker container?

Viewed 2168

I am using the posgres:10.0 image to run PostgreSQL inside a container. My docker-compose.yml looks fairly simple:

version: "2"
services:
  db:
    image: "postgres:10.0"
    environment:
    - POSTGRES_USER=postgres
    - POSTGRES_DB=postgres
    volumes:
    - ./volumes/postgresql/postgresql.sh:/docker-entrypoint-initdb.d/postgresql.sh
    ports:
    - 5432:5432

postgresql.sh:

#!/bin/bash

echo wal_level=logical              >> $PGDATA/postgresql.auto.conf
echo max_replication_slots=1        >> $PGDATA/postgresql.auto.conf
echo host replication all all trust >> $PGDATA/pg_hba.conf

For my project, we will start using the Multicorn extension, see http://multicorn.org/. To make/make install this, I need to do:

git clone git://github.com/Kozea/Multicorn.git
cd Multicorn
make && make install

Then afterwards, I can add a multicorn.sql script and add it to the /docker-entrypoint-initdb.d/ directory, which will be called when the Docker container is starting up:

CREATE EXTENSION multicorn;

But how can I make/make install Multicorn within the Docker container? Ideally, I want to keep using the posgres:10.0 and not invent/create my own version, as I don't want to inherit the maintenance hassle.

1 Answers
Related