From f2411bd556326ce732423bbd4690d12b93fa2f27 Mon Sep 17 00:00:00 2001 From: Gary van Woerkens Date: Fri, 19 Apr 2024 16:08:50 +0200 Subject: [PATCH] chore: add pgadmin --- .kontinuous/env/preprod/values.yaml | 75 +++++++++++++++++++++++++++ src/pgadmin/Dockerfile | 20 ++++++++ src/pgadmin/entrypoint.sh | 79 +++++++++++++++++++++++++++++ 3 files changed, 174 insertions(+) create mode 100644 src/pgadmin/Dockerfile create mode 100644 src/pgadmin/entrypoint.sh diff --git a/.kontinuous/env/preprod/values.yaml b/.kontinuous/env/preprod/values.yaml index 6ffd167c..e1d1f6fa 100644 --- a/.kontinuous/env/preprod/values.yaml +++ b/.kontinuous/env/preprod/values.yaml @@ -130,3 +130,78 @@ pg-strapi: cnpg-cluster: backup: ~tpl~enabled: "false" + +pgadmin: + ~chart: app + ~needs: ["build-pgadmin"] + imagePackage: pgadmin + env: + - name: POSTGRES_USER + valueFrom: + secretRef: + name: pg-app + key: PGUSER + - name: POSTGRES_PASSWORD + valueFrom: + secretRef: + name: pg-app + key: PGPASSWORD + - name: POSTGRES_HOST + valueFrom: + secretRef: + name: pg-app + key: PGHOST + - name: POSTGRES_PORT + valueFrom: + secretRef: + name: pg-app + key: PGPORT + - name: POSTGRES_USER_2 + valueFrom: + secretRef: + name: pg-n8n + key: PGUSER + - name: POSTGRES_PASSWORD_2 + valueFrom: + secretRef: + name: pg-n8n + key: PGPASSWORD + - name: POSTGRES_HOST_2 + valueFrom: + secretRef: + name: pg-n8n + key: PGHOST + - name: POSTGRES_PORT_2 + valueFrom: + secretRef: + name: pg-n8n + key: PGPORT + - name: POSTGRES_USER_3 + valueFrom: + secretRef: + name: pg-strapi + key: PGUSER + - name: POSTGRES_PASSWORD_3 + valueFrom: + secretRef: + name: pg-strapi + key: PGPASSWORD + - name: POSTGRES_HOST_3 + valueFrom: + secretRef: + name: pg-strapi + key: PGHOST + - name: POSTGRES_PORT_3 + valueFrom: + secretRef: + name: pg-strapi + key: PGPORT + +jobs: + ~chart: jobs + runs: + build-pgadmin: + use: build + with: + imagePackage: pgadmin + context: src/pgadmin diff --git a/src/pgadmin/Dockerfile b/src/pgadmin/Dockerfile new file mode 100644 index 00000000..04026ecb --- /dev/null +++ b/src/pgadmin/Dockerfile @@ -0,0 +1,20 @@ +ARG BASE_VERSION=8.5 +FROM dpage/pgadmin4:${BASE_VERSION} + +ENV PGADMIN_DEFAULT_EMAIL="pgadmin4@pgadmin.org" +ENV PGADMIN_DEFAULT_PASSWORD="admin" +ENV PGADMIN_CONFIG_SERVER_MODE="False" +ENV PGADMIN_CONFIG_MASTER_PASSWORD_REQUIRED="False" + +ENV POSTGRES_HOST="postgres" +ENV POSTGRES_PORT="5432" +ENV POSTGRES_DB="*" + +USER root +COPY entrypoint.sh /entrypoint.sh +RUN chmod +x /entrypoint.sh && \ + touch /pgadmin4/servers.json && \ + chown pgadmin:root /pgadmin4/servers.json +USER pgadmin + +ENTRYPOINT /entrypoint.sh diff --git a/src/pgadmin/entrypoint.sh b/src/pgadmin/entrypoint.sh new file mode 100644 index 00000000..bcaf7046 --- /dev/null +++ b/src/pgadmin/entrypoint.sh @@ -0,0 +1,79 @@ +#!/usr/bin/env sh + +set -e + +## Create /var/lib/pgadmin/pgpass +# 1st database +echo "$POSTGRES_HOST:$POSTGRES_PORT:postgres:$POSTGRES_USER:$POSTGRES_PASSWORD" | tee -a "/var/lib/pgadmin/pgpass" >/dev/null +echo "$POSTGRES_HOST:$POSTGRES_PORT:$POSTGRES_DB:$POSTGRES_USER:$POSTGRES_PASSWORD" | tee -a "/var/lib/pgadmin/pgpass" >/dev/null +POSTGRES_HOST_1=$POSTGRES_HOST +POSTGRES_PORT_1=$POSTGRES_PORT +POSTGRES_DB_1=$POSTGRES_DB +POSTGRES_USER_1=$POSTGRES_USER +POSTGRES_PASSWORD_1=$POSTGRES_PASSWORD + +## Create servers.json +tee /pgadmin4/servers.json >/dev/null </dev/null + echo "$POSTGRES_HOST:$POSTGRES_PORT:$POSTGRES_DB:$POSTGRES_USER:$POSTGRES_PASSWORD" | tee -a "/var/lib/pgadmin/pgpass_$COUNT" >/dev/null + + tee -a /pgadmin4/servers.json >/dev/null </dev/null <