Browse Source

added Dockerfile

pull/3/head
Samuel Philipp 2 years ago
parent
commit
0d4e6c6f80
  1. 2
      .dockerignore
  2. 4
      .gitignore
  3. 14
      Dockerfile
  4. 6
      index.js
  5. 2
      package.json

2
.dockerignore

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

4
.gitignore

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

14
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

6
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);
});

2
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",

Loading…
Cancel
Save