Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
# see: https://github.com/moby/moby/issues/5509#issuecomment-890126570
CMD ["postgres"]

ENV PGROOT=/var/lib/postgresql \

Check warning on line 90 in Dockerfile

View workflow job for this annotation

GitHub Actions / Build arm64

Sensitive data should not be used in the ARG or ENV commands

SecretsUsedInArgOrEnv: Do not use ARG or ENV instructions for sensitive data (ENV "POSTGRES_PASSWORD") More info: https://docs.docker.com/go/dockerfile/rule/secrets-used-in-arg-or-env/

Check warning on line 90 in Dockerfile

View workflow job for this annotation

GitHub Actions / Build arm64

Variables should be defined before their use

UndefinedVar: Usage of undefined variable '$OR_DISABLE_AUTO_UPGRADE' More info: https://docs.docker.com/go/dockerfile/rule/undefined-var/

Check warning on line 90 in Dockerfile

View workflow job for this annotation

GitHub Actions / Build arm64

Variables should be defined before their use

UndefinedVar: Usage of undefined variable '$POSTGRES_IDLE_IN_TRANSACTION_SESSION_TIMEOUT' More info: https://docs.docker.com/go/dockerfile/rule/undefined-var/

Check warning on line 90 in Dockerfile

View workflow job for this annotation

GitHub Actions / Build arm64

Variables should be defined before their use

UndefinedVar: Usage of undefined variable '$POSTGRES_MAX_CONNECTIONS' More info: https://docs.docker.com/go/dockerfile/rule/undefined-var/

Check warning on line 90 in Dockerfile

View workflow job for this annotation

GitHub Actions / Build arm64

Variables should be defined before their use

UndefinedVar: Usage of undefined variable '$OR_DISABLE_REINDEX' More info: https://docs.docker.com/go/dockerfile/rule/undefined-var/

Check warning on line 90 in Dockerfile

View workflow job for this annotation

GitHub Actions / Build arm64

Variables should be defined before their use

UndefinedVar: Usage of undefined variable '$POSTGRES_PASSWORD' More info: https://docs.docker.com/go/dockerfile/rule/undefined-var/

Check warning on line 90 in Dockerfile

View workflow job for this annotation

GitHub Actions / Build arm64

Variables should be defined before their use

UndefinedVar: Usage of undefined variable '$POSTGRES_USER' More info: https://docs.docker.com/go/dockerfile/rule/undefined-var/

Check warning on line 90 in Dockerfile

View workflow job for this annotation

GitHub Actions / Build arm64

Variables should be defined before their use

UndefinedVar: Usage of undefined variable '$POSTGRES_DB' More info: https://docs.docker.com/go/dockerfile/rule/undefined-var/

Check warning on line 90 in Dockerfile

View workflow job for this annotation

GitHub Actions / Build arm64

Variables should be defined before their use

UndefinedVar: Usage of undefined variable '$PGTZ' (did you mean $PATH?) More info: https://docs.docker.com/go/dockerfile/rule/undefined-var/

Check warning on line 90 in Dockerfile

View workflow job for this annotation

GitHub Actions / Build arm64

Variables should be defined before their use

UndefinedVar: Usage of undefined variable '$TZ' More info: https://docs.docker.com/go/dockerfile/rule/undefined-var/

Check warning on line 90 in Dockerfile

View workflow job for this annotation

GitHub Actions / Build amd64

Sensitive data should not be used in the ARG or ENV commands

SecretsUsedInArgOrEnv: Do not use ARG or ENV instructions for sensitive data (ENV "POSTGRES_PASSWORD") More info: https://docs.docker.com/go/dockerfile/rule/secrets-used-in-arg-or-env/

Check warning on line 90 in Dockerfile

View workflow job for this annotation

GitHub Actions / Build amd64

Variables should be defined before their use

UndefinedVar: Usage of undefined variable '$OR_DISABLE_AUTO_UPGRADE' More info: https://docs.docker.com/go/dockerfile/rule/undefined-var/

Check warning on line 90 in Dockerfile

View workflow job for this annotation

GitHub Actions / Build amd64

Variables should be defined before their use

UndefinedVar: Usage of undefined variable '$POSTGRES_IDLE_IN_TRANSACTION_SESSION_TIMEOUT' More info: https://docs.docker.com/go/dockerfile/rule/undefined-var/

Check warning on line 90 in Dockerfile

View workflow job for this annotation

GitHub Actions / Build amd64

Variables should be defined before their use

