Skip to content

Commit 10c8dba

Browse files
committed
Add Dockerfile for easy Docker deployment
1 parent 56c5995 commit 10c8dba

4 files changed

Lines changed: 45 additions & 2 deletions

File tree

.dockerignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/.gitignore
2+
/.dockerignore
3+
/Dockerfile
4+
/RDMMonitorConfig.example.json
5+
/README.md
6+
/ecosystem.config.js
7+
8+
.git/
9+
static/

Dockerfile

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
### Build layer: Node.js 18 ###
2+
FROM node:18-alpine AS build-layer
3+
WORKDIR /app
4+
5+
# Install Vercel's pkg build tool
6+
RUN npm install -g pkg
7+
8+
# Install dependencies
9+
COPY package.json package-lock.json ./
10+
RUN npm install
11+
12+
# Build the self-contained application
13+
COPY RDMMonitor.js ./
14+
RUN pkg -t node18-alpine RDMMonitor.js
15+
16+
### Container ###
17+
FROM alpine
18+
WORKDIR /app
19+
ENV NODE_ENV=production
20+
21+
COPY --from=build-layer /app/RDMMonitor /app/RDMMonitor
22+
ENTRYPOINT ["/app/RDMMonitor"]

RDMMonitor.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const path = require('path');
1010
const args = process.argv.splice(2);
1111
const configPath = args.length > 0
1212
? path.resolve(__dirname, args[0])
13-
: './RDMMonitorConfig.json';
13+
: path.join(process.cwd(), 'RDMMonitorConfig.json');
1414
const config = require(configPath);
1515
const warningImage = "https://raw.githubusercontent.com/Kneckter/RDMMonitor/master/static/warned.png";
1616
const okImage = "https://raw.githubusercontent.com/Kneckter/RDMMonitor/master/static/ok.png";

README.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ RDMDeviceMonitor is a simple discord bot to monitor device status for RDM.
1818

1919
5. Copy the example file `cp RDMMonitorConfig.example.json RDMMonitorConfig.json`.
2020

21-
6. Create an applicaiton and get the your bot's secret token, and application ID at:
21+
6. Create an application and get the your bot's secret token, and application ID at:
2222
* https://discordapp.com/developers/applications/me
2323

2424
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.
3131

3232
<hr />
3333

34+
# SETTING UP THE BOT USING DOCKER:
35+
36+
1. Run `git clone https://github.com/Kneckter/RDMMonitor` to copy the bot.
37+
38+
2. Change into the new folder `cd RDMMonitor/`.
39+
40+
3. Build the container `docker build -t rdm-monitor .`
41+
42+
4. Create the application and the configuration file according to step 6-8 from the previous section.
43+
44+
5. Start the Docker container: `docker run -v ./RDMMonitorConfig.json:/app/RDMMonitorConfig.json rdm-monitor`
45+
3446
# SETTINGS
3547
```
3648
token: Mandator, discord bot token, bot should have send message and manage message permissions in the designated channel

0 commit comments

Comments
 (0)