mirror of
				https://github.com/citra-emu/discord-bot.git
				synced 2025-11-04 09:14:59 +00:00 
			
		
		
		
	Added Docker support.
This commit is contained in:
		
							parent
							
								
									6aa081ba8a
								
							
						
					
					
						commit
						0e7d7aad46
					
				
							
								
								
									
										2
									
								
								.dockerignore
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								.dockerignore
									
									
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,2 @@
 | 
			
		|||
node_modules
 | 
			
		||||
npm-debug.log
 | 
			
		||||
							
								
								
									
										13
									
								
								Dockerfile
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								Dockerfile
									
									
									
									
									
										Normal 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" ]
 | 
			
		||||
							
								
								
									
										21
									
								
								server.js
									
									
									
									
									
								
							
							
						
						
									
										21
									
								
								server.js
									
									
									
									
									
								
							| 
						 | 
				
			
			@ -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.');
 | 
			
		||||
		Loading…
	
		Reference in a new issue