Skip to content

Commit

Permalink
Use DATABASE_URL in pgdumper
Browse files Browse the repository at this point in the history
  • Loading branch information
frafra committed Feb 18, 2019
1 parent b6c75f7 commit 1cc7725
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
2 changes: 2 additions & 0 deletions scripts/spcgeonode/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ services:
pgdumper:
image: olivierdalang/spcgeonode:pgdumper-latest
build: ./pgdumper/
environment:
- DATABASE_URL=postgres://postgres:${POSTGRES_PASSWORD}@postgres:5432/postgres
volumes:
- pgdumps:/spcgeonode-pgdumps/
restart: on-failure
Expand Down
9 changes: 6 additions & 3 deletions scripts/spcgeonode/pgdumper/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@ RUN apk add --no-cache postgresql-client && \
cp /usr/bin/pg_dump /bin/pg_dump && \
apk del BUIID_DEPS

# envsubst dependency
RUN apk add --no-cache gettext

# The entrypoint creates the certificate
ADD crontab crontab
RUN /usr/bin/crontab crontab
RUN rm crontab
ADD crontab crontab.envsubst
ADD docker-entrypoint.sh /

ENTRYPOINT ["/docker-entrypoint.sh"]

# We run cron in foreground to update the certificates
CMD ["/usr/sbin/crond", "-f"]
2 changes: 1 addition & 1 deletion scripts/spcgeonode/pgdumper/crontab
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
# │ │ │ │ ┌───────────── day of week (0 - 6) (Sunday to Saturday; 7 is also Sunday on some systems)
# │ │ │ │ │

0 0 * * * date && pg_dump -C -h postgres -U postgres postgres > /spcgeonode-pgdumps/latest.pgdump && echo "Dump successful"
0 0 * * * date && pg_dump -C "${DATABASE_URL}" > /spcgeonode-pgdumps/latest.pgdump && echo "Dump successful"
7 changes: 7 additions & 0 deletions scripts/spcgeonode/pgdumper/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh

envsubst '\$DATABASE_URL' < crontab.envsubst > crontab
/usr/bin/crontab crontab
rm crontab crontab.envsubst

exec "$@"

0 comments on commit 1cc7725

Please sign in to comment.