Skip to content

Commit

Permalink
Test build for #1718
Browse files Browse the repository at this point in the history
  • Loading branch information
SUSE Update Bot committed Sep 24, 2024
1 parent 6245860 commit 654e365
Show file tree
Hide file tree
Showing 18 changed files with 623 additions and 5 deletions.
7 changes: 7 additions & 0 deletions .obs/workflows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,10 @@ staging_build:
source_project: home:defolos:BCI:CR:Tumbleweed
source_package: postgres-16-image
target_project: home:defolos:BCI:CR:Tumbleweed:Staging
- branch_package:
source_project: home:defolos:BCI:CR:Tumbleweed
source_package: postgres-17-image
target_project: home:defolos:BCI:CR:Tumbleweed:Staging
- branch_package:
source_project: home:defolos:BCI:CR:Tumbleweed
source_package: prometheus-image
Expand Down Expand Up @@ -370,6 +374,9 @@ refresh_devel_BCI:
- trigger_services:
project: devel:BCI:Tumbleweed
package: postgres-16-image
- trigger_services:
project: devel:BCI:Tumbleweed
package: postgres-17-image
- trigger_services:
project: devel:BCI:Tumbleweed
package: prometheus-image
Expand Down
2 changes: 1 addition & 1 deletion postgres-12-image/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

FROM opensuse/tumbleweed:latest

RUN set -euo pipefail; zypper -n in --no-recommends postgresql12-server findutils; zypper -n clean; rm -rf /var/log/{lastlog,tallylog,zypper.log,zypp/history,YaST2}
RUN set -euo pipefail; zypper -n in --no-recommends libpq5 postgresql12-server findutils; zypper -n clean; rm -rf /var/log/{lastlog,tallylog,zypper.log,zypp/history,YaST2}

# Define labels according to https://en.opensuse.org/Building_derived_containers
# labelprefix=org.opensuse.application.postgres
Expand Down
1 change: 1 addition & 0 deletions postgres-12-image/_service
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@
<param name="file">Dockerfile</param>
<param name="regex">%%pg_patch_version%%</param>
<param name="package">postgresql12-server</param>
<param name="parse-version">patch</param>
</service>
</services>
2 changes: 1 addition & 1 deletion postgres-13-image/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

FROM opensuse/tumbleweed:latest

RUN set -euo pipefail; zypper -n in --no-recommends postgresql13-server findutils; zypper -n clean; rm -rf /var/log/{lastlog,tallylog,zypper.log,zypp/history,YaST2}
RUN set -euo pipefail; zypper -n in --no-recommends libpq5 postgresql13-server findutils; zypper -n clean; rm -rf /var/log/{lastlog,tallylog,zypper.log,zypp/history,YaST2}

# Define labels according to https://en.opensuse.org/Building_derived_containers
# labelprefix=org.opensuse.application.postgres
Expand Down
1 change: 1 addition & 0 deletions postgres-13-image/_service
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@
<param name="file">Dockerfile</param>
<param name="regex">%%pg_patch_version%%</param>
<param name="package">postgresql13-server</param>
<param name="parse-version">patch</param>
</service>
</services>
2 changes: 1 addition & 1 deletion postgres-14-image/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

FROM opensuse/tumbleweed:latest

RUN set -euo pipefail; zypper -n in --no-recommends postgresql14-server findutils; zypper -n clean; rm -rf /var/log/{lastlog,tallylog,zypper.log,zypp/history,YaST2}
RUN set -euo pipefail; zypper -n in --no-recommends libpq5 postgresql14-server findutils; zypper -n clean; rm -rf /var/log/{lastlog,tallylog,zypper.log,zypp/history,YaST2}

# Define labels according to https://en.opensuse.org/Building_derived_containers
# labelprefix=org.opensuse.application.postgres
Expand Down
1 change: 1 addition & 0 deletions postgres-14-image/_service
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@
<param name="file">Dockerfile</param>
<param name="regex">%%pg_patch_version%%</param>
<param name="package">postgresql14-server</param>
<param name="parse-version">patch</param>
</service>
</services>
2 changes: 1 addition & 1 deletion postgres-15-image/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

FROM opensuse/tumbleweed:latest

RUN set -euo pipefail; zypper -n in --no-recommends postgresql15-server findutils; zypper -n clean; rm -rf /var/log/{lastlog,tallylog,zypper.log,zypp/history,YaST2}
RUN set -euo pipefail; zypper -n in --no-recommends libpq5 postgresql15-server findutils; zypper -n clean; rm -rf /var/log/{lastlog,tallylog,zypper.log,zypp/history,YaST2}

