1
0
Fork 0
mirror of https://codeberg.org/demostf/postgres_refresh.git synced 2026-06-03 17:14:06 +02:00

initial version

This commit is contained in:
Robin Appelman 2019-01-23 19:29:57 +01:00
commit 56aac057d0
3 changed files with 40 additions and 0 deletions

13
Dockerfile Normal file
View file

@ -0,0 +1,13 @@
FROM alpine:3.8
RUN apk add --no-cache postgresql
ADD loop.sh /
ENV POSTGRES_USER=postgres
ENV POSTGRES_DATABASE=postgres
ENV POSTGRES_PORT=5432
ENV INTERVAL=3600
ENTRYPOINT ["/loop.sh"]

17
README.md Normal file
View file

@ -0,0 +1,17 @@
# POSTGRES_REFRESH
Periodically refresh materialized postgresql views
## Usage
This docker image can be configured using the following environment variables.
| Variable | Default | Comment |
| ------------------ | -------- | ---------------------------------------- |
| $POSTGRES_HOST | - | database host |
| $POSTGRES_PORT | 5432 | database port |
| $POSTGRES_USER | postgres | database user |
| $POSTGRES_PASSWORD | - | database password |
| $POSTGRES_DATABASE | postgres | database name containing the views |
| $VIEWS | - | space separated list of views to refresh |
| $INTERVAL | 3600 | Time between refreshes in seconds |

10
loop.sh Executable file
View file

@ -0,0 +1,10 @@
#!/usr/bin/env sh
while [ : ]; do
for view in $VIEWS; do
echo "refreshing $view"
env PGPASSWORD=$POSTGRES_PASSWORD psql -p $POSTGRES_PORT -U $POSTGRES_USER -h $POSTGRES_HOST $POSTGRES_DATABASE -c "REFRESH MATERIALIZED VIEW $view"
done
sleep $INTERVAL
done