Skip to content

Commit

Permalink
commit stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
matthias committed Feb 15, 2023
1 parent 8f6215e commit 962e863
Show file tree
Hide file tree
Showing 19 changed files with 1,451 additions and 90 deletions.
56 changes: 36 additions & 20 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@

# Define Default if Values not exist
BASE_IMAGE ?= rockylinux:9-minimal
BASE_IMAGE ?= rockylinux:9.1-minimal
BASEOS ?= rocky9
IMAGE_REPOSITORY ?= docker.io
IMAGE_PATH ?= cybertec-os-container
PG_MAJOR ?= 15
PG_VERSION ?= 15.0
IMAGE_PATH ?= cybertec-pg-container
PGVERSION ?= 15
PGVERSION_FULL ?= 15.2
OLD_PG_VERSIONS ?= 10 11 12 13 14
PATRONI_VERSION ?= 2.1.4
PGBACKREST_VERSION ?= 2.41
POSTGIS_VERSION ?= 3.2
PACKAGER ?= dnf
BUILD ?= 0
IMAGE_TAG ?= $(BASEOS)-$(PG_VERSION)-$(BUILD)
POSTGIS_IMAGE_TAG ?= $(BASEOS)-$(PG_VERSION)-$(POSTGIS_VERSION)-$(BUILD)
IMAGE_TAG ?= $(BASEOS)-$(PGVERSION_FULL)-$(BUILD)
POSTGIS_IMAGE_TAG ?= $(BASEOS)-$(PGVERSION_FULL)-$(POSTGIS_VERSION)-$(BUILD)

# Settings for the Build-Process
BUILDWITH ?= docker
ROOTPATH = $(GOPATH)/src/github.com/cybertec/cybertec-os-container
ROOTPATH = $(GOPATH)/src/github.com/cybertec/cybertec-pg-container
ifndef ROOTPATH
export ROOTPATH=$(GOPATH)/src/github.com/cybertec/cybertec-os-container
export ROOTPATH=$(GOPATH)/src/github.com/cybertec/cybertec-pg-container
endif

# Build Images
Expand All @@ -28,12 +28,13 @@ all: base pgbackrest postgres
base: base
pgbackrest: pgbackrest
postgres: base postgres
postgres-stage: postgres-stage
postgres-stage: base postgres-stage
exporter: exporter

base-build:
docker build $(ROOTPATH) \
--file $(ROOTPATH)/docker/base/Dockerfile \
--tag cybertec-os-container/base:0.0.$(BUILD) \
--tag cybertec-pg-container/base:0.0.$(BUILD) \
--build-arg BASE_IMAGE \
--build-arg IMAGE_REPOSITORY \
--build-arg BASEOS \
Expand All @@ -44,22 +45,22 @@ base: base-build;
pgbackrest-build:
docker build $(ROOTPATH) \
--file $(ROOTPATH)/docker/pgbackrest/Dockerfile \
--tag cybertec-os-container/pgbackrest:0.0.$(BUILD) \
--tag cybertec-pg-container/pgbackrest:0.0.$(BUILD) \
--build-arg BASE_IMAGE \
--build-arg IMAGE_REPOSITORY \
--build-arg BASEOS \
--build-arg PACKAGER \
--build-arg CONTAINERSUITE \
--build-arg BUILD \
--build-arg PGBACKREST_VERSION \
--build-arg PG_MAJOR
--build-arg PGVERSION

pgbackrest: pgbackrest-build;

postgres-build:
docker build $(ROOTPATH) \
--file $(ROOTPATH)/docker/postgres/Dockerfile \
--tag cybertec-os-container/postgres:$(PG_MAJOR).0.$(BUILD) \
--tag cybertec-pg-container/postgres:$(PGVERSION_FULL)-$(BETA)$(BUILD) \
--build-arg BASE_IMAGE \
--build-arg IMAGE_REPOSITORY \
--build-arg BASEOS \
Expand All @@ -68,16 +69,32 @@ postgres-build:
--build-arg BUILD \
--build-arg PATRONI_VERSION \
--build-arg PGBACKREST_VERSION \
--build-arg PG_VERSION \
--build-arg OLD_PG_VERSIONS \
--build-arg PG_MAJOR
--build-arg PGVERSION

postgres: postgres-build

