Skip to content

Commit 0148110

Browse files
committed
fix: dockerfile build
1 parent c87f869 commit 0148110

2 files changed

Lines changed: 23 additions & 11 deletions

File tree

Dockerfile

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ RUN apk add -uU --no-cache \
4040
su-exec \
4141
openssl \
4242
krb5 \
43-
postgresql-client \
43+
postgresql17-client \
4444
perl
4545

4646
# Copy pgBadger
@@ -60,25 +60,26 @@ RUN mkdir -p /var/lib/postgresql/data \
6060

6161
WORKDIR /app
6262
# making sure we use the binaries from the installed postgresql17 client
63-
ENV PG_DUMP_BINARY=/usr/local/pgsql/bin/pg_dump
64-
ENV PG_RESTORE_BINARY=/usr/local/pgsql/bin/pg_restore
63+
ENV PG_DUMP_BINARY=/usr/bin/pg_dump
64+
ENV PG_RESTORE_BINARY=/usr/bin/pg_restore
6565
ENV PATH="/usr/local/pgsql/bin:$PATH"
6666
ENV PGDATA=/var/lib/postgresql/data
6767

6868
RUN sed -i 's|nobody:/|nobody:/home|' /etc/passwd && chown nobody:nobody /home
6969

7070
ENV POSTGRES_URL=postgresql://postgres@localhost/postgres?host=/tmp
7171

72-
RUN su-exec postgres initdb -D $PGDATA || true && \
73-
# echo "shared_preload_libraries = 'timescaledb,pg_stat_statements'" >> $PGDATA/postgresql.conf && \
74-
echo "listen_addresses = ''" >> $PGDATA/postgresql.conf && \
75-
echo "unix_socket_directories = '/tmp'" >> $PGDATA/postgresql.conf
72+
COPY ./docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
73+
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
74+
7675

7776
USER postgres
7877

78+
RUN initdb -D "$PGDATA"
79+
80+
# We don't expose 5432 because
81+
# 1. We use a unix socket
82+
# 2. The external user should never have to interface with the internal postgres service
7983
EXPOSE 2345
8084

81-
CMD ["/bin/bash", "-c", "\
82-
pg_ctl -D $PGDATA -l $PGDATA/logfile start || (cat $PGDATA/logfile && exit 1) && \
83-
until pg_isready -h /tmp; do sleep 0.5; done && \
84-
node /app/dist/main.mjs"]
85+
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]

docker-entrypoint.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/sh
2+
3+
echo "listen_addresses = '0.0.0.0'" >> "$PGDATA/postgresql.conf"
4+
echo "host all all 0.0.0.0/0 trust" >> "$PGDATA/pg_hba.conf"
5+
echo "shared_preload_libraries = 'timescaledb,pg_stat_statements'" >> "$PGDATA/postgresql.conf"
6+
7+
pg_ctl -D "$PGDATA" -l "$PGDATA/logfile" start || (cat "$PGDATA/logfile" && exit 1)
8+
9+
until pg_isready -h /tmp; do sleep 0.5; done
10+
11+
node /app/dist/main.mjs

0 commit comments

Comments
 (0)