diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..0310213 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,9 @@ +/.gitignore +/.dockerignore +/Dockerfile +/RDMMonitorConfig.example.json +/README.md +/ecosystem.config.js + +.git/ +static/ \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..e34c76d --- /dev/null +++ b/Dockerfile @@ -0,0 +1,22 @@ +### Build layer: Node.js 18 ### +FROM node:18-alpine AS build-layer +WORKDIR /app + +# Install Vercel's pkg build tool +RUN npm install -g pkg + +# Install dependencies +COPY package.json package-lock.json ./ +RUN npm install + +# Build the self-contained application +COPY RDMMonitor.js ./ +RUN pkg -t node18-alpine RDMMonitor.js + +### Container ### +FROM alpine +WORKDIR /app +ENV NODE_ENV=production + +COPY --from=build-layer /app/RDMMonitor /app/RDMMonitor +ENTRYPOINT ["/app/RDMMonitor"] \ No newline at end of file diff --git a/RDMMonitor.js b/RDMMonitor.js index 7e02824..583a31b 100644 --- a/RDMMonitor.js +++ b/RDMMonitor.js @@ -10,7 +10,7 @@ const path = require('path'); const args = process.argv.splice(2); const configPath = args.length > 0 ? path.resolve(__dirname, args[0]) - : './RDMMonitorConfig.json'; + : path.join(process.cwd(), 'RDMMonitorConfig.json'); const config = require(configPath); const warningImage = "https://raw.githubusercontent.com/Kneckter/RDMMonitor/master/static/warned.png"; const okImage = "https://raw.githubusercontent.com/Kneckter/RDMMonitor/master/static/ok.png"; diff --git a/README.md b/README.md index b1cc0fd..521e0be 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ RDMDeviceMonitor is a simple discord bot to monitor device status for RDM. 5. Copy the example file `cp RDMMonitorConfig.example.json RDMMonitorConfig.json`. -6. Create an applicaiton and get the your bot's secret token, and application ID at: +6. Create an application and get the your bot's secret token, and application ID at: * https://discordapp.com/developers/applications/me 7. Get your application/bot to join your server by going here: @@ -31,6 +31,18 @@ RDMDeviceMonitor is a simple discord bot to monitor device status for RDM.