postgres-stage-build:
docker build $(ROOTPATH) \
--file $(ROOTPATH)/docker/postgres_stage/Dockerfile \
--tag cybertec-os-container/postgres-stage:$(PG_MAJOR).0.$(BUILD) \
--file $(ROOTPATH)/docker/postgres-stage/Dockerfile \
--tag cybertec-pg-container/postgres-stage:$(PGVERSION_FULL)-$(BETA)$(BUILD) \
--build-arg BASE_IMAGE \
--build-arg IMAGE_REPOSITORY \
--build-arg BASEOS \
--build-arg PACKAGER \
--build-arg CONTAINERSUITE \
--build-arg BUILD \
--build-arg PATRONI_VERSION \
--build-arg PGBACKREST_VERSION \
--build-arg OLD_PG_VERSIONS \
--build-arg PGVERSION

postgres-stage: postgres-stage-build

exporter-build:
docker build $(ROOTPATH) \
--file $(ROOTPATH)/docker/exporter/Dockerfile \
--tag cybertec-pg-container/exporter:0.1.$(BUILD) \
--build-arg BASE_IMAGE \
--build-arg IMAGE_REPOSITORY \
--build-arg BASEOS \
Expand All @@ -86,8 +103,7 @@ postgres-stage-build:
--build-arg BUILD \
--build-arg PATRONI_VERSION \
--build-arg PGBACKREST_VERSION \
--build-arg PG_VERSION \
--build-arg OLD_PG_VERSION \
--build-arg PG_MAJOR
--build-arg PGVERSION

postgres-stage: postgres-stage-build
exporter: exporter-build
2 changes: 2 additions & 0 deletions docker/base/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ RUN ${PACKAGER} -y install --nodocs \
glibc-langpack-en \
&& ${PACKAGER} -y clean all ;

#Enable CRB-Repo (Powertools)
RUN ${PACKAGER} -y config-manager --set-enabled crb
#Add PostgreSQL-Repo to Base
RUN ${PACKAGER} install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-9-x86_64/pgdg-redhat-repo-latest.noarch.rpm && ${PACKAGER} -y update && ${PACKAGER} -y clean all
#RUN dnf -qy module disable postgresql
Expand Down
39 changes: 39 additions & 0 deletions docker/exporter/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
ARG CONTAINERSUITE
ARG BUILD

FROM ${CONTAINERSUITE}/base:0.0.${BUILD}

# Dockerfile specific informations
ARG PACKAGER
ARG BASEOS
ARG PGBACKREST_VERSION
ARG PG_MAJOR

RUN if [ "$BASEOS" = "ubi8" ] ; then \
${PACKAGER} -y install --nodocs \
shadow-utils \
tar \
bzip2 \
lz4 \
#crunchy-backrest-${BACKREST_VER} \
&& ${PACKAGER} -y clean all ; \
else \
${PACKAGER} -y install --nodocs \
--setopt=skip_missing_names_on_install=False \
bzip2 \
lz4 \
nano \
git \
go \
dumb-init \
&& ${PACKAGER} -y clean all ; \
fi

RUN git clone https://github.com/prometheus-community/postgres_exporter.git && cd postgres_exporter && make build
COPY launcher/exporter/launch.sh /
COPY scripts/exporter/queries/ /postgres_exporter/queries

ENTRYPOINT ["/usr/bin/dumb-init", "--"]

CMD ["/bin/sh", "/launch.sh", "init"]
#CMD ["/bin/sh", "/scripts/postgres/promote.sh"]
134 changes: 134 additions & 0 deletions docker/newpg/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
ARG BASE_IMAGE=ubuntu:22.04
ARG PGVERSION=15
ARG TIMESCALEDB="1.7.5 2.3.1 2.9.2"
ARG DEMO=false
ARG COMPRESS=false
ARG ADDITIONAL_LOCALES=
ARG CONTAINERSUITE
ARG BUILD


FROM ${CONTAINERSUITE}/base:0.0.${BUILD} as base

ARG ADDITIONAL_LOCALES

COPY build_scripts/locales.sh /builddeps/

RUN bash /builddeps/locales.sh


FROM ${CONTAINERSUITE}/base:0.0.${BUILD} as dependencies-builder

ARG DEMO

ENV WALG_VERSION=v2.0.1

COPY build_scripts/dependencies.sh /builddeps/

COPY dependencies/debs /builddeps/

RUN bash /builddeps/dependencies.sh


FROM ${CONTAINERSUITE}/base:0.0.${BUILD} as builder-false

ARG DEMO
ARG ADDITIONAL_LOCALES

COPY build_scripts/prepare.sh build_scripts/locales.sh /builddeps/

RUN bash /builddeps/prepare.sh

COPY --from=base /usr/lib/locale/locale-archive /usr/lib/locale/locale-archive.18

