mirror of
https://codeberg.org/demostf/postgres_refresh.git
synced 2026-06-03 09:04:08 +02:00
initial version
This commit is contained in:
commit
56aac057d0
3 changed files with 40 additions and 0 deletions
13
Dockerfile
Normal file
13
Dockerfile
Normal 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
17
README.md
Normal 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
10
loop.sh
Executable 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
|
||||
Loading…
Add table
Add a link
Reference in a new issue