Compare commits
No commits in common. "0ea86a8c05514afe0bd29baf40451086f9b1c904" and "2473c1b9241bfea601f63d6e50c55e01396debae" have entirely different histories.
0ea86a8c05
...
2473c1b924
5 changed files with 20 additions and 86 deletions
|
@ -24,7 +24,6 @@ table_meta*
|
|||
/*.pdf
|
||||
|
||||
.gitignore
|
||||
.bash_history
|
||||
|
||||
node_modules
|
||||
local
|
||||
|
|
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -27,7 +27,6 @@ node_modules
|
|||
local
|
||||
tmp
|
||||
.parcel-cache
|
||||
.bash_history
|
||||
|
||||
.env
|
||||
.mc
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
image: docker:latest
|
||||
image: docker:20.10.16
|
||||
|
||||
variables:
|
||||
IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG
|
||||
|
@ -9,7 +9,7 @@ stages:
|
|||
- release
|
||||
|
||||
services:
|
||||
- docker:dind
|
||||
- docker:20.10.16-dind
|
||||
|
||||
build:
|
||||
stage: build
|
||||
|
|
38
Dockerfile
38
Dockerfile
|
@ -2,44 +2,40 @@ FROM buildpack-deps:bullseye
|
|||
|
||||
ARG SRV_UID="1000"
|
||||
ARG SRV_GID="100"
|
||||
ARG SRV_LOCALE="en_US"
|
||||
ARG SRV_VERSION="0"
|
||||
|
||||
ENV SRV_UID $SRV_UID
|
||||
ENV SRV_GID $SRV_GID
|
||||
ENV SRV_LOCALE $SRV_LOCALE
|
||||
ENV SRV_VERSION $SRV_VERSION
|
||||
ENV SRV_APT_GET_INSTALL $SRV_APT_GET_INSTALL
|
||||
|
||||
ENV DEBIAN_FRONTEND "noninteractive"
|
||||
ENV PGDATA "/data"
|
||||
ENV POSTGRES_INITDB_ARGS "--locale=${SRV_LOCALE}.UTF-8 --lc-ctype=${SRV_LOCALE}.UTF-8 --lc-monetary=${SRV_LOCALE}.UTF-8 --lc-numeric=${SRV_LOCALE}.UTF-8 --lc-time=${SRV_LOCALE}.UTF-8 --lc-collate=${SRV_LOCALE}.UTF-8 --encoding=UTF8"
|
||||
|
||||
# explicitly set user/group IDs
|
||||
RUN if [ -z "$( getent group $SRV_GID )" ] ; then groupadd -r postgres --gid=$SRV_GID ; fi && \
|
||||
useradd -r -g $SRV_GID --uid=$SRV_UID --home-dir=/var/lib/postgresql --shell=/bin/bash postgres && \
|
||||
mkdir -p $PGDATA && chown -R $SRV_UID:$SRV_GID $PGDATA && \
|
||||
apt-get update -y && apt-get install -y apt-utils lsb-release && \
|
||||
apt-get update -y && apt-get install -y lsb-release && \
|
||||
( curl https://www.postgresql.org/media/keys/ACCC4CF8.asc | gpg --dearmor > /etc/apt/trusted.gpg.d/apt.postgresql.org.gpg ) && \
|
||||
( echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list ) && \
|
||||
apt-get update -y && mkdir -p /docker-entrypoint-initdb.d && \
|
||||
apt-get install -y postgresql-16 postgresql-common postgresql-16-pglogical \
|
||||
postgresql-16-cron postgresql-16-extra-window-functions \
|
||||
postgresql-16-first-last-agg postgresql-16-jsquery postgresql-16-numeral \
|
||||
postgresql-16-pglogical-ticker postgresql-16-pgmemcache \
|
||||
postgresql-16-pgpcre postgresql-16-pgrouting postgresql-16-repack \
|
||||
postgresql-16-pgrouting-scripts postgresql-16-pgsphere \
|
||||
postgresql-16-postgis-3 postgresql-16-postgis-3-scripts \
|
||||
postgresql-16-repack postgresql-16-set-user postgresql-16-similarity \
|
||||
postgresql-16-pgpool2 postgresql-16-semver postgresql-16-repmgr \
|
||||
postgresql-plperl-16 postgresql-plpython3-16 postgresql-16-age \
|
||||
postgresql-16-pgvector postgresql-16-tablelog postgresql-16-wal2json \
|
||||
apgdiff locales-all $SRV_APT_GET_INSTALL && \
|
||||
apt-get install -y postgresql-15 postgresql-common postgresql-15-pglogical \
|
||||
postgresql-15-cron postgresql-15-extra-window-functions \
|
||||
postgresql-15-first-last-agg postgresql-15-jsquery postgresql-15-numeral \
|
||||
postgresql-15-pglogical-ticker postgresql-15-pgmemcache \
|
||||
postgresql-15-pgpcre postgresql-15-pgrouting postgresql-15-repack \
|
||||
postgresql-15-pgrouting-scripts postgresql-15-pgsphere \
|
||||
postgresql-15-postgis-3 postgresql-15-postgis-3-scripts \
|
||||
postgresql-15-repack postgresql-15-set-user postgresql-15-similarity \
|
||||
postgresql-15-pgpool2 postgresql-15-semver postgresql-15-repmgr \
|
||||
postgresql-15-tablelog postgresql-15-wal2json \
|
||||
$SRV_APT_GET_INSTALL && \
|
||||
apt-get clean && rm -rf ~/.cache && rm -rf /var/lib/apt/lists/*
|
||||
|
||||
ENV PATH="/usr/lib/postgresql/16/bin:$PATH"
|
||||
ENV PATH="/usr/lib/postgresql/15/bin:$PATH"
|
||||
|
||||
COPY docker-entrypoint.sh /
|
||||
COPY docker-entrypoint.sh /usr/local/bin/
|
||||
|
||||
USER $SRV_UID:$SRV_GID
|
||||
|
||||
|
@ -49,13 +45,13 @@ VOLUME $PGDATA
|
|||
|
||||
WORKDIR $PGDATA
|
||||
|
||||
ENTRYPOINT ["/docker-entrypoint.sh"]
|
||||
ENTRYPOINT ["docker-entrypoint.sh"]
|
||||
|
||||
STOPSIGNAL SIGINT
|
||||
|
||||
EXPOSE 5432
|
||||
|
||||
CMD ["postgres","-c","listen_addresses=*"]
|
||||
CMD ["postgres"]
|
||||
|
||||
HEALTHCHECK --interval=30s --timeout=3s --retries=4 \
|
||||
CMD pg_isready -U postgres
|
||||
CMD pg_isready -U ${POSTGRES_USER:-postgres}
|
||||
|
|
60
README.md
60
README.md
|
@ -1,60 +0,0 @@
|
|||
# PostgreSQL 16 Image
|
||||
|
||||
## About
|
||||
|
||||
This is a special image that I created out of necessity to have a dynamic User ID and Group ID for the data of the PostgreSQL, while also solving the default listen address problem normally happening with Docker, without touching configuration. It will always listen to all network addresses. Additionally we use a Debian image and install the Debian packages for all the PostgreSQL modules from the official PostgreSQL Debian repository. This allows to activate them on demand. The image also contains a proper healthcheck that checks 4 times on the interval of 30 seconds with a timeout of 3 seconds. If you need this configurable, please contact me. The user will be called *postgres* and his home will be **/var/lib/postgresql**. The PostgreSQL itself is installed under **/data**. Additionally the image is not running as *root* and is using the official Docker image *docker-entrypoint.sh* as documented on the [PostgreSQL Docker Hub page](https://hub.docker.com/_/postgres).
|
||||
|
||||
## How To Use
|
||||
|
||||
If you use the image, you will have to make a mount for the **/data** directory inside the image. Please be aware, that this directory must exist before and must have the same User ID and Group ID as the image is using, else Docker creates a root owned directory, the init db will fail. If you do not want the image to listen to all network addresses, then just set a new *command*.
|
||||
|
||||
### Image Name
|
||||
|
||||
The image name for your Docker is **src.ci/srv/postgres:latest**. This is only applicable, if you do not want to change the User ID and Group ID.
|
||||
|
||||
### ARGS
|
||||
|
||||
For changing the ARGS, you need to copy the repository and build the image yourself with setting the necessary ARGS to get a new image. As convention, you could use the User ID as the tag name for your new image, we will not make an official tag that is just a number, so you will not collide here in the future. Of course, you can also just give it then a complete new image name, so that there can't be any collide. You can also *git submodule* the repository in a subdirectory and then add it with args to your Docker-Compose configuration, like in this example, assuming you put the submodule of the repository under *docker/postgres*:
|
||||
|
||||
```yaml
|
||||
services:
|
||||
db:
|
||||
image: "src.ci/srv/postgres:1010"
|
||||
volumes:
|
||||
- "db-volume:/data"
|
||||
environment:
|
||||
POSTGRES_USER: "myuser"
|
||||
POSTGRES_DBNAME: "myuser"
|
||||
POSTGRES_PASSWORD: "mypass"
|
||||
ALLOW_IP_RANGE: "0.0.0.0/0"
|
||||
build:
|
||||
context: "docker/postgres"
|
||||
args:
|
||||
SRV_UID: "1010"
|
||||
```
|
||||
|
||||
#### SRV_UID
|
||||
|
||||
User ID for the PostgreSQL daemon and so of the data (Default: 1000)
|
||||
|
||||
#### SRV_GID
|
||||
|
||||
Group ID for the PostgreSQL daemon and so of the data (Default: 1000)
|
||||
|
||||
#### SRV_LOCALE
|
||||
|
||||
Locale used for *initdb*, it will be extended with **.UTF-8** and set for *locale*, *lc-ctype*, *lc-monetary*, *lc-numeric*, *lc-time* and *lc-collate*. In addition *encoding* is set to **UTF8**. Please be aware that after the database is initialized, a changing of this parameter is not having any effect, the database will not change its settings, also new databases are not set with different parameters, as *initdb* is not used there anymore. (Default: en_US)
|
||||
|
||||
## Support
|
||||
|
||||
### Discord
|
||||
|
||||
Join the [**People, Postgres, Data**](https://discord.gg/bW2hsax8We) Discord and highlight **Getty** for support.
|
||||
|
||||
### IRC
|
||||
|
||||
Join the [**Libera.Chat**](https://libera.chat/) IRC server and best message **Getty** for support, you can also join the **#postgresql** channel there, via **irc://irc.libera.chat:+6697/postgresql**.
|
||||
|
||||
### Email
|
||||
|
||||
You can also email me under [**getty@conflict.industries**](mailto:getty@conflict.industries)
|
Loading…
Add table
Add a link
Reference in a new issue