COPY cron_unprivileged.c dependencies/src /builddeps/
COPY build_scripts/base.sh /builddeps/
COPY --from=dependencies-builder /builddeps/*.deb /builddeps/

ARG PGVERSION
ARG TIMESCALEDB
ARG TIMESCALEDB_APACHE_ONLY=true
ARG TIMESCALEDB_TOOLKIT=true
ARG COMPRESS
ARG PGOLDVERSIONS="10 11 12 13 14"
ARG WITH_PERL=false

ARG DEB_PG_SUPPORTED_VERSIONS="$PGOLDVERSIONS $PGVERSION"

# Install PostgreSQL, extensions and contribs
ENV POSTGIS_VERSION=3.3 \
POSTGIS_LEGACY=3.2 \
BG_MON_COMMIT=241d8134e4dda4ffe6f21d40abf8d544d78bc9d8 \
PG_AUTH_MON_COMMIT=439697fe2980cf48f1760f45e04c2d69b2748e73 \
PG_MON_COMMIT=34c35a86e6dea26930bf1f770048cea2c695b80b \
SET_USER=REL3_0_0 \
PLPROFILER=REL4_2_1 \
PG_PROFILE=4.1 \
PAM_OAUTH2=v1.0.1 \
PLANTUNER_COMMIT=800d81bc85da64ff3ef66e12aed1d4e1e54fc006 \
PG_PERMISSIONS_COMMIT=314b9359e3d77c0b2ef7dbbde97fa4be80e31925 \
PG_TM_AUX_COMMIT=51cf42f6043608919802fcc48458471d0ea3a127

WORKDIR /builddeps
RUN bash base.sh

# Install wal-g
COPY --from=dependencies-builder /builddeps/wal-g /usr/local/bin/

COPY build_scripts/patroni_wale.sh build_scripts/compress_build.sh /builddeps/

# Install patroni and wal-e
ENV PATRONIVERSION=3.0.0
ENV WALE_VERSION=1.1.1

WORKDIR /

RUN bash /builddeps/patroni_wale.sh

RUN if [ "$COMPRESS" = "true" ]; then bash /builddeps/compress_build.sh; fi


FROM scratch as builder-true
COPY --from=builder-false / /


FROM builder-${COMPRESS}

LABEL maintainer="Polina Bungina <[email protected]>"

ARG PGVERSION
ARG TIMESCALEDB
ARG DEMO
ARG COMPRESS

EXPOSE 5432 8008 8080

ENV LC_ALL=en_US.utf-8 \
PATH=$PATH:/usr/lib/postgresql/$PGVERSION/bin \
PGHOME=/home/postgres \
RW_DIR=/run \
TIMESCALEDB=$TIMESCALEDB \
DEMO=$DEMO

ENV WALE_ENV_DIR=$RW_DIR/etc/wal-e.d/env \
LOG_ENV_DIR=$RW_DIR/etc/log.d/env \
PGROOT=$PGHOME/pgdata/pgroot

ENV PGDATA=$PGROOT/data \
PGLOG=$PGROOT/pg_log

ENV USE_OLD_LOCALES=false

WORKDIR $PGHOME

COPY motd /etc/
COPY runit /etc/service/
COPY pgq_ticker.ini $PGHOME/
COPY build_scripts/post_build.sh /builddeps/

RUN sh /builddeps/post_build.sh && rm -rf /builddeps/

COPY scripts bootstrap major_upgrade /scripts/
COPY launch.sh /

CMD ["/bin/sh", "/launch.sh", "init"]
6 changes: 3 additions & 3 deletions docker/pgbackrest/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ FROM ${CONTAINERSUITE}/base:0.0.${BUILD}
ARG PACKAGER
ARG BASEOS
ARG PGBACKREST_VERSION
ARG PG_MAJOR
ARG PGVERSION

RUN if [ "$BASEOS" = "ubi8" ] ; then \
${PACKAGER} -y install --nodocs \
Expand All @@ -26,7 +26,7 @@ else \
openssh-server \
bzip2 \
lz4 \
postgresql${PG_MAJOR}-server \
postgresql${PGVERSION}-server \
pgbackrest-${PGBACKREST_VERSION} \
nano \
&& ${PACKAGER} -y clean all ; \
Expand Down Expand Up @@ -67,7 +67,7 @@ RUN curl -LO https://dl.k8s.io/release/v1.26.0/bin/linux/amd64/kubectl && chmod
RUN chown -R postgres:postgres /opt/pgbackrest \
/backrestrepo /home/postgres/pgdata

ENV PATH=$PATH:/usr/pgsql-$PG_MAJOR/bin
ENV PATH=$PATH:/usr/pgsql-$PGVERSION/bin
COPY launcher/pgbackrest/launch.sh /

VOLUME ["sshd", "/home/postgres/pgdata", "/backrestrepo"]
Expand Down
Loading

0 comments on commit 962e863

Please sign in to comment.