# Define labels according to https://en.opensuse.org/Building_derived_containers
# labelprefix=org.opensuse.application.postgres
Expand Down
1 change: 1 addition & 0 deletions postgres-15-image/_service
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@
<param name="file">Dockerfile</param>
<param name="regex">%%pg_patch_version%%</param>
<param name="package">postgresql15-server</param>
<param name="parse-version">patch</param>
</service>
</services>
2 changes: 1 addition & 1 deletion postgres-16-image/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

FROM opensuse/tumbleweed:latest

RUN set -euo pipefail; zypper -n in --no-recommends postgresql16-server findutils; zypper -n clean; rm -rf /var/log/{lastlog,tallylog,zypper.log,zypp/history,YaST2}
RUN set -euo pipefail; zypper -n in --no-recommends libpq5 postgresql16-server findutils; zypper -n clean; rm -rf /var/log/{lastlog,tallylog,zypper.log,zypp/history,YaST2}

# Define labels according to https://en.opensuse.org/Building_derived_containers
# labelprefix=org.opensuse.application.postgres
Expand Down
1 change: 1 addition & 0 deletions postgres-16-image/_service
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@
<param name="file">Dockerfile</param>
<param name="regex">%%pg_patch_version%%</param>
<param name="package">postgresql16-server</param>
<param name="parse-version">patch</param>
</service>
</services>
66 changes: 66 additions & 0 deletions postgres-17-image/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# SPDX-License-Identifier: PostgreSQL

# Copyright (c) 2024 SUSE LLC

# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon.

# The content of THIS FILE IS AUTOGENERATED and should not be manually modified.
# It is maintained by the BCI team and generated by
# https://github.com/SUSE/BCI-dockerfile-generator

# Please submit bugfixes or comments via https://bugs.opensuse.org/
# You can contact the BCI team via https://github.com/SUSE/bci/discussions

#!UseOBSRepositories

#!BuildTag: opensuse/postgres:17
#!BuildTag: opensuse/postgres:17-%RELEASE%
#!BuildTag: opensuse/postgres:%%pg_minor_version%%
#!BuildTag: opensuse/postgres:%%pg_minor_version%%-%RELEASE%
#!BuildTag: opensuse/postgres:%%pg_patch_version%%
#!BuildTag: opensuse/postgres:%%pg_patch_version%%-%RELEASE%

FROM opensuse/tumbleweed:latest

RUN set -euo pipefail; zypper -n in --no-recommends libpq5 postgresql17-server findutils; zypper -n clean; rm -rf /var/log/{lastlog,tallylog,zypper.log,zypp/history,YaST2}

# Define labels according to https://en.opensuse.org/Building_derived_containers
# labelprefix=org.opensuse.application.postgres
LABEL org.opencontainers.image.authors="openSUSE (https://www.opensuse.org/)"
LABEL org.opencontainers.image.title="openSUSE Tumbleweed PostgreSQL 17"
LABEL org.opencontainers.image.description="PostgreSQL 17 container based on the openSUSE Tumbleweed Base Container Image."
LABEL org.opencontainers.image.version="%%pg_patch_version%%"
LABEL org.opencontainers.image.url="https://www.opensuse.org"
LABEL org.opencontainers.image.created="%BUILDTIME%"
LABEL org.opencontainers.image.vendor="openSUSE Project"
LABEL org.opencontainers.image.source="%SOURCEURL%"
LABEL org.opencontainers.image.ref.name="17-%RELEASE%"
LABEL org.opensuse.reference="registry.opensuse.org/opensuse/postgres:17-%RELEASE%"
LABEL org.openbuildservice.disturl="%DISTURL%"
LABEL org.opensuse.lifecycle-url="https://en.opensuse.org/Lifetime#openSUSE_BCI"
LABEL org.opensuse.release-stage="released"
# endlabelprefix
LABEL io.artifacthub.package.readme-url="https://raw.githubusercontent.com/SUSE/BCI-dockerfile-generator/Tumbleweed/postgres-17-image/README.md"
ENV LANG="en_US.utf8"
ENV PG_MAJOR="17"
ENV PG_VERSION="%%pg_minor_version%%"
ENV PGDATA="/var/lib/pgsql/data"

ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
CMD ["postgres"]
EXPOSE 5432
COPY docker-entrypoint.sh /usr/local/bin/
RUN set -euo pipefail; chmod +x /usr/local/bin/docker-entrypoint.sh; \
sed -i -e 's/exec gosu postgres "/exec setpriv --reuid=postgres --regid=postgres --clear-groups -- "/g' /usr/local/bin/docker-entrypoint.sh; \
mkdir /docker-entrypoint-initdb.d; \
install -m 1775 -o postgres -g postgres -d /run/postgresql; \
install -d -m 0700 -o postgres -g postgres $PGDATA; \
sed -ri "s|^#?(listen_addresses)\s*=\s*\S+.*|\1 = '*'|" /usr/share/postgresql17/postgresql.conf.sample

