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 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) {
return arr.some(function (v) {
return haystack.indexOf(v) >= 0;
});
};
process.on('unhandledRejection', function onError(err) {
throw err;
});
client.on('ready', () => {
// Initalize app channels.
app.logChannel = client.channels.get(config.logChannel);
@ -153,10 +157,5 @@ require("fs").readdirSync('./triggers/').forEach(function(file) {
data.readWarnings();
data.readBans();
if (config.clientLoginToken) {
client.login(config.clientLoginToken);
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');
}
client.login(config.clientLoginToken);
logger.info('Startup completed. Established connection to Discord.');