From 0d4e6c6f802b384a98b4d9a2db4612efc155fa69 Mon Sep 17 00:00:00 2001 From: samuel-p Date: Thu, 27 Feb 2020 19:04:38 +0100 Subject: [PATCH] added Dockerfile --- .dockerignore | 2 ++ .gitignore | 4 +--- Dockerfile | 14 ++++++++++++++ index.js | 6 +++--- package.json | 2 +- 5 files changed, 21 insertions(+), 7 deletions(-) create mode 100644 .dockerignore create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..ff227fe --- /dev/null +++ b/.dockerignore @@ -0,0 +1,2 @@ +node_modules/ +data/ \ No newline at end of file diff --git a/.gitignore b/.gitignore index 4983cf8..3e5dede 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,4 @@ *.iml node_modules/ - -cache.json -config.json \ No newline at end of file +data/ \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..136eb50 --- /dev/null +++ b/Dockerfile @@ -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 \ No newline at end of file diff --git a/index.js b/index.js index e59cb45..b828da0 100644 --- a/index.js +++ b/index.js @@ -1,14 +1,14 @@ -const config = require('./config'); +const config = require('./data/config'); const fs = require('fs'); const cron = require('node-cron'); const fetch = require('node-fetch'); const abort = require('abort-controller'); 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', () => { - fs.writeFileSync("cache.json", JSON.stringify(cache), {encoding: "utf8"}); + fs.writeFileSync("data/cache.json", JSON.stringify(cache), {encoding: "utf8"}); process.exit(0); }); diff --git a/package.json b/package.json index 5c268f0..a07f4e2 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "scripts": { "start": "node index.js" }, - "author": "codes@samuel-philipp.de", + "author": "mail@sp-codes.de", "dependencies": { "abort-controller": "^3.0.0", "libnmap": "^0.4.19",