From 41bbd250d6fd846c4e3e7c66ecb5860aac30ff93 Mon Sep 17 00:00:00 2001 From: James Gunn Date: Fri, 19 Apr 2024 15:59:12 +0100 Subject: [PATCH] Add script to simply connecting to DB from a pod --- TeachingRecordSystem/Dockerfile | 3 +++ TeachingRecordSystem/db.sh | 8 ++++++++ 2 files changed, 11 insertions(+) create mode 100644 TeachingRecordSystem/db.sh diff --git a/TeachingRecordSystem/Dockerfile b/TeachingRecordSystem/Dockerfile index 1804dcccb..90afae7f2 100644 --- a/TeachingRecordSystem/Dockerfile +++ b/TeachingRecordSystem/Dockerfile @@ -8,8 +8,11 @@ COPY src/TeachingRecordSystem.Cli/bin/Release/net8.0/publish/ Apps/TrsCli/ COPY src/TeachingRecordSystem.SupportUi/bin/Release/net8.0/publish/ Apps/SupportUi/ COPY src/TeachingRecordSystem.Worker/bin/Release/net8.0/publish/ Apps/Worker/ COPY src/TeachingRecordSystem.AuthorizeAccess/bin/Release/net8.0/publish/ Apps/AuthorizeAccess/ +COPY db.sh Apps/db.sh WORKDIR /Apps +RUN chmod +x /Apps/db.sh + # Install Culture prerequisities RUN apk add --no-cache \ tzdata \ diff --git a/TeachingRecordSystem/db.sh b/TeachingRecordSystem/db.sh new file mode 100644 index 000000000..7c7f9b358 --- /dev/null +++ b/TeachingRecordSystem/db.sh @@ -0,0 +1,8 @@ +ENV_VARS=$(env | grep DefaultConnection | sed 's/^ConnectionStrings__DefaultConnection=//' | awk -v RS=';' -v FS='=' ' +/^Server/ { print "export PGHOST=" $2 } +/^Database/ { print "export PGDATABASE=" $2 } +/^User Id/ { print "export PGUSER=" $2 } +/^Password/ { print "export PGPASSWORD=" substr($0, 10) } +') +eval "$ENV_VARS" +psql