Add support for deploying from TS source

Signed-off-by: Fred Boniface <fred@fjla.uk>
This commit is contained in:
Fred Boniface 2023-07-28 20:51:43 +01:00
parent b717917500
commit 159c46c4cc
19 changed files with 32 additions and 23 deletions

View File

@ -1,7 +1,16 @@
FROM node:19 FROM node:20 as builder
EXPOSE 8460 EXPOSE 8460
WORKDIR /usr/src/app WORKDIR /usr/src/app
COPY ./package*.json ./ COPY ./package*.json ./
RUN npm ci --omit=dev RUN npm i
COPY . . COPY . .
CMD [ "node", "app.js" ] RUN npm run build
FROM node:20-slim
EXPOSE 8460
WORKDIR /usr/src/app
COPY ./mail-templates/* ./mail-templates/
COPY ./package*.json ./
RUN npm ci --omit=dev
COPY --from=builder /usr/src/app/dist/ ./
CMD [ "node" , "app.js" ]

View File

@ -18,7 +18,7 @@ const cors = require('cors');
const authenticate= require('./src/middlewares/auth.middlewares'); const authenticate= require('./src/middlewares/auth.middlewares');
// Internal Requires // Internal Requires
const log = require('./src/utils/log.utils'); const log = require('./src/utils/logs.utils');
const version = require('./src/configs/version.configs'); const version = require('./src/configs/version.configs');
const listRtr = require('./src/routes/list.routes'); const listRtr = require('./src/routes/list.routes');
const ldbRtr = require('./src/routes/ldb.routes'); const ldbRtr = require('./src/routes/ldb.routes');
@ -54,7 +54,7 @@ log.out(`app: Starting OwlBoard - Backend Version: ${version.app} - ` +
`API versions: ${version.api}`, 'init'); `API versions: ${version.api}`, 'init');
// Express Error Handling: // Express Error Handling:
app.use((err: Error, req: Request, res, next) => { app.use((err, req, res, next) => {
const statusCode = err.statuscode || 500; const statusCode = err.statuscode || 500;
console.error(err.message, err.stack); console.error(err.message, err.stack);
res.status(statusCode).json({'message': err.message}); res.status(statusCode).json({'message': err.message});
@ -103,7 +103,7 @@ mode === 'development'
: null; : null;
// Start Express // Start Express
app.listen(srvPort, srvListen, (error: Error) =>{ app.listen(srvPort, srvListen, (error) =>{
if(!error) { if(!error) {
log.out(`app.listen: Listening on http://${srvListen}:${srvPort}`, 'init'); log.out(`app.listen: Listening on http://${srvListen}:${srvPort}`, 'init');
log.out('app.listen: State - alive', 'init'); log.out('app.listen: State - alive', 'init');

View File

@ -1,5 +1,5 @@
const issue = require('../services/issue.services'); const issue = require('../services/issue.services');
const log = require('../utils/log.utils'); const log = require('../utils/logs.utils');
async function post(req, res, next){ async function post(req, res, next){
try { try {

View File

@ -1,5 +1,5 @@
const utils = require('../utils/auth.utils'); const utils = require('../utils/auth.utils');
const log = require('../utils/log.utils'); const log = require('../utils/logs.utils');
module.exports = async function authCheck(req, res, next) { module.exports = async function authCheck(req, res, next) {
log.out('authMiddlewares: Checking authentication', 'dbug'); log.out('authMiddlewares: Checking authentication', 'dbug');

View File

@ -1,4 +1,4 @@
const log = require('../utils/log.utils'); const log = require('../utils/logs.utils');
module.exports = async function requireJson(req, res, next) { module.exports = async function requireJson(req, res, next) {
if (req.headers['content-type'] !== 'application/json') { if (req.headers['content-type'] !== 'application/json') {

View File

@ -1,5 +1,5 @@
/* global process */ /* global process */
const log = require('../utils/log.utils'); // Log Helper const log = require('../utils/logs.utils'); // Log Helper
const dbUser = process.env.OWL_DB_USER || 'owl'; const dbUser = process.env.OWL_DB_USER || 'owl';
const dbPass = process.env.OWL_DB_PASS || 'twittwoo'; const dbPass = process.env.OWL_DB_PASS || 'twittwoo';

View File

