# SPDX-License-Identifier: MIT
#!BuildTag: suse/postgres:14
#!BuildTag: suse/postgres:latest
#!BuildTag: suse/postgres:14-%RELEASE%
#!BuildTag: suse/postgres:%%pg_version%%
FROM suse/sle15:15.4

MAINTAINER SUSE LLC (https://www.suse.com/)

# Define labels according to https://en.opensuse.org/Building_derived_containers
# labelprefix=com.suse.application.postgres
PREFIXEDLABEL org.opencontainers.image.title="SLE PostgreSQL 14 Container Image"
PREFIXEDLABEL org.opencontainers.image.description="Image containing PostgreSQL 14 based on the SLE Base Container Image."
PREFIXEDLABEL org.opencontainers.image.version="14"
PREFIXEDLABEL org.opencontainers.image.url="https://www.suse.com/products/server/"
PREFIXEDLABEL org.opencontainers.image.created="%BUILDTIME%"
PREFIXEDLABEL org.opencontainers.image.vendor="SUSE LLC"
PREFIXEDLABEL org.opensuse.reference="registry.suse.com/suse/postgres:14"
PREFIXEDLABEL org.openbuildservice.disturl="%DISTURL%"
PREFIXEDLABEL com.suse.techpreview="true"
PREFIXEDLABEL com.suse.eula="sle-bci"
PREFIXEDLABEL com.suse.lifecycle-url="https://www.suse.com/lifecycle"
PREFIXEDLABEL com.suse.image-type="application"
PREFIXEDLABEL com.suse.release-stage="beta"
# endlabelprefix


RUN zypper -n in --no-recommends postgresql14-server distribution-release && zypper -n clean && rm -rf /var/log/*

ENV LANG="en_US.utf8"
ENV PG_MAJOR="14"
ENV PG_VERSION="%%pg_version%%"
ENV PGDATA="/var/lib/postgresql/data"
ENTRYPOINT ["docker-entrypoint.sh"]

VOLUME /var/lib/postgresql/data

COPY docker-entrypoint.sh /usr/local/bin/
RUN chmod +x /usr/local/bin/docker-entrypoint.sh && \
    ln -s su /usr/bin/gosu && \
    mkdir /docker-entrypoint-initdb.d && \
    sed -ri "s|^#?(listen_addresses)\s*=\s*\S+.*|\1 = '*'|" /usr/share/postgresql14/postgresql.conf.sample

STOPSIGNAL SIGINT
EXPOSE 5432
CMD ["postgres"]