UndefinedVar: Usage of undefined variable '$POSTGRES_MAX_CONNECTIONS' More info: https://docs.docker.com/go/dockerfile/rule/undefined-var/

Check warning on line 90 in Dockerfile

View workflow job for this annotation

GitHub Actions / Build amd64

Variables should be defined before their use

UndefinedVar: Usage of undefined variable '$OR_DISABLE_REINDEX' More info: https://docs.docker.com/go/dockerfile/rule/undefined-var/

Check warning on line 90 in Dockerfile

View workflow job for this annotation

GitHub Actions / Build amd64

Variables should be defined before their use

UndefinedVar: Usage of undefined variable '$POSTGRES_PASSWORD' More info: https://docs.docker.com/go/dockerfile/rule/undefined-var/

Check warning on line 90 in Dockerfile

View workflow job for this annotation

GitHub Actions / Build amd64

Variables should be defined before their use

UndefinedVar: Usage of undefined variable '$POSTGRES_USER' More info: https://docs.docker.com/go/dockerfile/rule/undefined-var/

Check warning on line 90 in Dockerfile

View workflow job for this annotation

GitHub Actions / Build amd64

Variables should be defined before their use

UndefinedVar: Usage of undefined variable '$POSTGRES_DB' More info: https://docs.docker.com/go/dockerfile/rule/undefined-var/

Check warning on line 90 in Dockerfile

View workflow job for this annotation

GitHub Actions / Build amd64

Variables should be defined before their use

UndefinedVar: Usage of undefined variable '$PGTZ' (did you mean $PATH?) More info: https://docs.docker.com/go/dockerfile/rule/undefined-var/

Check warning on line 90 in Dockerfile

View workflow job for this annotation

GitHub Actions / Build amd64

Variables should be defined before their use

UndefinedVar: Usage of undefined variable '$TZ' More info: https://docs.docker.com/go/dockerfile/rule/undefined-var/
PGDATA=/var/lib/postgresql/data \
PGLOG=/var/lib/postgresql/pg_log \
PGSOCKET=/var/lib/postgresql \
Expand All @@ -109,6 +109,7 @@
OR_REINDEX_COUNTER=${OR_REINDEX_COUNTER} \
OR_DISABLE_REINDEX=${OR_DISABLE_REINDEX:-false} \
POSTGRES_MAX_CONNECTIONS=${POSTGRES_MAX_CONNECTIONS:-50} \
POSTGRES_IDLE_IN_TRANSACTION_SESSION_TIMEOUT=${POSTGRES_IDLE_IN_TRANSACTION_SESSION_TIMEOUT:-10min} \
OR_DISABLE_AUTO_UPGRADE=${OR_DISABLE_AUTO_UPGRADE:-false}

WORKDIR /var/lib/postgresql
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ POSTGIS and TimescaleDB (inc. toolkit for hyperfunctions) image built for amd64

- OR specific ENV variables and a healthcheck added
- Easy configuration of `max_connections` using `POSTGRES_MAX_CONNECTIONS` environment variable (set to `-1` to disable this setting)
- Sessions left idle in a transaction for more than 10 minutes are terminated, as they prevent autovacuum removing dead rows
and cause table bloat; configure using `POSTGRES_IDLE_IN_TRANSACTION_SESSION_TIMEOUT` environment variable with a
PostgreSQL time value e.g. `30min` (set to `0` to disable this setting)
- PGDATA path set to match old Alpine image (for ease of DB migration)
- POSTGRES user UID and GID changed to match old Alpine image (for ease of DB migration)
- Auto upgrade of database with PG major version changes from previous PG major version; can be disabled using
Expand Down
6 changes: 6 additions & 0 deletions or-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ if [ $POSTGRES_MAX_CONNECTIONS -gt 0 ]; then
set -- "$@" -c max_connections=${POSTGRES_MAX_CONNECTIONS}
fi

# Terminate sessions left idle in a transaction for longer than this, as they prevent autovacuum removing dead rows
# (set to 0 to disable this setting)
if [ -n "$POSTGRES_IDLE_IN_TRANSACTION_SESSION_TIMEOUT" ] && [ "$POSTGRES_IDLE_IN_TRANSACTION_SESSION_TIMEOUT" != "0" ]; then
set -- "$@" -c idle_in_transaction_session_timeout=${POSTGRES_IDLE_IN_TRANSACTION_SESSION_TIMEOUT}
fi

wait_for_ready() {
# Wait for connectivity first
until pg_isready -q; do
Expand Down
Loading