Public Repository

Last pushed: 2 years ago
Short Description
Postgres freshly built from source, not yet configured
Full Description

This image was built by hand. It contains a freshly built, not yet configured, Postgres with standard extensions. This is the base for building a leaner postgres image; the base is the official debian:jessie image with a staticaly compiled docker added to it. Base debian only contains C and POSIX locales, so before using initdb make sure to build the desired locales first.

Use it to configure and package a leaner postgres image (like for example communitycloud/postgres). To run and create the docker image, make sure to map the docker socket:

docker run --rm \
           --name pg-pack \
           --hostname pg-pack \
           -v /var/run/docker.sock:/var/run/docker.sock \
           -it communitycloud/postgres-source-build

One way to configure a limited set of locales by hand:

cat > /etc/locale.gen <<EOF
en_US.UTF-8 UTF-8
fr_FR.UTF-8 UTF-8
pt_BR.UTF-8 UTF-8
es_ES.UTF-8 UTF-8
ru_RU.UTF-8 UTF-8
ru_UA.UTF-8 UTF-8
de_DE.UTF-8 UTF-8
zh_CN.UTF-8 UTF-8
ar_JO.UTF-8 UTF-8


The other way is to run dpkg-reconfigure locales.

Build Process

The image was built by hand, though it is certainly possible to reach this stage through a dockerfile as well:

docker run --rm \
           --name pg-builder \
           --hostname pg-builder \
           -v /var/run/docker.sock:/var/run/docker.sock \
           -it communitycloud/docker-builder

communitycloud/docker-builder is a bare-bones Debian jessie official image with a statically compiled docker 1.4.1 binary copied into it.

To get the latest Postgres stuff, we'll need to add postgres sources first to apt, as described on the postgres wiki:

echo "deb jessie-pgdg main" > /etc/apt/sources.list.d/pgdg.list \
&& apt-get update && DEBIAN_FRONTEND=noninteractive \
&& apt-get install -y wget ca-certificates sudo \
&& wget --quiet -O - | sudo apt-key add - \
&& apt-get update \
&& apt-get install -y build-essential tree strace libreadline-dev libncurses5-dev \
                      libpcre3-dev libssl-dev perl libpq-dev libossp-uuid-dev locales

Now that we have all prerequisites, building Postgres is fairly straightforward. We'll use /opt as the root:

wget \
&& bunzip2 postgresql-9.4.1.tar.bz2 \
&& tar -xf postgresql-9.4.1.tar \
&& rm postgresql-9.4.1.tar \
&& cd postgresql-* \
&& ./configure \
    --prefix=/opt/pgsql \
    --with-openssl \
    --with-ossp-uuid \
&& make world \
&& make install-world \
&& cd .. \
&& rm -rf postgresql-* \
&& ldconfig

rm -rf /var/lib/apt/lists

docker commit pg-builder communitycloud/postgres-source-build:
Docker Pull Command

Comments (0)