Skip to content

Generate config files #78

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Nov 20, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@ node_modules
*.log
*.lock
*.config.js
db/config/config.json
package-lock.json
*.bk
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ COPY package.json .
RUN npm install

# Global Installs
RUN npm install -g pm2 sequelize-cli
RUN npm install -g pm2 sequelize-cli gulp-cli

COPY . .
2 changes: 1 addition & 1 deletion bot/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const client = new Discord.Client();
const ctrls = require('./controllers')();

client.on('ready', () => {
util.log('Bot Online and Ready!', {}, 0);
util.log('Bot Online and Ready!', 0);
});

client.on('message', (message) => {
Expand Down
1 change: 1 addition & 0 deletions bot/controllers/roles.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ module.exports = () => {
resType: 'dm',
action: (message) => {
const roles = [];
util.log('help!', message);
message.guild.roles.map((role) => {
if (!disallowedRoles.includes(role.name.toLowerCase())) {
return roles.push(role.name);
Expand Down
23 changes: 0 additions & 23 deletions db/config/config.json

This file was deleted.

4 changes: 4 additions & 0 deletions db/first_run.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#!/bin/bash

echo "Generating Sequelize config from .env file"
gulp db
echo "Generating PM2 config from .env file"
gulp pm2
echo "Migrating"
sequelize db:migrate --config db/config/config.json --migrations-path db/migrations/
echo "Seeding"
Expand Down
12 changes: 6 additions & 6 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,21 @@ services:
- /usr/src/app/node_modules
restart: always
ports:
- "8080:3000"
- "$BOT_PORT_HOST:$BOT_PORT_GUEST"
command: ["./wait-for-it.sh", "mysql:3306", "--", "db/first_run.sh"]

mysql:
container_name: mariadb
restart: always
image: mariadb:latest
environment:
MYSQL_ROOT_PASSWORD: 'down_and_dirty_deeds'
MYSQL_USER: 'max_attack'
MYSQL_PASS: 'headroom_dead_batteries'
MYSQL_DATABASE: 'max'
MYSQL_ROOT_PASSWORD: $MYSQL_ROOT_PASSWORD
MYSQL_USER: $MYSQL_USER
MYSQL_PASS: $MYSQL_PASS
MYSQL_DATABASE: $MYSQL_DATABASE
volumes:
- my-datavolume:/var/lib/mysql
ports:
- "3306:3306"
- "$DB_PORT_HOST:$DB_PORT_GUEST"
volumes:
my-datavolume:
32 changes: 32 additions & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
const gulp = require('gulp');
const fs = require('fs');

gulp.task('db', () => {
require('dotenv').config();
const config = {
development: {
username: 'root',
password: process.env.MYSQL_ROOT_PASSWORD,
database: process.env.MYSQL_DATABASE,
host: process.env.MYSQL_HOST,
dialect: 'mysql',
},
};
fs.writeFileSync('./db/config/config.json', JSON.stringify(config));
});

gulp.task('pm2', () => {
require('dotenv').config();
const config = {
apps: [{
name: 'max',
script: './bot/client.js',
env: {
TOKEN: process.env.DISCORD_BOT_TOKEN,
DEBUG_MODE: '3',
NODE_ENV: process.env.NODE_ENV,
},
}],
};
fs.writeFileSync('./max.config.js', 'module.exports = ' + JSON.stringify(config));
});
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"eslint-plugin-import": "^2.7.0",
"eslint-plugin-jsx-a11y": "^5.1.1",
"eslint-plugin-react": "^7.1.0",
"gulp": "^3.9.1",
"mocha": "^3.5.0",
"mocha-eslint": "^4.1.0",
"nodemailer": "^4.3.1",
Expand Down
38 changes: 20 additions & 18 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,30 @@ git clone git@github.com:reactivepixel/Max-Bot.git

### ENV Vars

Create an ```max.config.js``` file with all the environment specific and sensitive information.

```javascript
module.exports = () => {
apps: [
{
name: 'max',
script: './bot/client.js',
env: {
TOKEN: DiscordBotToken,
DEBUG_MODE: '3',
NODE_ENV: 'development',
EMAIL_USERNAME: 'example@gmail.com',
EMAIL_PASS: 'password',
},
},
],
};

Create an ```.env``` file with the following sensitive information. Replace the "xxx"'s with some unique information for your local Environment.

```
MYSQL_ROOT_PASSWORD=xxx
MYSQL_USER=xxx
MYSQL_PASS=xxx
MYSQL_DATABASE=max
DISCORD_BOT_TOKEN=xxx_bot_token_from_next_step_xxx
NODE_ENV=development
DB_PORT_HOST=3306
DB_PORT_GUEST=3306
BOT_PORT_HOST=80
BOT_PORT_GUEST=3000
BOT_PORT_HOST=80
BOT_PORT_GUEST=3000

```

> Update ```DiscordBotToken``` with the token you receive from the next step.




### Bot Token

Obtain a [Discord App Bot Token](https://discordapp.com/developers/applications/me) from your registered app (or register a new one) to proceed or contact a Release Manager for Max's Dev Bot token.
Expand Down