STOPSIGNAL SIGINT
HEALTHCHECK --interval=10s --start-period=10s --timeout=5s \
CMD pg_isready -U ${POSTGRES_USER:-postgres} -h localhost -p 5432

VOLUME $PGDATA
22 changes: 22 additions & 0 deletions postgres-17-image/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Copyright (c) 2014, Docker PostgreSQL Authors (See AUTHORS)

Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
135 changes: 135 additions & 0 deletions postgres-17-image/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
# PostgreSQL 17 container image

![Redistributable](https://img.shields.io/badge/Redistributable-Yes-green)

## Description

PostgreSQL (often spelled as Postgres) is an extensible and SQL-compliant relational database management system (RDBMS).

PostgreSQL implements most of the SQL:2011 standard, and the RDBMS is ACID-compliant and transactional (including most DDL statements). The latter prevents locking issues using multiversion concurrency control (MVCC) as well as provides immunity to dirty reads and full serializability. PostgreSQL can handle complex SQL queries using different indexing methods that are not available in other databases. It features updateable views and materialized views, triggers, and foreign keys. The RDBMS supports functions and stored procedures. PostgreSQL's functionality can be extended using a vast collection of available extensions.

## Usage

By default, the image launches PostgreSQL with the same configuration that comes with SUSE Linux Enterprise Server.

The only environment variable required to start the container is the PostgreSQL root password.

```ShellSession
$ podman run -it --rm -p 5432:5432 -e POSTGRES_PASSWORD=my-password -v /path/to/data:/var/lib/pgsql/data:Z registry.opensuse.org/opensuse/postgres:17
```

## Volumes

### `/var/lib/pgsql/data`

PostgreSQL data directory location.

## Environment variables

The PostgreSQL image uses several environment variables to configure the database initialization.

The only mandatory variable is `POSTGRES_PASSWORD`; other environment variables are optional.

### POSTGRES_PASSWORD

The `POSTGRES_PASSWORD` environment variable is required to use the PostgreSQL image. It must not be empty or undefined. This environment variable sets the superuser password for PostgreSQL.

### POSTGRES_USER

This optional environment variable is used in conjunction with `POSTGRES_PASSWORD` to set a user and its password. This variable creates the specified user with superuser power and a database with the same name. If it is not specified, the default user of `postgres` is used.

### POSTGRES_DB

This optional environment variable can be used to define a different name for the default database created when the image is first started. If it is not specified, the value of `POSTGRES_USER` is used.

### POSTGRES_INITDB_ARGS

This optional environment variable can be used to send arguments to `postgres initdb`. The value is a space-separated string of arguments as `postgres initdb` expects them. This is useful for adding actions like data page checksums: `-e POSTGRES_INITDB_ARGS="--data-checksums"`.

### POSTGRES_INITDB_WALDIR

This optional environment variable can be used to define another location for the Postgres transaction log. By default, the transaction log is stored in a subdirectory of the main Postgres data folder (`PGDATA`). In certain situations, it is desirable to store the transaction log in a different directory that may be backed by storage with different performance or reliability characteristics.

### POSTGRES_HOST_AUTH_METHOD

This optional variable can be used to control the `auth-method` for host connections for all databases, users, and addresses. If unspecified, the `scram-sha-256` password authentication is used.

On an uninitialized database, this populates `pg_hba.conf` via this approximate line:

`echo "host all all all $POSTGRES_HOST_AUTH_METHOD" >> pg_hba.conf`

For more information about possible values and their meanings, refer to the PostgreSQL documentation on [password Authentication](https://www.postgresql.org/docs/14/auth-password.html) and [pg_hba.conf](https://www.postgresql.org/docs/14/auth-pg-hba-conf.html).

**Note 1:** If you set `POSTGRES_HOST_AUTH_METHOD` to `trust`, then `POSTGRES_PASSWORD` is not required, since it allows anyone to connect without a password.

**Note 2:** If you set `POSTGRES_HOST_AUTH_METHOD` to an alternative value, you might need additional `POSTGRES_INITDB_ARGS` for the database to initialize correctly.

### PGDATA

The value for this variable is `/var/lib/pgsql/data`. This location is a volume and another location is currently not supported.

## Sensitive information

As an alternative to passing sensitive information via environment variables, `_FILE` can be appended to `POSTGRES_INITDB_ARGS`, `POSTGRES_PASSWORD`, `POSTGRES_USER`, and `POSTGRES_DB` environment variables. This makes the initialization script load the values for those variables from files present in the container. To, e.g., pass the password securely, you can store the password in a secret called `postgress-pw` and launch the container as follows:

```ShellSession
$ podman run -it --rm
-p 5432:5432 \
-e POSTGRES_PASSWORD_FILE=/run/secrets/postgress-pw \
--secret postgress-pw \
-v /path/to/data:/var/lib/pgsql/data:Z \
registry.opensuse.org/opensuse/postgres:17
```

## Health, liveness, and readiness

There is one explicit health check added to the container image. This check executes the `pg_isready` for host `localhost` and port `5432`.

The utility [pg_isread](https://www.postgresql.org/docs/current/app-pg-isready.html) checks the connection status of the server, and the exit status specifies the result of the connection check.

## Initialization scripts

To perform additional initialization in an image derived from this one, add one or more `*.sql`, `*.sql.gz`, or `*.sh` scripts under `/docker-entrypoint-initdb.d`. After the entrypoint calls `initdb` to create the default PostgreSQL user and database, it runs any `*.sql` files, runs any executable `*.sh` scripts, and sources any non-executable `*.sh` scripts found in that directory to perform further initialization before starting the service.

**Warning:** Scripts in `/docker-entrypoint-initdb.d` are only executed when you start the container with an empty data directory. Any pre-existing databases are left untouched when the container starts.

**Note:** If one of the `/docker-entrypoint-initdb.d` scripts fails, and the container restarts with the already initialized data directory, it aborts the running scripts.

## Database configuration

For information on the available configuration options, refer to the [PostgreSQL documentation](https://www.postgresql.org/docs/current/runtime-config.html) covering the specific version of your PostgreSQL server.

Below is a list of the most common configuration options:

- Set options directly on the container run line via `-c`.
- Use a custom configuration file and mount it.

**Note:** Configuration files (`postgresql.auto.conf`, `postgresql.conf`, `pg_hba.conf`, and `pg_ident.conf`) are stored in the location defined in `PGDATA`.

## Backup and restore

The utilities `pg_dump` and `pg_dumpall` are available in the container.

To dump the entire contents of a database cluster, run the following command:

```ShellSession
$ podman exec -t $CONTAINER_ID pg_dumpall -c -U $POSTGRES_USER > dump.sql
```

To restore a dump, run the following command:

```ShellSession
$ cat dump.sql | podman exec -i $CONTAINER_ID psql -U $POSTGRES_USER -d $POSTGRES_DB
```

For more information on how to perform backup and restore, refer to the [PostgreSQL documentation](https://www.postgresql.org/docs/current/backup.html).

## Licensing

`SPDX-License-Identifier: PostgreSQL`

This documentation and the build recipe are licensed as PostgreSQL.
The container itself contains various software components under various open source licenses listed in the associated
Software Bill of Materials (SBOM).

This image is based on [openSUSE Tumbleweed](https://get.opensuse.org/tumbleweed/).
7 changes: 7 additions & 0 deletions postgres-17-image/_constraints
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<constraints>
<hardware>
<disk>
<size unit="G">8</size>
</disk>
</hardware>
</constraints>
16 changes: 16 additions & 0 deletions postgres-17-image/_service
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<services>
<service mode="buildtime" name="docker_label_helper"/>
<service mode="buildtime" name="kiwi_metainfo_helper"/>
<service name="replace_using_package_version" mode="buildtime">
<param name="file">Dockerfile</param>
<param name="regex">%%pg_minor_version%%</param>
<param name="package">postgresql17-server</param>
<param name="parse-version">minor</param>
</service>
<service name="replace_using_package_version" mode="buildtime">
<param name="file">Dockerfile</param>
<param name="regex">%%pg_patch_version%%</param>
<param name="package">postgresql17-server</param>
<param name="parse-version">patch</param>
</service>
</services>
Loading

0 comments on commit 654e365

Please sign in to comment.