From 7460f10bc88776767b2900f5d4489673968b79a7 Mon Sep 17 00:00:00 2001 From: Will Barnett Date: Tue, 10 Oct 2023 08:51:09 +0100 Subject: [PATCH 1/2] Added dockerfile for tokenserver, fixed port env variable name, and made dotenv a runtime dependency. --- package-lock.json | 32 ++++++++++++++++++-------------- tokenserver/Dockerfile | 19 +++++++++++++++++++ tokenserver/package.json | 2 +- tokenserver/src/config.js | 2 +- 4 files changed, 39 insertions(+), 16 deletions(-) create mode 100644 tokenserver/Dockerfile diff --git a/package-lock.json b/package-lock.json index 166512d..c00e56b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -913,6 +913,17 @@ "void-elements": "^2.0.0" } }, + "node_modules/dotenv": { + "version": "16.3.1", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.3.1.tgz", + "integrity": "sha512-IPzF4w4/Rd94bA9imS68tZBaYyBWSCE47V1RGuMrB94iyTOIEwRmVL2x/4An+6mETpLrKJ5hQkB8W4kFAadeIQ==", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/motdotla/dotenv?sponsor=1" + } + }, "node_modules/ee-first": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", @@ -3166,12 +3177,12 @@ "cookie": "^0.5.0", "cookie-parser": "^1.4.6", "cors": "^2.8.5", + "dotenv": "^16.3.1", "express": "^4.18.2", "octokit": "^2.0.14" }, "devDependencies": { "@types/cookie": "^0.5.1", - "dotenv": "^16.0.3", "ts-loader": "^9.4.2", "typescript": "^5.0.3" } @@ -3632,14 +3643,6 @@ "version": "2.3.1", "license": "ISC" }, - "tokenserver/node_modules/dotenv": { - "version": "16.0.3", - "dev": true, - "license": "BSD-2-Clause", - "engines": { - "node": ">=12" - } - }, "tokenserver/node_modules/ecdsa-sig-formatter": { "version": "1.0.11", "license": "Apache-2.0", @@ -4760,6 +4763,11 @@ "void-elements": "^2.0.0" } }, + "dotenv": { + "version": "16.3.1", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.3.1.tgz", + "integrity": "sha512-IPzF4w4/Rd94bA9imS68tZBaYyBWSCE47V1RGuMrB94iyTOIEwRmVL2x/4An+6mETpLrKJ5hQkB8W4kFAadeIQ==" + }, "ee-first": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", @@ -5380,7 +5388,7 @@ "cookie": "^0.5.0", "cookie-parser": "^1.4.6", "cors": "^2.8.5", - "dotenv": "^16.0.3", + "dotenv": "^16.3.1", "express": "^4.18.2", "octokit": "^2.0.14", "ts-loader": "^9.4.2", @@ -5694,10 +5702,6 @@ "deprecation": { "version": "2.3.1" }, - "dotenv": { - "version": "16.0.3", - "dev": true - }, "ecdsa-sig-formatter": { "version": "1.0.11", "requires": { diff --git a/tokenserver/Dockerfile b/tokenserver/Dockerfile new file mode 100644 index 0000000..f4522d6 --- /dev/null +++ b/tokenserver/Dockerfile @@ -0,0 +1,19 @@ +# syntax=docker/dockerfile:1 + +FROM node:18.13-alpine + +# Create mdenet-ts directory +WORKDIR /usr/src/mdenet-ts + +# Install app dependencies +# A wildcard is used to ensure both package.json AND package-lock.json are copied +# where available (npm@5+) +COPY package*.json ./ + +RUN npm install +COPY . . + +EXPOSE 10000 + +CMD ["node", "-r", "dotenv/config", "dist/server.js"] + diff --git a/tokenserver/package.json b/tokenserver/package.json index b7cd705..4e0a0bc 100644 --- a/tokenserver/package.json +++ b/tokenserver/package.json @@ -15,12 +15,12 @@ "cookie": "^0.5.0", "cookie-parser": "^1.4.6", "cors": "^2.8.5", + "dotenv": "^16.3.1", "express": "^4.18.2", "octokit": "^2.0.14" }, "devDependencies": { "@types/cookie": "^0.5.1", - "dotenv": "^16.0.3", "ts-loader": "^9.4.2", "typescript": "^5.0.3" } diff --git a/tokenserver/src/config.js b/tokenserver/src/config.js index 59b7efd..bdafa77 100644 --- a/tokenserver/src/config.js +++ b/tokenserver/src/config.js @@ -2,7 +2,7 @@ export const config = { - port: process.env.PORT || "10000", + port: process.env.TS_PORT || "10000", endpointsPrefix: process.env.TS_ENDPOINT_PREFIX || "/mdenet-auth", From 4d7002fcec1286433bf08466e7398c1d88db1006 Mon Sep 17 00:00:00 2001 From: Will Barnett Date: Thu, 12 Oct 2023 17:26:59 +0100 Subject: [PATCH 2/2] Replaced tokenserver dockerfile fixed port value to use environment variable. --- tokenserver/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tokenserver/Dockerfile b/tokenserver/Dockerfile index f4522d6..0451db4 100644 --- a/tokenserver/Dockerfile +++ b/tokenserver/Dockerfile @@ -13,7 +13,7 @@ COPY package*.json ./ RUN npm install COPY . . -EXPOSE 10000 +EXPOSE ${TS_PORT} CMD ["node", "-r", "dotenv/config", "dist/server.js"]