added Dockerfile
This commit is contained in:
parent
ea55fda9e5
commit
0d4e6c6f80
5 changed files with 21 additions and 7 deletions
2
.dockerignore
Normal file
2
.dockerignore
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
node_modules/
|
||||||
|
data/
|
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -2,6 +2,4 @@
|
||||||
*.iml
|
*.iml
|
||||||
|
|
||||||
node_modules/
|
node_modules/
|
||||||
|
data/
|
||||||
cache.json
|
|
||||||
config.json
|
|
14
Dockerfile
Normal file
14
Dockerfile
Normal 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
|
6
index.js
6
index.js
|
@ -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);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -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",
|
||||||
|
|
Reference in a new issue