From 6d58d5af1f7ef06fcbddc0429436906a5a74f489 Mon Sep 17 00:00:00 2001 From: Nishant Aanjaney Jalan Date: Sun, 20 Oct 2024 14:50:30 +0100 Subject: [PATCH 1/3] entry script to load the ssl certificate --- collection/.env.local.template | 3 +++ collection/Dockerfile | 3 ++- collection/entry.sh | 7 +++++++ 3 files changed, 12 insertions(+), 1 deletion(-) create mode 100755 collection/entry.sh diff --git a/collection/.env.local.template b/collection/.env.local.template index 569332b..5566c66 100644 --- a/collection/.env.local.template +++ b/collection/.env.local.template @@ -23,3 +23,6 @@ ROOT_USER_EMAIL="guilds.docsoc@imperial.ac.uk" # Replace "postgres:postgres" with ":" # And docsoc-tools-collection with the name of the database you are using COLLECTION_DATABASE_URL="postgres://postgres:postgres@localhost:5432/docsoc-tools-collection" + +# Optional PSQL certicate if the connection occurs over SSL +PG_CERT= \ No newline at end of file diff --git a/collection/Dockerfile b/collection/Dockerfile index ef914dc..ccf1682 100644 --- a/collection/Dockerfile +++ b/collection/Dockerfile @@ -46,6 +46,7 @@ COPY --from=builder /build/collection/.next/standalone/common ./ COPY --from=builder /build/collection/.next/standalone/package.json ./ COPY --from=builder /build/collection/.next/standalone/node_modules ./node_modules COPY --from=builder /build/collection/.next/static ./.next/static +COPY --from=builder /build/collection/entry.sh ./entry.sh COPY --from=builder --chown=node:node /build/collection/prisma ./prisma @@ -60,4 +61,4 @@ EXPOSE 3000 # Learn more here: https://nextjs.org/telemetry # Uncomment the following line in case you want to disable telemetry. ENV NEXT_TELEMETRY_DISABLED=1 -CMD ["dumb-init", "node", "server.js"] +CMD ["./entry.sh"] diff --git a/collection/entry.sh b/collection/entry.sh new file mode 100755 index 0000000..f39f045 --- /dev/null +++ b/collection/entry.sh @@ -0,0 +1,7 @@ +# This is to be used with the Docker Container only! +# The script loads the PSQL certificate and starts the server. + +#!/usr/bin/dumb-init /bin/sh +echo $PG_CERT > ./prisma/postgres.crt + +node server.js \ No newline at end of file From ab6c766e3fe8743d67c1157720f632266f47303f Mon Sep 17 00:00:00 2001 From: Nishant Aanjaney Jalan Date: Sun, 20 Oct 2024 15:14:10 +0100 Subject: [PATCH 2/3] run entry with dumb-init and fix script --- collection/Dockerfile | 2 +- collection/entry.sh | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/collection/Dockerfile b/collection/Dockerfile index ccf1682..827729c 100644 --- a/collection/Dockerfile +++ b/collection/Dockerfile @@ -61,4 +61,4 @@ EXPOSE 3000 # Learn more here: https://nextjs.org/telemetry # Uncomment the following line in case you want to disable telemetry. ENV NEXT_TELEMETRY_DISABLED=1 -CMD ["./entry.sh"] +CMD ["dumb-init", "./entry.sh"] diff --git a/collection/entry.sh b/collection/entry.sh index f39f045..b280dd9 100755 --- a/collection/entry.sh +++ b/collection/entry.sh @@ -1,7 +1,8 @@ +#!/usr/bin/dumb-init /bin/sh + # This is to be used with the Docker Container only! # The script loads the PSQL certificate and starts the server. -#!/usr/bin/dumb-init /bin/sh echo $PG_CERT > ./prisma/postgres.crt node server.js \ No newline at end of file From 1ca33eca003999c0ea23d109d663701a894e69bd Mon Sep 17 00:00:00 2001 From: Nishant Aanjaney Jalan Date: Sun, 20 Oct 2024 15:23:18 +0100 Subject: [PATCH 3/3] remove dumb-init from docker cmd --- collection/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/collection/Dockerfile b/collection/Dockerfile index 827729c..ccf1682 100644 --- a/collection/Dockerfile +++ b/collection/Dockerfile @@ -61,4 +61,4 @@ EXPOSE 3000 # Learn more here: https://nextjs.org/telemetry # Uncomment the following line in case you want to disable telemetry. ENV NEXT_TELEMETRY_DISABLED=1 -CMD ["dumb-init", "./entry.sh"] +CMD ["./entry.sh"]