Add Deploying Silvanus Yourself
parent
6a2571769a
commit
17b4261a5f
90
Deploying-Silvanus-Yourself.md
Normal file
90
Deploying-Silvanus-Yourself.md
Normal file
@ -0,0 +1,90 @@
|
||||
# Deploying Silvanus Yourself
|
||||
|
||||
This guide is a work in progress but a rough overview is below. Silvanus can be run on baremetal or within a Docker container. I use a Docker container for production and run on baremetal for development. Silvanus is written in JavaScript with the Node.js runtime and Discord.js library. Currently Silvanus uses D.js v14. Silvanus requires the use of a MySQL database - specifically MariaDB, however I don't think there are any features used that would prevent the use of a vanilla MySQL server.
|
||||
|
||||
Check out [Silvanus' GitHub repository here](https://github.com/voidf1sh/silvanus)!
|
||||
|
||||
## Database Structure
|
||||
|
||||
Here is the `CREATE TABLE` structure for the two tables required by Silvanus
|
||||
|
||||
### `guild_info`
|
||||
|
||||
```plaintext
|
||||
CREATE TABLE `guild_info` (
|
||||
`guild_id` varchar(50) NOT NULL,
|
||||
`tree_name` varchar(100) NOT NULL DEFAULT 'Unknown',
|
||||
`tree_height` float NOT NULL DEFAULT 0,
|
||||
`tree_message_id` varchar(50) NOT NULL DEFAULT 'Unknown',
|
||||
`tree_channel_id` varchar(50) NOT NULL DEFAULT 'Unknown',
|
||||
`leaderboard_message_id` varchar(50) NOT NULL DEFAULT 'Unknown',
|
||||
`leaderboard_channel_id` varchar(50) NOT NULL DEFAULT 'Unknown',
|
||||
`water_message` varchar(1500) DEFAULT '',
|
||||
`water_role_id` varchar(50) DEFAULT NULL,
|
||||
`fruit_message` varchar(1500) DEFAULT NULL,
|
||||
`fruit_role_id` varchar(50) DEFAULT NULL,
|
||||
`reminder_channel_id` varchar(50) DEFAULT '',
|
||||
`watch_channel_id` varchar(50) DEFAULT '',
|
||||
`notifications_enabled` varchar(5) DEFAULT 'false',
|
||||
`compare_channel_id` varchar(50) DEFAULT '',
|
||||
`compare_message_id` varchar(50) DEFAULT '',
|
||||
PRIMARY KEY (`guild_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
```
|
||||
|
||||
### `leaderboard`
|
||||
|
||||
```plaintext
|
||||
CREATE TABLE `leaderboard` (
|
||||
`id` int(10) NOT NULL AUTO_INCREMENT,
|
||||
`guild_id` varchar(50) NOT NULL,
|
||||
`tree_name` varchar(100) NOT NULL,
|
||||
`tree_rank` int(10) NOT NULL,
|
||||
`tree_height` float NOT NULL DEFAULT 1,
|
||||
`has_pin` tinyint(1) NOT NULL DEFAULT 0,
|
||||
`timestamp` datetime DEFAULT current_timestamp(),
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
```
|
||||
|
||||
## Baremetal
|
||||
|
||||
Running Silvanus on bare metal is preferred for testing development versions, but you can run the production version on bare metal too if desired.
|
||||
|
||||
### Secrets
|
||||
|
||||
To avoid leaking secrets in the code and images, Silvanus uses environment variables and the `dotenv` module to handle secrets like bot tokens and keys. When running on bare metal, simply create a file named `.env` in the root of the project directory with the following structure:
|
||||
|
||||
```plaintext
|
||||
TOKEN=
|
||||
BOTID=
|
||||
DEBUG=false
|
||||
DBHOST=
|
||||
DBPORT=
|
||||
DBUSER=
|
||||
DBPASS=
|
||||
DBNAME=
|
||||
STATUSCHANNELID=
|
||||
ownerId=
|
||||
```
|
||||
|
||||
Alternatively you can pass these variables from the command line if you're a masochist.
|
||||
|
||||
### Running the Bot
|
||||
|
||||
```plaintext
|
||||
$ git clone https://github.com/voidf1sh/silvanus
|
||||
$ cd silvanus
|
||||
$ npm i
|
||||
$ node main.js
|
||||
$ ???
|
||||
$ profit
|
||||
```
|
||||
|
||||
## Docker
|
||||
|
||||
Running Silvanus in a Docker container is preferred when deployed to production use. This will allow for easy restarts if and when the bot crashes due to my lazy code. `--restart unless-stopped` is your friend here.
|
||||
|
||||
### Secrets
|
||||
|
||||
You'll have to figure this one out, it's the same variable structure as above, but I've never had to pass variables to Docker manually as I use unRAID to host my bots. Alternatively if you're not going to be publishing the docker image, you can use a `.env` file and remove `.env` from the `.dockerignore` file, this will include the variables in the image and Silvanus will load them from the `.env` file. If you also use unRAID send me a DM on Discord and I'll send the template I've built for Silvanus.
|
Loading…
Reference in New Issue
Block a user