Run initial docker build in parallel

This commit is contained in:
1computer1 2019-03-12 23:21:05 -04:00
parent 0fa062875b
commit 0d29b8f403
2 changed files with 8 additions and 5 deletions

View file

@ -31,7 +31,7 @@ class CompilerClient extends AkairoClient {
this.config = config; this.config = config;
} }
start() { async start() {
this.commandHandler.useListenerHandler(this.listenerHandler); this.commandHandler.useListenerHandler(this.listenerHandler);
this.listenerHandler.setEmitters({ this.listenerHandler.setEmitters({
commandHandler: this.commandHandler, commandHandler: this.commandHandler,
@ -42,7 +42,7 @@ class CompilerClient extends AkairoClient {
this.commandHandler.loadAll(); this.commandHandler.loadAll();
this.listenerHandler.loadAll(); this.listenerHandler.loadAll();
this.languageHandler.loadAll(); this.languageHandler.loadAll();
this.languageHandler.buildDocker(); await this.languageHandler.buildDocker();
return this.login(this.config.token); return this.login(this.config.token);
} }
} }

View file

@ -2,6 +2,8 @@ const { AkairoHandler } = require('discord-akairo');
const { Collection } = require('discord.js'); const { Collection } = require('discord.js');
const Language = require('./Language'); const Language = require('./Language');
const childProcess = require('child_process'); const childProcess = require('child_process');
const util = require('util');
const path = require('path');
class LanguageHandler extends AkairoHandler { class LanguageHandler extends AkairoHandler {
constructor(client, { constructor(client, {
@ -48,9 +50,10 @@ class LanguageHandler extends AkairoHandler {
} }
buildDocker() { buildDocker() {
for (const [, { id }] of this.modules) { return Promise.all(this.modules.map(({ id }) => {
childProcess.execSync(`docker build -t "1computer1/comp_iler:${id}" ./docker/${id}`); const folder = path.join(__dirname, '../../docker', id);
} return util.promisify(childProcess.exec)(`docker build -t "1computer1/comp_iler:${id}" ${folder}`);
}));
} }
evalCode(message, { language, code, options }) { evalCode(message, { language, code, options }) {