diff --git a/postgres/8.4/Dockerfile b/postgres/8.4/Dockerfile new file mode 100644 index 000000000..d3be0ad93 --- /dev/null +++ b/postgres/8.4/Dockerfile @@ -0,0 +1,44 @@ +# vim:set ft=dockerfile: +FROM debian:wheezy + +# add our user and group first to make sure their IDs get assigned consistently, regardless of whatever dependencies get added +RUN groupadd -r postgres && useradd -r -g postgres postgres + +# grab gosu for easy step-down from root +RUN apt-get update && apt-get install -y curl && rm -rf /var/lib/apt/lists/* \ + && curl -o /usr/local/bin/gosu -SL 'https://github.com/tianon/gosu/releases/download/1.1/gosu' \ + && chmod +x /usr/local/bin/gosu \ + && apt-get purge -y --auto-remove curl + +# make the "en_US.UTF-8" locale so postgres will be utf-8 enabled by default +RUN apt-get update && apt-get install -y locales && rm -rf /var/lib/apt/lists/* \ + && localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8 +ENV LANG en_US.utf8 + +RUN apt-key adv --keyserver pgp.mit.edu --recv-keys B97B0AFCAA1A47F044F244A07FCC7D46ACCC4CF8 + +ENV PG_MAJOR 8.4 +ENV PG_VERSION 8.4.22-1.pgdg70+1 + +RUN echo 'deb http://apt.postgresql.org/pub/repos/apt/ wheezy-pgdg main' $PG_MAJOR > /etc/apt/sources.list.d/pgdg.list + +RUN apt-get update \ + && apt-get install -y postgresql-common \ + && sed -ri 's/#(create_main_cluster) .*$/\1 = false/' /etc/postgresql-common/createcluster.conf \ + && apt-get install -y \ + postgresql-$PG_MAJOR=$PG_VERSION \ + postgresql-contrib-$PG_MAJOR=$PG_VERSION \ + && rm -rf /var/lib/apt/lists/* + +RUN mkdir -p /var/run/postgresql && chown -R postgres /var/run/postgresql + +ENV PATH /usr/lib/postgresql/$PG_MAJOR/bin:$PATH +ENV PGDATA /var/lib/postgresql/data +VOLUME /var/lib/postgresql/data + +COPY ./docker-entrypoint.sh / + +ENTRYPOINT ["/docker-entrypoint.sh"] + +EXPOSE 5432 +CMD ["postgres"] diff --git a/postgres/8.4/docker-entrypoint.sh b/postgres/8.4/docker-entrypoint.sh new file mode 100755 index 000000000..8011908ac --- /dev/null +++ b/postgres/8.4/docker-entrypoint.sh @@ -0,0 +1,24 @@ +#!/bin/bash +set -e + +if [ "$1" = 'postgres' ]; then + chown -R postgres "$PGDATA" + + if [ -z "$(ls -A "$PGDATA")" ]; then + gosu postgres initdb + + sed -ri "s/^#(listen_addresses\s*=\s*)\S+/\1'*'/" "$PGDATA"/postgresql.conf + + { echo; echo 'host all all 0.0.0.0/0 trust'; } >> "$PGDATA"/pg_hba.conf + + if [ -d /docker-entrypoint-initdb.d ]; then + for f in /docker-entrypoint-initdb.d/*.sh; do + [ -f "$f" ] && . "$f" + done + fi + fi + + exec gosu postgres "$@" +fi + +exec "$@" diff --git a/postgres/9.0/Dockerfile b/postgres/9.0/Dockerfile new file mode 100644 index 000000000..927494498 --- /dev/null +++ b/postgres/9.0/Dockerfile @@ -0,0 +1,44 @@ +# vim:set ft=dockerfile: +FROM debian:wheezy + +# add our user and group first to make sure their IDs get assigned consistently, regardless of whatever dependencies get added +RUN groupadd -r postgres && useradd -r -g postgres postgres + +# grab gosu for easy step-down from root +RUN apt-get update && apt-get install -y curl && rm -rf /var/lib/apt/lists/* \ + && curl -o /usr/local/bin/gosu -SL 'https://github.com/tianon/gosu/releases/download/1.1/gosu' \ + && chmod +x /usr/local/bin/gosu \ + && apt-get purge -y --auto-remove curl + +# make the "en_US.UTF-8" locale so postgres will be utf-8 enabled by default +RUN apt-get update && apt-get install -y locales && rm -rf /var/lib/apt/lists/* \ + && localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8 +ENV LANG en_US.utf8 + +RUN apt-key adv --keyserver pgp.mit.edu --recv-keys B97B0AFCAA1A47F044F244A07FCC7D46ACCC4CF8 + +ENV PG_MAJOR 9.0 +ENV PG_VERSION 9.0.18-1.pgdg70+1 + +RUN echo 'deb http://apt.postgresql.org/pub/repos/apt/ wheezy-pgdg main' $PG_MAJOR > /etc/apt/sources.list.d/pgdg.list + +RUN apt-get update \ + && apt-get install -y postgresql-common \ + && sed -ri 's/#(create_main_cluster) .*$/\1 = false/' /etc/postgresql-common/createcluster.conf \ + && apt-get install -y \ + postgresql-$PG_MAJOR=$PG_VERSION \ + postgresql-contrib-$PG_MAJOR=$PG_VERSION \ + && rm -rf /var/lib/apt/lists/* + +RUN mkdir -p /var/run/postgresql && chown -R postgres /var/run/postgresql + +ENV PATH /usr/lib/postgresql/$PG_MAJOR/bin:$PATH +ENV PGDATA /var/lib/postgresql/data +VOLUME /var/lib/postgresql/data + +COPY ./docker-entrypoint.sh / + +ENTRYPOINT ["/docker-entrypoint.sh"] + +EXPOSE 5432 +CMD ["postgres"] diff --git a/postgres/9.0/docker-entrypoint.sh b/postgres/9.0/docker-entrypoint.sh new file mode 100755 index 000000000..8011908ac --- /dev/null +++ b/postgres/9.0/docker-entrypoint.sh @@ -0,0 +1,24 @@ +#!/bin/bash +set -e + +if [ "$1" = 'postgres' ]; then + chown -R postgres "$PGDATA" + + if [ -z "$(ls -A "$PGDATA")" ]; then + gosu postgres initdb + + sed -ri "s/^#(listen_addresses\s*=\s*)\S+/\1'*'/" "$PGDATA"/postgresql.conf + + { echo; echo 'host all all 0.0.0.0/0 trust'; } >> "$PGDATA"/pg_hba.conf + + if [ -d /docker-entrypoint-initdb.d ]; then + for f in /docker-entrypoint-initdb.d/*.sh; do + [ -f "$f" ] && . "$f" + done + fi + fi + + exec gosu postgres "$@" +fi + +exec "$@" diff --git a/postgres/9.1/Dockerfile b/postgres/9.1/Dockerfile new file mode 100644 index 000000000..b58fbdd6e --- /dev/null +++ b/postgres/9.1/Dockerfile @@ -0,0 +1,44 @@ +# vim:set ft=dockerfile: +FROM debian:wheezy + +# add our user and group first to make sure their IDs get assigned consistently, regardless of whatever dependencies get added +RUN groupadd -r postgres && useradd -r -g postgres postgres + +# grab gosu for easy step-down from root +RUN apt-get update && apt-get install -y curl && rm -rf /var/lib/apt/lists/* \ + && curl -o /usr/local/bin/gosu -SL 'https://github.com/tianon/gosu/releases/download/1.1/gosu' \ + && chmod +x /usr/local/bin/gosu \ + && apt-get purge -y --auto-remove curl + +# make the "en_US.UTF-8" locale so postgres will be utf-8 enabled by default +RUN apt-get update && apt-get install -y locales && rm -rf /var/lib/apt/lists/* \ + && localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8 +ENV LANG en_US.utf8 + +RUN apt-key adv --keyserver pgp.mit.edu --recv-keys B97B0AFCAA1A47F044F244A07FCC7D46ACCC4CF8 + +ENV PG_MAJOR 9.1 +ENV PG_VERSION 9.1.14-1.pgdg70+1 + +RUN echo 'deb http://apt.postgresql.org/pub/repos/apt/ wheezy-pgdg main' $PG_MAJOR > /etc/apt/sources.list.d/pgdg.list + +RUN apt-get update \ + && apt-get install -y postgresql-common \ + && sed -ri 's/#(create_main_cluster) .*$/\1 = false/' /etc/postgresql-common/createcluster.conf \ + && apt-get install -y \ + postgresql-$PG_MAJOR=$PG_VERSION \ + postgresql-contrib-$PG_MAJOR=$PG_VERSION \ + && rm -rf /var/lib/apt/lists/* + +RUN mkdir -p /var/run/postgresql && chown -R postgres /var/run/postgresql + +ENV PATH /usr/lib/postgresql/$PG_MAJOR/bin:$PATH +ENV PGDATA /var/lib/postgresql/data +VOLUME /var/lib/postgresql/data + +COPY ./docker-entrypoint.sh / + +ENTRYPOINT ["/docker-entrypoint.sh"] + +EXPOSE 5432 +CMD ["postgres"] diff --git a/postgres/9.1/docker-entrypoint.sh b/postgres/9.1/docker-entrypoint.sh new file mode 100755 index 000000000..8011908ac --- /dev/null +++ b/postgres/9.1/docker-entrypoint.sh @@ -0,0 +1,24 @@ +#!/bin/bash +set -e + +if [ "$1" = 'postgres' ]; then + chown -R postgres "$PGDATA" + + if [ -z "$(ls -A "$PGDATA")" ]; then + gosu postgres initdb + + sed -ri "s/^#(listen_addresses\s*=\s*)\S+/\1'*'/" "$PGDATA"/postgresql.conf + + { echo; echo 'host all all 0.0.0.0/0 trust'; } >> "$PGDATA"/pg_hba.conf + + if [ -d /docker-entrypoint-initdb.d ]; then + for f in /docker-entrypoint-initdb.d/*.sh; do + [ -f "$f" ] && . "$f" + done + fi + fi + + exec gosu postgres "$@" +fi + +exec "$@" diff --git a/postgres/9.2/Dockerfile b/postgres/9.2/Dockerfile new file mode 100644 index 000000000..91bd7a326 --- /dev/null +++ b/postgres/9.2/Dockerfile @@ -0,0 +1,44 @@ +# vim:set ft=dockerfile: +FROM debian:wheezy + +# add our user and group first to make sure their IDs get assigned consistently, regardless of whatever dependencies get added +RUN groupadd -r postgres && useradd -r -g postgres postgres + +# grab gosu for easy step-down from root +RUN apt-get update && apt-get install -y curl && rm -rf /var/lib/apt/lists/* \ + && curl -o /usr/local/bin/gosu -SL 'https://github.com/tianon/gosu/releases/download/1.1/gosu' \ + && chmod +x /usr/local/bin/gosu \ + && apt-get purge -y --auto-remove curl + +# make the "en_US.UTF-8" locale so postgres will be utf-8 enabled by default +RUN apt-get update && apt-get install -y locales && rm -rf /var/lib/apt/lists/* \ + && localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8 +ENV LANG en_US.utf8 + +RUN apt-key adv --keyserver pgp.mit.edu --recv-keys B97B0AFCAA1A47F044F244A07FCC7D46ACCC4CF8 + +ENV PG_MAJOR 9.2 +ENV PG_VERSION 9.2.9-1.pgdg70+1 + +RUN echo 'deb http://apt.postgresql.org/pub/repos/apt/ wheezy-pgdg main' $PG_MAJOR > /etc/apt/sources.list.d/pgdg.list + +RUN apt-get update \ + && apt-get install -y postgresql-common \ + && sed -ri 's/#(create_main_cluster) .*$/\1 = false/' /etc/postgresql-common/createcluster.conf \ + && apt-get install -y \ + postgresql-$PG_MAJOR=$PG_VERSION \ + postgresql-contrib-$PG_MAJOR=$PG_VERSION \ + && rm -rf /var/lib/apt/lists/* + +RUN mkdir -p /var/run/postgresql && chown -R postgres /var/run/postgresql + +ENV PATH /usr/lib/postgresql/$PG_MAJOR/bin:$PATH +ENV PGDATA /var/lib/postgresql/data +VOLUME /var/lib/postgresql/data + +COPY ./docker-entrypoint.sh / + +ENTRYPOINT ["/docker-entrypoint.sh"] + +EXPOSE 5432 +CMD ["postgres"] diff --git a/postgres/9.2/docker-entrypoint.sh b/postgres/9.2/docker-entrypoint.sh new file mode 100755 index 000000000..8011908ac --- /dev/null +++ b/postgres/9.2/docker-entrypoint.sh @@ -0,0 +1,24 @@ +#!/bin/bash +set -e + +if [ "$1" = 'postgres' ]; then + chown -R postgres "$PGDATA" + + if [ -z "$(ls -A "$PGDATA")" ]; then + gosu postgres initdb + + sed -ri "s/^#(listen_addresses\s*=\s*)\S+/\1'*'/" "$PGDATA"/postgresql.conf + + { echo; echo 'host all all 0.0.0.0/0 trust'; } >> "$PGDATA"/pg_hba.conf + + if [ -d /docker-entrypoint-initdb.d ]; then + for f in /docker-entrypoint-initdb.d/*.sh; do + [ -f "$f" ] && . "$f" + done + fi + fi + + exec gosu postgres "$@" +fi + +exec "$@" diff --git a/postgres/9.3/Dockerfile b/postgres/9.3/Dockerfile new file mode 100644 index 000000000..487e748bd --- /dev/null +++ b/postgres/9.3/Dockerfile @@ -0,0 +1,44 @@ +# vim:set ft=dockerfile: +FROM debian:wheezy + +# add our user and group first to make sure their IDs get assigned consistently, regardless of whatever dependencies get added +RUN groupadd -r postgres && useradd -r -g postgres postgres + +# grab gosu for easy step-down from root +RUN apt-get update && apt-get install -y curl && rm -rf /var/lib/apt/lists/* \ + && curl -o /usr/local/bin/gosu -SL 'https://github.com/tianon/gosu/releases/download/1.1/gosu' \ + && chmod +x /usr/local/bin/gosu \ + && apt-get purge -y --auto-remove curl + +# make the "en_US.UTF-8" locale so postgres will be utf-8 enabled by default +RUN apt-get update && apt-get install -y locales && rm -rf /var/lib/apt/lists/* \ + && localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8 +ENV LANG en_US.utf8 + +RUN apt-key adv --keyserver pgp.mit.edu --recv-keys B97B0AFCAA1A47F044F244A07FCC7D46ACCC4CF8 + +ENV PG_MAJOR 9.3 +ENV PG_VERSION 9.3.5-1.pgdg70+1 + +RUN echo 'deb http://apt.postgresql.org/pub/repos/apt/ wheezy-pgdg main' $PG_MAJOR > /etc/apt/sources.list.d/pgdg.list + +RUN apt-get update \ + && apt-get install -y postgresql-common \ + && sed -ri 's/#(create_main_cluster) .*$/\1 = false/' /etc/postgresql-common/createcluster.conf \ + && apt-get install -y \ + postgresql-$PG_MAJOR=$PG_VERSION \ + postgresql-contrib-$PG_MAJOR=$PG_VERSION \ + && rm -rf /var/lib/apt/lists/* + +RUN mkdir -p /var/run/postgresql && chown -R postgres /var/run/postgresql + +ENV PATH /usr/lib/postgresql/$PG_MAJOR/bin:$PATH +ENV PGDATA /var/lib/postgresql/data +VOLUME /var/lib/postgresql/data + +COPY ./docker-entrypoint.sh / + +ENTRYPOINT ["/docker-entrypoint.sh"] + +EXPOSE 5432 +CMD ["postgres"] diff --git a/postgres/9.3/docker-entrypoint.sh b/postgres/9.3/docker-entrypoint.sh new file mode 100755 index 000000000..8011908ac --- /dev/null +++ b/postgres/9.3/docker-entrypoint.sh @@ -0,0 +1,24 @@ +#!/bin/bash +set -e + +if [ "$1" = 'postgres' ]; then + chown -R postgres "$PGDATA" + + if [ -z "$(ls -A "$PGDATA")" ]; then + gosu postgres initdb + + sed -ri "s/^#(listen_addresses\s*=\s*)\S+/\1'*'/" "$PGDATA"/postgresql.conf + + { echo; echo 'host all all 0.0.0.0/0 trust'; } >> "$PGDATA"/pg_hba.conf + + if [ -d /docker-entrypoint-initdb.d ]; then + for f in /docker-entrypoint-initdb.d/*.sh; do + [ -f "$f" ] && . "$f" + done + fi + fi + + exec gosu postgres "$@" +fi + +exec "$@" diff --git a/postgres/9.4/Dockerfile b/postgres/9.4/Dockerfile new file mode 100644 index 000000000..0b22b529d --- /dev/null +++ b/postgres/9.4/Dockerfile @@ -0,0 +1,44 @@ +# vim:set ft=dockerfile: +FROM debian:wheezy + +# add our user and group first to make sure their IDs get assigned consistently, regardless of whatever dependencies get added +RUN groupadd -r postgres && useradd -r -g postgres postgres + +# grab gosu for easy step-down from root +RUN apt-get update && apt-get install -y curl && rm -rf /var/lib/apt/lists/* \ + && curl -o /usr/local/bin/gosu -SL 'https://github.com/tianon/gosu/releases/download/1.1/gosu' \ + && chmod +x /usr/local/bin/gosu \ + && apt-get purge -y --auto-remove curl + +# make the "en_US.UTF-8" locale so postgres will be utf-8 enabled by default +RUN apt-get update && apt-get install -y locales && rm -rf /var/lib/apt/lists/* \ + && localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8 +ENV LANG en_US.utf8 + +RUN apt-key adv --keyserver pgp.mit.edu --recv-keys B97B0AFCAA1A47F044F244A07FCC7D46ACCC4CF8 + +ENV PG_MAJOR 9.4 +ENV PG_VERSION 9.4~beta2-2~129.bzr487.pgdg70+1 + +RUN echo 'deb http://apt.postgresql.org/pub/repos/apt/ wheezy-pgdg main' $PG_MAJOR > /etc/apt/sources.list.d/pgdg.list + +RUN apt-get update \ + && apt-get install -y postgresql-common \ + && sed -ri 's/#(create_main_cluster) .*$/\1 = false/' /etc/postgresql-common/createcluster.conf \ + && apt-get install -y \ + postgresql-$PG_MAJOR=$PG_VERSION \ + postgresql-contrib-$PG_MAJOR=$PG_VERSION \ + && rm -rf /var/lib/apt/lists/* + +RUN mkdir -p /var/run/postgresql && chown -R postgres /var/run/postgresql + +ENV PATH /usr/lib/postgresql/$PG_MAJOR/bin:$PATH +ENV PGDATA /var/lib/postgresql/data +VOLUME /var/lib/postgresql/data + +COPY ./docker-entrypoint.sh / + +ENTRYPOINT ["/docker-entrypoint.sh"] + +EXPOSE 5432 +CMD ["postgres"] diff --git a/postgres/9.4/docker-entrypoint.sh b/postgres/9.4/docker-entrypoint.sh new file mode 100755 index 000000000..8011908ac --- /dev/null +++ b/postgres/9.4/docker-entrypoint.sh @@ -0,0 +1,24 @@ +#!/bin/bash +set -e + +if [ "$1" = 'postgres' ]; then + chown -R postgres "$PGDATA" + + if [ -z "$(ls -A "$PGDATA")" ]; then + gosu postgres initdb + + sed -ri "s/^#(listen_addresses\s*=\s*)\S+/\1'*'/" "$PGDATA"/postgresql.conf + + { echo; echo 'host all all 0.0.0.0/0 trust'; } >> "$PGDATA"/pg_hba.conf + + if [ -d /docker-entrypoint-initdb.d ]; then + for f in /docker-entrypoint-initdb.d/*.sh; do + [ -f "$f" ] && . "$f" + done + fi + fi + + exec gosu postgres "$@" +fi + +exec "$@" diff --git a/postgres/AUTHORS b/postgres/AUTHORS new file mode 100644 index 000000000..d3ad2447a --- /dev/null +++ b/postgres/AUTHORS @@ -0,0 +1,6 @@ +Docker PostgreSQL Authors + +Tianon Gravi +Joseph Ferguson + +And other contributors not specifically named here. diff --git a/postgres/Dockerfile.template b/postgres/Dockerfile.template new file mode 100644 index 000000000..9d86078a9 --- /dev/null +++ b/postgres/Dockerfile.template @@ -0,0 +1,44 @@ +# vim:set ft=dockerfile: +FROM debian:wheezy + +# add our user and group first to make sure their IDs get assigned consistently, regardless of whatever dependencies get added +RUN groupadd -r postgres && useradd -r -g postgres postgres + +# grab gosu for easy step-down from root +RUN apt-get update && apt-get install -y curl && rm -rf /var/lib/apt/lists/* \ + && curl -o /usr/local/bin/gosu -SL 'https://github.com/tianon/gosu/releases/download/1.1/gosu' \ + && chmod +x /usr/local/bin/gosu \ + && apt-get purge -y --auto-remove curl + +# make the "en_US.UTF-8" locale so postgres will be utf-8 enabled by default +RUN apt-get update && apt-get install -y locales && rm -rf /var/lib/apt/lists/* \ + && localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8 +ENV LANG en_US.utf8 + +RUN apt-key adv --keyserver pgp.mit.edu --recv-keys B97B0AFCAA1A47F044F244A07FCC7D46ACCC4CF8 + +ENV PG_MAJOR %%PG_MAJOR%% +ENV PG_VERSION %%PG_VERSION%% + +RUN echo 'deb http://apt.postgresql.org/pub/repos/apt/ wheezy-pgdg main' $PG_MAJOR > /etc/apt/sources.list.d/pgdg.list + +RUN apt-get update \ + && apt-get install -y postgresql-common \ + && sed -ri 's/#(create_main_cluster) .*$/\1 = false/' /etc/postgresql-common/createcluster.conf \ + && apt-get install -y \ + postgresql-$PG_MAJOR=$PG_VERSION \ + postgresql-contrib-$PG_MAJOR=$PG_VERSION \ + && rm -rf /var/lib/apt/lists/* + +RUN mkdir -p /var/run/postgresql && chown -R postgres /var/run/postgresql + +ENV PATH /usr/lib/postgresql/$PG_MAJOR/bin:$PATH +ENV PGDATA /var/lib/postgresql/data +VOLUME /var/lib/postgresql/data + +COPY ./docker-entrypoint.sh / + +ENTRYPOINT ["/docker-entrypoint.sh"] + +EXPOSE 5432 +CMD ["postgres"] diff --git a/postgres/LICENSE b/postgres/LICENSE new file mode 100644 index 000000000..f86b1322e --- /dev/null +++ b/postgres/LICENSE @@ -0,0 +1,22 @@ +Copyright (c) 2014, Docker PostgreSQL Authors (See AUTHORS) + +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation +files (the "Software"), to deal in the Software without +restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. diff --git a/postgres/docker-entrypoint.sh b/postgres/docker-entrypoint.sh new file mode 100755 index 000000000..8011908ac --- /dev/null +++ b/postgres/docker-entrypoint.sh @@ -0,0 +1,24 @@ +#!/bin/bash +set -e + +if [ "$1" = 'postgres' ]; then + chown -R postgres "$PGDATA" + + if [ -z "$(ls -A "$PGDATA")" ]; then + gosu postgres initdb + + sed -ri "s/^#(listen_addresses\s*=\s*)\S+/\1'*'/" "$PGDATA"/postgresql.conf + + { echo; echo 'host all all 0.0.0.0/0 trust'; } >> "$PGDATA"/pg_hba.conf + + if [ -d /docker-entrypoint-initdb.d ]; then + for f in /docker-entrypoint-initdb.d/*.sh; do + [ -f "$f" ] && . "$f" + done + fi + fi + + exec gosu postgres "$@" +fi + +exec "$@" diff --git a/postgres/generate-stackbrew-library.sh b/postgres/generate-stackbrew-library.sh new file mode 100755 index 000000000..230f74767 --- /dev/null +++ b/postgres/generate-stackbrew-library.sh @@ -0,0 +1,27 @@ +#!/bin/bash +set -e + +declare -A aliases +aliases=( + [9.3]='9 latest' + [8.4]='8' +) + +cd "$(dirname "$(readlink -f "$BASH_SOURCE")")" + +versions=( */ ) +versions=( "${versions[@]%/}" ) +url='git://github.com/docker-library/postgres' + +echo '# maintainer: InfoSiftr (@infosiftr)' + +for version in "${versions[@]}"; do + commit="$(git log -1 --format='format:%H' "$version")" + fullVersion="$(grep -m1 'ENV PG_VERSION ' "$version/Dockerfile" | cut -d' ' -f3 | cut -d- -f1 | sed 's/~/-/g')" + versionAliases=( $fullVersion $version ${aliases[$version]} ) + + echo + for va in "${versionAliases[@]}"; do + echo "$va: ${url}@${commit} $version" + done +done diff --git a/postgres/update.sh b/postgres/update.sh new file mode 100755 index 000000000..649d71619 --- /dev/null +++ b/postgres/update.sh @@ -0,0 +1,26 @@ +#!/bin/bash +set -e + +cd "$(dirname "$(readlink -f "$BASH_SOURCE")")" + +versions=( "$@" ) +if [ ${#versions[@]} -eq 0 ]; then + versions=( */ ) +fi +versions=( "${versions[@]%/}" ) + +packagesUrl='http://apt.postgresql.org/pub/repos/apt/dists/wheezy-pgdg/main/binary-amd64/Packages' +packages="$(echo "$packagesUrl" | sed -r 's/[^a-zA-Z.-]+/-/g')" +curl -sSL "${packagesUrl}.bz2" | bunzip2 > "$packages" + +for version in "${versions[@]}"; do + fullVersion="$(grep -m1 -A10 "^Package: postgresql-$version\$" "$packages" | grep -m1 '^Version: ' | cut -d' ' -f2)" + ( + set -x + cp docker-entrypoint.sh Dockerfile.template "$version/" + mv "$version/Dockerfile.template" "$version/Dockerfile" + sed -i 's/%%PG_MAJOR%%/'$version'/g; s/%%PG_VERSION%%/'$fullVersion'/g' "$version/Dockerfile" + ) +done + +rm "$packages"