diff --git a/Dockerfile b/Dockerfile index 7125651..be48b5b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ ARG PARENT_VERSION=2.3.0-node20.15.0 -ARG PORT=3021 +ARG PORT=3031 ARG PORT_DEBUG=9229 # Development diff --git a/README.md b/README.md index d37b06f..9569637 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# FCP Template Node +# fcp-fd-landing-page Template to support rapid delivery of microservices for FCP Platform. It contains the configuration needed to deploy a simple Hapi Node server to the Azure Kubernetes Platform. diff --git a/docker-compose.override.yaml b/docker-compose.override.yaml index b54d9c0..2c1e20d 100644 --- a/docker-compose.override.yaml +++ b/docker-compose.override.yaml @@ -8,8 +8,8 @@ services: image: fcp-fd-landing-page-development container_name: fcp-fd-landing-page-development ports: - - "3021:3021" - - "9021:9229" + - "3031:3031" + - "9031:9229" volumes: - ./app:/home/node/app - ./package.json:/home/node/package.json diff --git a/helm/fcp-fd-landing-page/values.yaml b/helm/fcp-fd-landing-page/values.yaml index a563575..7ea1da5 100644 --- a/helm/fcp-fd-landing-page/values.yaml +++ b/helm/fcp-fd-landing-page/values.yaml @@ -25,11 +25,11 @@ container: requestCpu: 100m limitMemory: 100Mi limitCpu: 100m - port: 3021 + port: 3031 livenessProbe: path: /healthz - port: 3021 + port: 3031 initialDelaySeconds: 20 periodSeconds: 10 failureThreshold: 3 @@ -37,7 +37,7 @@ livenessProbe: readinessProbe: path: /healthy - port: 3021 + port: 3031 initialDelaySeconds: 30 periodSeconds: 10 failureThreshold: 3 diff --git a/package.json b/package.json index 5863df0..e600391 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "fcp-fd-landing-page", - "version": "0.1.3", + "version": "0.1.4", "description": "Micro front end for Single Front Door landing page", "homepage": "https://github.com/DEFRA/fcp-fd-landing-page", "main": "app/index.js", @@ -15,7 +15,9 @@ "start:debug": "nodemon --inspect-brk=0.0.0.0 --ext js --legacy-watch app/index.js" }, "author": "Defra", - "contributors": [], + "contributors": [ + "Rana Salem " + ], "license": "OGL-UK-3.0", "dependencies": { "@hapi/hapi": "21.3.2", diff --git a/rename.js b/rename.js deleted file mode 100755 index a0f61c7..0000000 --- a/rename.js +++ /dev/null @@ -1,132 +0,0 @@ -#!/usr/bin/env node - -import fs from 'fs' -import readline from 'readline' - -const originalDescription = 'description-of-project-goes-here' -const originalNamespace = 'ffc-demo' -const originalProjectName = 'ffc-template-node' - -function processInput (args) { - const [, , projectName, description] = args - if (args.length === 2) { - console.error('Please enter a new name and description for the project e.g. ffc-demo-web "Web frontend for demo workstream".') - process.exit(1) - } - if (args.length !== 4 || !projectName || projectName.split('-').length < 3 || !description) { - const errMsg = [ - 'Please enter a new name and description for the project.', - 'The name must contain two hyphens and be of the form "--" e.g. "ffc-demo-web".', - 'The description must not be empty and be wrapped in quotes e.g. "excellent new description".' - ] - console.error(errMsg.join('\n')) - process.exit(1) - } - return { description, projectName } -} - -async function confirmRename (projectName, description) { - const affirmativeAnswer = 'yes' - const rl = readline.createInterface({ - input: process.stdin, - output: process.stdout - }) - return new Promise((resolve, reject) => { - rl.question(`Do you want to rename the project to '${projectName}', with a description of '${description}'?\nType '${affirmativeAnswer}' to confirm\n`, (answer) => { - rl.close() - resolve(answer === affirmativeAnswer) - }) - }) -} - -async function getHelmDir () { - const projectName = await fs.promises.readdir('./helm') - return `./helm/${projectName}` -} - -function getScriptDir () { - return './scripts' -} - -async function getHelmFiles () { - // assuming the only dir in ./helm is the project name. - // getting the name here removes dependency on it being updated. - const helmDir = await getHelmDir() - const baseFiles = ['Chart.yaml', 'values.yaml'] - const templateFiles = ['templates/_container.yaml', 'templates/cluster-ip-service.yaml', 'templates/config-map.yaml', 'templates/container-secret.yaml', 'templates/deployment.yaml'] - const files = [...baseFiles, ...templateFiles] - - return files.map((file) => { - return `${helmDir}/${file}` - }) -} - -function getRootFiles () { - return ['docker-compose.yaml', 'docker-compose.override.yaml', 'docker-compose.debug.yaml', 'docker-compose.test.yaml', 'docker-compose.test.watch.yaml', 'docker-compose.test.debug.yaml', 'package.json', 'package-lock.json'] -} - -function getScriptFiles () { - const scriptDir = getScriptDir() - const files = ['test'] - return files.map((file) => { - return `${scriptDir}/${file}` - }) -} - -function getNamespace (projectName) { - const firstIndex = projectName.indexOf('-') - const secondIndex = projectName.indexOf('-', firstIndex + 1) - return projectName.substring(0, secondIndex) -} - -async function renameDirs (projectName) { - const helmDir = await getHelmDir() - await fs.promises.rename(helmDir, `./helm/${projectName}`) -} - -async function updateProjectName (projectName) { - const rootFiles = getRootFiles() - const helmFiles = await getHelmFiles() - const scriptFiles = getScriptFiles() - const filesToUpdate = [...rootFiles, ...helmFiles, ...scriptFiles] - const namespace = getNamespace(projectName) - - console.log(`Updating projectName from '${originalProjectName}', to '${projectName}'. In...`) - await Promise.all(filesToUpdate.map(async (file) => { - console.log(file) - const content = await fs.promises.readFile(file, 'utf8') - const projectNameRegex = new RegExp(originalProjectName, 'g') - const namespaceRegex = new RegExp(originalNamespace, 'g') - const updatedContent = content.replace(projectNameRegex, projectName).replace(namespaceRegex, namespace) - return fs.promises.writeFile(file, updatedContent) - })) - console.log('Completed projectName update.') -} - -async function updateProjectDescription (description) { - const helmDir = await getHelmDir() - const filesToUpdate = ['package.json', `${helmDir}/Chart.yaml`] - - console.log(`Updating description from '${originalDescription}', to '${description}'. In...`) - await Promise.all(filesToUpdate.map(async (file) => { - console.log(file) - const content = await fs.promises.readFile(file, 'utf8') - const updatedContent = content.replace(originalDescription, description) - return fs.promises.writeFile(file, updatedContent) - })) - console.log('Completed description update.') -} - -async function rename () { - const { description, projectName } = processInput(process.argv) - const rename = await confirmRename(projectName, description) - if (rename) { - await renameDirs(projectName) - await updateProjectName(projectName) - await updateProjectDescription(description) - } else { - console.log('Project has not been renamed.') - } -} - -rename()