Refactor docker/k8s features and builds

This commit is contained in:
Fred Boniface 2023-01-09 23:26:28 +00:00
parent 150a43139f
commit 77c5ef2cf5
9 changed files with 71 additions and 6 deletions

View File

@ -4,5 +4,7 @@ npm-debug.log
.gitignore
Dockerfile
.dockerignore
nginx-proxy-docker
README.md
LICENSE
LICENSE
UpNext.md

View File

@ -1,7 +1,7 @@
FROM node:19
WORKDIR /usr/src/app
COPY ../package*.json ./
COPY ./package*.json ./
RUN npm ci --only=production
COPY .. .
COPY . .
EXPOSE 8460
CMD [ "node", "app.js" ]

View File

@ -1 +0,0 @@
FROM nginx:latest

View File

@ -0,0 +1,3 @@
FROM nginx:mainline-alpine-slim
RUN rm /etc/nginx/nginx.conf
COPY ./nginx.conf /etc/nginx/nginx.conf

View File

@ -0,0 +1,44 @@
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log notice;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
keepalive_timeout 65;
gzip on;
proxy_cache_path /var/cache/nginx keys_zone=owl_cache:20m inactive=24h;
server {
listen 80;
server_name localhost;
proxy_cache owl_cache;
location / {
proxy_pass http://localhost:8460;
proxy_cache_key $scheme://$host$uri$is_args$query_string;
proxy_ignore_headers Cache-Control;
proxy_cache_valid 200 1440m;
}
location /api/ {
proxy_pass http://localhost:8460;
proxy_cache_key $scheme://$host$uri$is_args$query_string;
proxy_ignore_headers Cache-Control;
proxy_cache_valid 200 1m;
}
}
}

View File

@ -18,7 +18,17 @@ async function getReady(req, res, next){
}
}
async function getTime(req, res, next){
try {
res.json(await kube.getTime(req.body))
} catch (err) {
console.error(`Unknown Error`, err.message);
next(err);
}
}
module.exports = {
getAlive,
getReady
getReady,
getTime
}

View File

@ -4,5 +4,6 @@ const kubeController = require('../controllers/kube.controllers');
router.get('/alive', kubeController.getAlive);
router.get('/ready', kubeController.getReady);
router.get('/time', kubeController.getTime);
module.exports = router

View File

@ -6,7 +6,13 @@ async function getReady(){
return "not_implemented";
};
async function getTime(){
var now = new Date()
return {responseGenerated: now}
}
module.exports = {
getAlive,
getReady
getReady,
getTime
}