The site has been dockerised

This commit is contained in:
Martin Donnelly 2022-10-17 17:26:51 +01:00
parent b614f0daf0
commit 0cb1404d32
10 changed files with 10429 additions and 28 deletions

26
Docker/Dockerfile Normal file
View File

@ -0,0 +1,26 @@
# FROM node:current-slim
FROM martind2000/node-python3:16-slim
ARG VERSION
ENV VERSION ${VERSION:-development}
WORKDIR /app
COPY ./Docker/start.sh ./package*.json ./web-server.js /app/
COPY ./dist /app/dist
COPY ./views /app/views
COPY ./lib /app/lib
COPY ./config /app/config
RUN pnpm install
# RUN ls -lh .
EXPOSE 9000
RUN chmod +x /app/start.sh
ENTRYPOINT ["/app/start.sh"]

View File

@ -0,0 +1,12 @@
[
{
"name": "Slack",
"script": "app/predict.js",
"env": {
"NODE_ENV": "production"
},
"autorestart": false,
"instances": 1,
"cron_restart": "10 15 * * 2,5"
}
]

4
Docker/start.sh Executable file
View File

@ -0,0 +1,4 @@
#!/bin/sh
set -ex
node web-server.js

14
docker-compose.yml Normal file
View File

@ -0,0 +1,14 @@
version: '3.5'
services:
silvrtree:
container_name: silvrtree
build:
context: .
dockerfile: ./Docker/Dockerfile
image: silvrtree_docker
restart: always
ports:
- "9000:9000"
# volumes:
# - ./dist:/app/dist

View File

@ -1,6 +1,6 @@
const http = require('http'); const http = require('http');
const https = require('https'); const https = require('https');
const LimitedArray = require('limitedarray'); const LimitedArray = require('@rakh/limitedarray');
const trend = require('trend'); const trend = require('trend');
const logger = require('log4js').getLogger('btc'); const logger = require('log4js').getLogger('btc');
let btcCache = {}; let btcCache = {};
@ -62,8 +62,8 @@ function getBitcoin () {
history.push(a.bpi.USD.rate_float); history.push(a.bpi.USD.rate_float);
btcCache.history = history.get(); btcCache.history = history.get();
btcCache.trend = trend(btcCache.history, { 'avgPoints': 12 }); btcCache.trend = trend(btcCache.history, { 'avgPoints': 12 });
GLOBAL.lastcheck = new Date(); global.lastcheck = new Date();
btcCache.lastcheck = GLOBAL.lastcheck.toISOString(); btcCache.lastcheck = global.lastcheck.toISOString();
eventEmitter.emit('sendSocket', { 'id': 'btc', 'data': btcCache }); eventEmitter.emit('sendSocket', { 'id': 'btc', 'data': btcCache });
}); });
} }

View File

@ -1,5 +1,5 @@
const http = require('http'); const http = require('http');
const LimitedArray = require('limitedarray'); const LimitedArray = require('@rakh/limitedarray');
const trend = require('trend'); const trend = require('trend');
const logger = require('log4js').getLogger('fx'); const logger = require('log4js').getLogger('fx');
const delay = 5529600; // 32 days divided by 500 const delay = 5529600; // 32 days divided by 500

View File

@ -21,21 +21,6 @@
"eslint-watch": "^3.0.1", "eslint-watch": "^3.0.1",
"fitbit-oauth2": "0.0.1", "fitbit-oauth2": "0.0.1",
"forecast.io": "0.0.11", "forecast.io": "0.0.11",
"gulp-autoprefixer": "^4.0.0",
"gulp-babel": "^7.0.0",
"gulp-cache": "^0.4.6",
"gulp-concat": "^2.6.1",
"gulp-cssnano": "^2.1.2",
"gulp-google-webfonts": "0.0.14",
"gulp-html-replace": "^1.6.2",
"gulp-htmlmin": "^3.0.0",
"gulp-jshint": "^2.0.4",
"gulp-rename": "^1.2.2",
"gulp-sass": "^3.1.0",
"gulp-scss": "^1.4.0",
"gulp-sourcemaps": "^2.6.1",
"gulp-strip-debug": "^1.1.0",
"gulp-uglify": "^3.0.0",
"htmlparser": "^1.7.7", "htmlparser": "^1.7.7",
"jade": "^1.11.0", "jade": "^1.11.0",
"jest": "^21.2.1", "jest": "^21.2.1",
@ -74,9 +59,8 @@
"express": "^4.15.5", "express": "^4.15.5",
"express-session": "^1.15.6", "express-session": "^1.15.6",
"ftse": "^1.0.6", "ftse": "^1.0.6",
"gulp": "^3.9.1",
"ical2json": "^1.2.0", "ical2json": "^1.2.0",
"limitedarray": "git+https://gitlab.silvrtree.co.uk/martind2000/limitedArray.git", "@rakh/limitedarray": "^0.1.0",
"logger": "0.0.1", "logger": "0.0.1",
"method-override": "^2.3.10", "method-override": "^2.3.10",
"morgan": "^1.9.0", "morgan": "^1.9.0",
@ -94,12 +78,9 @@
"scripts": { "scripts": {
"start": "node web-server.js", "start": "node web-server.js",
"copy": "sudo cp -r ./. /var/www/silvrtree", "copy": "sudo cp -r ./. /var/www/silvrtree",
"postinstall": "browserify -g uglifyify app/appV2.js -o app/bundle.js" "nopostinstall": "browserify -g uglifyify app/appV2.js -o app/bundle.js"
}, },
"jest": { "jest": {
"verbose": true "verbose": true
},
"engines": {
"node": "= 8.8.0"
} }
} }

10364
pnpm-lock.yaml Normal file

File diff suppressed because it is too large Load Diff

View File

@ -43,7 +43,7 @@ const polys = require('./lib/poly.js');
const logger = require('log4js').getLogger(); const logger = require('log4js').getLogger();
const app = express(); const app = express();
GLOBAL.lastcheck = 0; global.lastcheck = 0;
let btcCache = {}, fxCache = {}, trainCache = {}; let btcCache = {}, fxCache = {}, trainCache = {};
const port = process.env.PORT || 9010; const port = process.env.PORT || 9010;

View File

@ -51,8 +51,8 @@ const logger = require('log4js').getLogger('web-server');
logger.level = 'debug'; logger.level = 'debug';
const app = express(); const app = express();
GLOBAL.lastcheck = 0; global.lastcheck = 0;
GLOBAL.fxLastCheck = 0; global.fxLastCheck = 0;
let btcCache = {}, fxCache = {}, trainCache = {}; let btcCache = {}, fxCache = {}, trainCache = {};
const port = process.env.PORT || 9000; const port = process.env.PORT || 9000;