Skip to content

Commit

Permalink
Make Postgres start for amd64 - @undecaf - #2
Browse files Browse the repository at this point in the history
  • Loading branch information
dominictayloruk committed Jul 7, 2021
1 parent cdb9c9e commit 91110be
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
4 changes: 4 additions & 0 deletions alpine-postgres-amd64/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ VOLUME /var/lib/postgresql/data

COPY files/docker-entrypoint.sh /

RUN chmod -R 755 /docker-entrypoint.sh && \
mkdir -p /run/postgresql && \
chown postgres: /run/postgresql

ENTRYPOINT ["/docker-entrypoint.sh"]

EXPOSE 5432
Expand Down
12 changes: 6 additions & 6 deletions alpine-postgres-amd64/files/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
chown -R postgres "$PGDATA"

if [ -z "$(ls -A "$PGDATA")" ]; then
gosu postgres initdb
su-exec postgres initdb
sed -ri "s/^#(listen_addresses\s*=\s*)\S+/\1'*'/" "$PGDATA"/postgresql.conf

: ${POSTGRES_USER:="postgres"}
Expand All @@ -23,7 +23,7 @@ if [ -z "$(ls -A "$PGDATA")" ]; then

if [ "$POSTGRES_DB" != 'postgres' ]; then
createSql="CREATE DATABASE $POSTGRES_DB;"
echo $createSql | gosu postgres postgres --single -jE
echo $createSql | su-exec postgres postgres --single -jE
echo
fi

Expand All @@ -34,10 +34,10 @@ if [ -z "$(ls -A "$PGDATA")" ]; then
fi

userSql="$op USER $POSTGRES_USER WITH SUPERUSER $pass;"
echo $userSql | gosu postgres postgres --single -jE
echo $userSql | su-exec postgres postgres --single -jE
echo

gosu postgres pg_ctl -D "$PGDATA" \
su-exec postgres pg_ctl -D "$PGDATA" \
-o "-c listen_addresses=''" \
-w start

Expand All @@ -51,9 +51,9 @@ if [ -z "$(ls -A "$PGDATA")" ]; then
echo
done

gosu postgres pg_ctl -D "$PGDATA" -m fast -w stop
su-exec 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 "$@"
exec su-exec postgres "$@"

0 comments on commit 91110be

Please sign in to comment.