diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..5563af0 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,3 @@ +node_modules/ +.env +data/ \ No newline at end of file diff --git a/.gitignore b/.gitignore index 7439756..5563af0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,3 @@ node_modules/ .env -data.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..2c110e0 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,10 @@ +FROM node:lts-alpine + +WORKDIR /app +COPY package*.json /app/ +RUN npm ci + +COPY ./ /app/ + +VOLUME [ "/app/data" ] +CMD ["node", "index.js"] \ No newline at end of file diff --git a/index.js b/index.js index 863f409..911cf28 100644 --- a/index.js +++ b/index.js @@ -1,10 +1,11 @@ import * as sdk from "matrix-js-sdk"; import fetch from "node-fetch"; +import process from "process"; import "dotenv/config"; import { JsonDB, Config } from "node-json-db"; import { TimetableClient } from "./timetable.js"; -const db = new JsonDB(new Config("data", true, true, "/")); +const db = new JsonDB(new Config("data/data", true, true, "/")); const timetable = new TimetableClient( process.env.TIMETABLE_ENDPOINT, process.env.TIMETABLE_TOKEN @@ -296,3 +297,8 @@ async function handleReaction(event, room) { } client.startClient(0); + +process.on("SIGINT", () => { + console.info("Interrupted"); + process.exit(0); +});