added Dockerfile

This commit is contained in:
Samuel Philipp 2020-02-27 19:04:38 +01:00
parent ea55fda9e5
commit 0d4e6c6f80
5 changed files with 21 additions and 7 deletions

2
.dockerignore Normal file
View file

@ -0,0 +1,2 @@
node_modules/
data/

4
.gitignore vendored
View file

@ -2,6 +2,4 @@
*.iml *.iml
node_modules/ node_modules/
data/
cache.json
config.json

14
Dockerfile Normal file
View file

@ -0,0 +1,14 @@
FROM node:alpine
MAINTAINER mail@sp-codes.de
WORKDIR monitor
COPY index.js package.json ./
RUN mkdir -p /monitor/data \
&& apk --no-cache add nmap git \
&& npm install \
&& apk del git
CMD npm run start

View file

@ -1,14 +1,14 @@
const config = require('./config'); const config = require('./data/config');
const fs = require('fs'); const fs = require('fs');
const cron = require('node-cron'); const cron = require('node-cron');
const fetch = require('node-fetch'); const fetch = require('node-fetch');
const abort = require('abort-controller'); const abort = require('abort-controller');
const nmap = require('libnmap'); const nmap = require('libnmap');
const cache = fs.existsSync("cache.json") ? JSON.parse(fs.readFileSync("cache.json", {encoding: "utf8"})) : {}; const cache = fs.existsSync("data/cache.json") ? JSON.parse(fs.readFileSync("data/cache.json", {encoding: "utf8"})) : {};
process.on('SIGINT', () => { process.on('SIGINT', () => {
fs.writeFileSync("cache.json", JSON.stringify(cache), {encoding: "utf8"}); fs.writeFileSync("data/cache.json", JSON.stringify(cache), {encoding: "utf8"});
process.exit(0); process.exit(0);
}); });

View file

@ -5,7 +5,7 @@
"scripts": { "scripts": {
"start": "node index.js" "start": "node index.js"
}, },
"author": "codes@samuel-philipp.de", "author": "mail@sp-codes.de",
"dependencies": { "dependencies": {
"abort-controller": "^3.0.0", "abort-controller": "^3.0.0",
"libnmap": "^0.4.19", "libnmap": "^0.4.19",