Skip to content

Instantly share code, notes, and snippets.

@spinolacastro
Created September 28, 2016 11:57
Show Gist options
  • Save spinolacastro/1460b8c216a4cfe696d51fb7754eeb02 to your computer and use it in GitHub Desktop.
Save spinolacastro/1460b8c216a4cfe696d51fb7754eeb02 to your computer and use it in GitHub Desktop.
FROM centos:centos7
# PostgreSQL image for OpenShift.
# Volumes:
# * /var/lib/psql/data - Database cluster for PostgreSQL
# Environment:
# * $POSTGRESQL_USER - Database user name
# * $POSTGRESQL_PASSWORD - User's password
# * $POSTGRESQL_DATABASE - Name of the database to create
# * $POSTGRESQL_ADMIN_PASSWORD (Optional) - Password for the 'postgres'
# PostgreSQL administrative account
MAINTAINER SoftwareCollections.org <[email protected]>
ENV POSTGRESQL_VERSION=9.4 \
HOME=/var/lib/pgsql \
PGUSER=postgres
LABEL io.k8s.description="PostgreSQL is an advanced Object-Relational database management system" \
io.k8s.display-name="PostgreSQL 9.4" \
io.openshift.expose-services="5432:postgresql" \
io.openshift.tags="database,postgresql,postgresql94,rh-postgresql94"
EXPOSE 5432
ADD root /
# This image must forever use UID 26 for postgres user so our volumes are
# safe in the future. This should *never* change, the last test is there
# to make sure of that.
RUN yum install -y centos-release-scl epel-release && \
INSTALL_PKGS="rsync tar gettext bind-utils rh-postgresql94 rh-postgresql94-postgresql rh-postgresql94-postgresql-contrib rh-postgresql94-postgresql-devel nss_wrapper gcc-c++ make libxml2-devel geos-devel proj-devel gdal-devel" && \
yum -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
rpm -V $INSTALL_PKGS && \
yum clean all && \
localedef -f UTF-8 -i en_US en_US.UTF-8 && \
test "$(id postgres)" = "uid=26(postgres) gid=26(postgres) groups=26(postgres)" && \
mkdir -p /var/lib/pgsql/data && \
/usr/libexec/fix-permissions /var/lib/pgsql && \
/usr/libexec/fix-permissions /var/run/postgresql
RUN curl http://download.osgeo.org/postgis/source/postgis-2.2.2.tar.gz -O && \
tar zxf postgis-2.2.2.tar.gz && \
cd postgis-2.2.2 && scl enable rh-postgresql94 './configure && make && make install'
# Get prefix path and path to scripts rather than hard-code them in scripts
ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql \
ENABLED_COLLECTIONS=rh-postgresql94
# When bash is started non-interactively, to run a shell script, for example it
# looks for this variable and source the content of this file. This will enable
# the SCL for all scripts without need to do 'scl enable'.
ENV BASH_ENV=${CONTAINER_SCRIPTS_PATH}/scl_enable \
ENV=${CONTAINER_SCRIPTS_PATH}/scl_enable \
PROMPT_COMMAND=". ${CONTAINER_SCRIPTS_PATH}/scl_enable"
VOLUME ["/var/lib/pgsql/data"]
USER 26
ENTRYPOINT ["container-entrypoint"]
CMD ["run-postgresql"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment