version 1.1

This commit is contained in:
2024-10-09 15:06:56 +02:00
parent d81fb678e3
commit 836a412a6d
536 changed files with 63922 additions and 0 deletions
+57
View File
@@ -0,0 +1,57 @@
FROM ubuntu:14.04
MAINTAINER Alexis Manin <alexis.manin@geomatys.com>
# fix locale
RUN locale-gen en_US.UTF-8
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8
ENV PG_VERSION 9.4
ENV PGIS_VERSION 2.1
# Add the PostgreSQL PGP key to verify their Debian packages
# It should be the same key as https://www.postgresql.org/media/keys/ACCC4CF8.asc
RUN apt-key adv \
--keyserver hkp://keyserver.ubuntu.com:80 \
--recv-keys B97B0AFCAA1A47F044F244A07FCC7D46ACCC4CF8 && \
echo "deb http://apt.postgresql.org/pub/repos/apt/ trusty-pgdg main $PG_VERSION" \
> /etc/apt/sources.list.d/pgdg.list && \
apt-get update
RUN apt-get upgrade -y
RUN apt-get install -y \
curl \
libpq5 \
psmisc \
postgresql-$PG_VERSION \
postgresql-client-$PG_VERSION \
postgresql-$PG_VERSION-postgis-$PGIS_VERSION
#>> Cleanup
RUN rm -rf /var/lib/apt/lists/* /tmp/* && \
apt-get autoremove -y && \
apt-get autoclean
# install gosu
RUN curl -o /usr/local/bin/gosu -sSL "https://github.com/tianon/gosu/releases/download/1.4/gosu-$(dpkg --print-architecture)" \
&& chmod +x /usr/local/bin/gosu
ENV PGDATA /var/rhomeo/pgdata
VOLUME /var/rhomeo/pgdata
ADD entrypoint-postgres.sh /usr/local/bin/entrypoint.sh
RUN chmod +x /usr/local/bin/entrypoint.sh
EXPOSE 5432
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
CMD ["postgres"]
+65
View File
@@ -0,0 +1,65 @@
#!/bin/sh
set -e
STDERR () {
cat - 1>&2
}
if [ "$1" = 'postgres' ]; then
# exit if postgres directory does not already exist
[ -d "$PGDATA" ] || (echo "PGDATA=$PGDATA does not exist" | STDERR && exit 1)
echo '##### chown'
chown -R postgres "$PGDATA"
# if data directory does not have any files
# initialize database in its place
if [ -z "$(ls -A "$PGDATA")" ]; then
gosu postgres /usr/lib/postgresql/$PG_VERSION/bin/initdb --encoding="UTF8"
sed -ri "s/^#(listen_addresses\s*=\s*)\S+/\1'*'/" "$PGDATA"/postgresql.conf
{ echo; echo 'host all all 0.0.0.0/0 md5'; } >> "$PGDATA"/pg_hba.conf
echo '##### start postgresql for cstl init'
exec gosu postgres /usr/lib/postgresql/$PG_VERSION/bin/"$@" -D "$PGDATA" -c config_file="$PGDATA"/postgresql.conf &
# Perform all actions as $POSTGRES_USER
export PGUSER="$POSTGRES_USER"
sleep 5
echo 'creating cstl user'
gosu postgres createuser -d -r -s cstl
echo 'created cstl user'
gosu postgres createdb -O cstl -E UTF8 -T template0 constellation
echo 'creating cstl db'
# alter cstl user and role
gosu postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE constellation to cstl; ALTER ROLE cstl WITH PASSWORD 'admin'"
echo 'altered cstl user'
# create rhomeo database for referential geodata
echo 'creating rhomeo user'
gosu postgres createuser -d -r -s rhomeo
echo 'created rhomeo user'
gosu postgres createdb -O rhomeo -E UTF8 -T template0 referential
echo 'creating referential db'
gosu postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE referential to rhomeo; ALTER ROLE rhomeo WITH PASSWORD 'espaces naturels !'"
echo 'altered rhomeo user'
echo 'creating postgis extension'
gosu postgres psql -d referential -c "CREATE EXTENSION postgis;"
echo 'created postgis extension'
kill -INT `head -1 "$PGDATA"/postmaster.pid`
sleep 5
echo 'kill postgresql'
fi
fi
# command is a postgres executable hence execute it as postgres user
if [ -x /usr/lib/postgresql/"$PG_VERSION"/bin/"$1" ]; then
echo "executing as postgres user"
exec gosu postgres /usr/lib/postgresql/$PG_VERSION/bin/"$@" -D "$PGDATA" -c config_file="$PGDATA"/postgresql.conf
else
echo "executing what else"
exec "$@"
fi