Skip to content

Commit

Permalink
Add script to simplify connecting to DB from a pod (#1291)
Browse files Browse the repository at this point in the history
  • Loading branch information
gunndabad authored Apr 19, 2024
1 parent f3a3d23 commit dae38e1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions TeachingRecordSystem/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
8 changes: 8 additions & 0 deletions TeachingRecordSystem/db.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit dae38e1

Please sign in to comment.