-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23 from HSLdevcom/development
Add Pikaratikka and upgrade dependencies
- Loading branch information
Showing
7 changed files
with
93 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
FROM node:16-alpine | ||
FROM node:18-alpine | ||
|
||
ENV WORK /opt/mappoc | ||
ENV NODE_ENV=production | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,7 @@ | ||
const { mapValues, orderBy } = require('lodash'); | ||
const fs = require('node:fs'); | ||
|
||
const SECRETS_PATH = '/run/secrets/'; | ||
|
||
// Check each env var and see if it has a value in the secrets. In that case, use the | ||
// secret value. Otherwise use the env var. Using sync fs methods for the sake of | ||
// simplicity, since this will only run once when staring the app, sync is OK. | ||
const secrets = (fs.existsSync(SECRETS_PATH) && fs.readdirSync(SECRETS_PATH)) || []; | ||
|
||
const secretsEnv = mapValues(process.env, (value, key) => { | ||
const matchingSecrets = secrets.filter(secretFile => secretFile.startsWith(key)); | ||
|
||
const currentSecret = | ||
orderBy( | ||
matchingSecrets, | ||
secret => { | ||
const secretVersion = parseInt(secret[secret.length - 1], 10); | ||
return isNaN(secretVersion) ? 0 : secretVersion; | ||
}, | ||
'desc', | ||
)[0] || null; | ||
|
||
const filepath = SECRETS_PATH + currentSecret; | ||
|
||
if (fs.existsSync(filepath)) { | ||
return (fs.readFileSync(filepath, { encoding: 'utf8' }) || '').trim(); | ||
} | ||
|
||
return value; | ||
}); | ||
|
||
|
||
module.exports = { | ||
GRAPHQL_URL: secretsEnv.GRAPHQL_URL || '', | ||
LINK_URL: secretsEnv.LINK_URL || '', | ||
DIGITRANSIT_URL: secretsEnv.DIGITRANSIT_URL || '', | ||
DIGITRANSIT_APIKEY: secretsEnv.DIGITRANSIT_APIKEY || '', | ||
PORT: secretsEnv.PORT || '', | ||
GRAPHQL_URL: process.env.GRAPHQL_URL || '', | ||
LINK_URL: process.env.LINK_URL || '', | ||
DIGITRANSIT_URL: process.env.DIGITRANSIT_URL || '', | ||
DIGITRANSIT_APIKEY: process.env.DIGITRANSIT_APIKEY || '', | ||
PORT: process.env.PORT || '', | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.