-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e394aaa
commit cdb9c9e
Showing
3 changed files
with
96 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
FROM yobasystems/alpine:3.9.0-aarch64 | ||
LABEL maintainer "Dominic Taylor <dominic@yobasystems.co.uk>" architecture="ARM64v8/aarch64" | ||
LABEL postgres-version="11.1" alpine-version="3.9.0" date="11-Feb-2018" | ||
|
||
ENV LANG en_GB.utf8 | ||
ENV PGDATA /var/lib/postgresql/data | ||
|
||
RUN apk update && \ | ||
apk add su-exec tzdata libpq postgresql-client postgresql postgresql-contrib && \ | ||
mkdir /docker-entrypoint-initdb.d && \ | ||
rm -rf /var/cache/apk/* | ||
|
||
|
||
VOLUME /var/lib/postgresql/data | ||
|
||
COPY files/docker-entrypoint.sh / | ||
|
||
ENTRYPOINT ["/docker-entrypoint.sh"] | ||
|
||
EXPOSE 5432 | ||
CMD ["postgres"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#!/bin/sh | ||
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 | ||
|
||
: ${POSTGRES_USER:="postgres"} | ||
: ${POSTGRES_DB:=$POSTGRES_USER} | ||
|
||
if [ "$POSTGRES_PASSWORD" ]; then | ||
pass="PASSWORD '$POSTGRES_PASSWORD'" | ||
authMethod=md5 | ||
else | ||
echo "===============================" | ||
echo "!!! NO PASSWORD SET !!! (Use \$POSTGRES_PASSWORD env var)" | ||
echo "===============================" | ||
pass= | ||
authMethod=trust | ||
fi | ||
echo | ||
|
||
|
||
if [ "$POSTGRES_DB" != 'postgres' ]; then | ||
createSql="CREATE DATABASE $POSTGRES_DB;" | ||
echo $createSql | gosu postgres postgres --single -jE | ||
echo | ||
fi | ||
|
||
if [ "$POSTGRES_USER" != 'postgres' ]; then | ||
op=CREATE | ||
else | ||
op=ALTER | ||
fi | ||
|
||
userSql="$op USER $POSTGRES_USER WITH SUPERUSER $pass;" | ||
echo $userSql | gosu postgres postgres --single -jE | ||
echo | ||
|
||
gosu postgres pg_ctl -D "$PGDATA" \ | ||
-o "-c listen_addresses=''" \ | ||
-w start | ||
|
||
echo | ||
for f in /docker-entrypoint-initdb.d/*; do | ||
case "$f" in | ||
*.sh) echo "$0: running $f"; . "$f" ;; | ||
*.sql) echo "$0: running $f"; psql --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" < "$f" && echo ;; | ||
*) echo "$0: ignoring $f" ;; | ||
esac | ||
echo | ||
done | ||
|
||
gosu postgres pg_ctl -D "$PGDATA" -m fast -w stop | ||
|
||
{ echo; echo "host all all 0.0.0.0/0 $authMethod"; } >> "$PGDATA"/pg_hba.conf | ||
fi | ||
|
||
exec gosu postgres "$@" |