@ -1,6 +1,6 @@
// Parse and return a find request // Parse and return a find request
const log = require('../utils/log.utils'); // Log Helper const log = require('../utils/logs.utils'); // Log Helper
const db = require('../services/dbAccess.services'); const db = require('../services/dbAccess.services');
const san = require('../utils/sanitizer.utils'); const san = require('../utils/sanitizer.utils');

View File

@ -1,6 +1,6 @@
/* eslint-disable no-useless-escape */ /* eslint-disable no-useless-escape */
const axios = require('axios'); const axios = require('axios');
const log = require('../utils/log.utils'); const log = require('../utils/logs.utils');
const issueLabels = { const issueLabels = {
bug: 120, bug: 120,

View File

@ -1,5 +1,5 @@
const testing = require('../services/mail.services'); const testing = require('../services/mail.services');
const log = require('../utils/log.utils'); const log = require('../utils/logs.utils');
async function getAlive(){ async function getAlive(){
log.out('kubeServices.getAlive: alive hook checked', 'info'); log.out('kubeServices.getAlive: alive hook checked', 'info');

View File

@ -1,6 +1,6 @@
// Parse and return an LDB Request // Parse and return an LDB Request
const log = require('../utils/log.utils'); // Log Helper const log = require('../utils/logs.utils'); // Log Helper
const ldb = require('ldbs-json'); const ldb = require('ldbs-json');
const util = require('../utils/ldb.utils'); const util = require('../utils/ldb.utils');
const san = require('../utils/sanitizer.utils'); const san = require('../utils/sanitizer.utils');

View File

@ -1,4 +1,4 @@
const log = require('../utils/log.utils'); // Log Helper const log = require('../utils/logs.utils'); // Log Helper
const db = require('../services/dbAccess.services'); const db = require('../services/dbAccess.services');
async function getStations(){ async function getStations(){

View File

@ -1,4 +1,4 @@
const log = require('../utils/log.utils'); const log = require('../utils/logs.utils');
const mail = require('nodemailer'); //>> Probs wrong const mail = require('nodemailer'); //>> Probs wrong
const fromAddr = process.env.OWL_EML_FROM; const fromAddr = process.env.OWL_EML_FROM;

View File

@ -1,7 +1,7 @@
// Finds PIS Codes using DB Lookups // Finds PIS Codes using DB Lookups
const db = require('../services/dbAccess.services'); const db = require('../services/dbAccess.services');
const log = require('../utils/log.utils'); const log = require('../utils/logs.utils');
const clean = require('../utils/sanitizer.utils'); const clean = require('../utils/sanitizer.utils');
const supported = [ const supported = [

View File

@ -1,4 +1,4 @@
const log = require('../utils/log.utils'); const log = require('../utils/logs.utils');
const auth = require('../utils/auth.utils'); const auth = require('../utils/auth.utils');
const db = require('./dbAccess.services'); const db = require('./dbAccess.services');
const mail = require('./mail.services'); const mail = require('./mail.services');

View File

@ -1,4 +1,4 @@
const log = require('../utils/log.utils'); // Log Helper const log = require('../utils/logs.utils'); // Log Helper
const db = require('../services/dbAccess.services'); const db = require('../services/dbAccess.services');
const os = require('os'); const os = require('os');
const vers = require('../configs/version.configs'); const vers = require('../configs/version.configs');

View File

@ -1,4 +1,4 @@
const log = require('../utils/log.utils'); const log = require('../utils/logs.utils');
const db = require('./dbAccess.services'); const db = require('./dbAccess.services');
const clean = require('../utils/sanitizer.utils'); const clean = require('../utils/sanitizer.utils');
const pis = require('../services/pis.services'); const pis = require('../services/pis.services');

View File

@ -1,5 +1,5 @@
const logs = require('../utils/logs.utils'); const logs = require('../utils/logs.utils');
const crypt = require('crypt'); const crypt = require('crypto');
const db = require('../services/dbAccess.services'); const db = require('../services/dbAccess.services');
const fs = require('fs/promises'); const fs = require('fs/promises');
const minify = require('../utils/minify.utils'); const minify = require('../utils/minify.utils');

View File

@ -1,4 +1,4 @@
const log = require('../utils/log.utils'); // Log Helper const log = require('./logs.utils'); // Log Helper
const db = require('../services/dbAccess.services'); // DB Access const db = require('../services/dbAccess.services'); // DB Access
//const san = require('../utils/sanitizer.utils'); // Sanitiser //const san = require('../utils/sanitizer.utils'); // Sanitiser