Added Docker support.

This commit is contained in:
chris062689 2017-09-24 15:44:49 -04:00
parent 6aa081ba8a
commit 0e7d7aad46
3 changed files with 25 additions and 11 deletions

2
.dockerignore Normal file
View file

@ -0,0 +1,2 @@
node_modules
npm-debug.log

13
Dockerfile Normal file
View file

@ -0,0 +1,13 @@
FROM mhart/alpine-node:latest
# Create app directory
WORKDIR /usr/src/app
# Install app dependencies
COPY package.json package-lock.json ./
RUN npm install --production
# Bundle app source
COPY . .
ENTRYPOINT [ "npm", "run", "start-prod" ]

View file

@ -12,16 +12,20 @@ var cachedModules = [];
var cachedTriggers = []; var cachedTriggers = [];
var client = new discord.Client(); var client = new discord.Client();
process.on('unhandledRejection', function onError(err) {
logger.error(err);
});
// Verify configuration options are set properly.
if (!config.logChannel) { throw 'Log Channel is missing from the configuration file.'; }
if (!config.clientLoginToken) { throw 'Client Login Token is missing from the configuration file.'; }
function findArray(haystack, arr) { function findArray(haystack, arr) {
return arr.some(function (v) { return arr.some(function (v) {
return haystack.indexOf(v) >= 0; return haystack.indexOf(v) >= 0;
}); });
}; };
process.on('unhandledRejection', function onError(err) {
throw err;
});
client.on('ready', () => { client.on('ready', () => {
// Initalize app channels. // Initalize app channels.
app.logChannel = client.channels.get(config.logChannel); app.logChannel = client.channels.get(config.logChannel);
@ -153,10 +157,5 @@ require("fs").readdirSync('./triggers/').forEach(function(file) {
data.readWarnings(); data.readWarnings();
data.readBans(); data.readBans();
if (config.clientLoginToken) { client.login(config.clientLoginToken);
client.login(config.clientLoginToken); logger.info('Startup completed. Established connection to Discord.');
logger.info('Startup completed. Established connection to Discord.');
} else {
logger.error('Cannot establish connection to Discord. Client login token is not defined.');
throw('MISSING_CLIENT_LOGIN_TOKEN');
}