brainlet/resources/Guides/HOSTING.md
hippoz 73a7a6acf6
🧶
2021-10-13 17:31:49 +03:00

58 lines
No EOL
1.8 KiB
Markdown

# Self-hosting
## Preface
So you wanna host Brainlet yourself, huh?
This guide assumes you're using Linux, though these instructions can easily be translated to Windows or Mac.
## MongoDB setup
Firstly, you're gonna need a MongoDB server, I just use Docker for the Mongo server, but you can *try* to not use Docker, though it can get tricky sometimes.
Let create a Docker container for Mongo!
```
docker run -it -v mongodata:/data/db -p 27017:27017 --name mongodb -d mongo
```
This should automatically run it, however, next time you need it you gotta run:
```
docker start mongodb
```
Stopping it is as simple as:
```
docker stop mongodb
```
Now that we have a Mongo server set up, let's actually begin to set up the Brainlet server.
## Server setup
You need nodejs and yarn installed in order to proceed! I recommend using node 14.x.
Once you have installed node, clone the repo and then cd into the brainlet folder.
Then, run the following command:
```
yarn i
```
This will install all of the node modules.
## Post-install
### The secret.js file (optional)
You may want to edit secret.js and have jwtPrivateKey set to a randomly generated key, such as with /dev/urandom. This will allow session cookies to persist after server reboot.
If you don't set one yourself, a private key will be randomly generated each time the server starts.
### The config.js file (important)
You need to edit the config.js file in order to allow your domain to CORS, and make various tweaks to how the server behaves. This will be better documented in the future.
## You should now be ready to go!
Just run Brainlet with the command below:
```
yarn start
```
Afterwards, try going to [http://localhost:3005/](http://localhost:3005/) to visit the site, assuming default port config.
Good luck!