rogueserver/README.md

67 lines
2.9 KiB
Markdown
Raw Normal View History

2024-05-09 00:51:44 -07:00
# rogueserver
Backend Golang server & API for [PokéRogue](https://github.com/pagefaultgames/pokerogue).
2024-05-09 00:51:44 -07:00
# Building
There are 2 main methods to host a local instance of the server: via Docker and as a local install.
## Docker
### Requirements:
- Docker Desktop (downloadable [from their website](https://www.docker.com/products/docker-desktop/)).
Use the [sample docker-compose file](./docker-compose.Development.yml) to set up a docker container to run the server.
On initialization, this will create an empty `mariadb` database with the default username/password combo of pokerogue:pokerogue.
2024-05-09 00:51:44 -07:00
# Self Hosting outside of Docker:
## Required Tools:
- Golang 1.22 or higher (downloadable [here](https://go.dev/dl/))
- Node: **18.3.0** or higher
2024-05-09 00:51:44 -07:00
- npm: [how to install](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm)
- Both this repository and the [main repo](https://github.com/pagefaultgames/pokerogue) cloned on your device
2024-05-09 00:51:44 -07:00
## Building
Running the server requires only the `rogueserver` executable (compiled from this repo).
Run the following code from the repository root to create and run it[^1]:
```bash
2024-05-09 01:44:04 -07:00
go build .
./rogueserver --debug --dbuser yourusername --dbpass yourpassword
2024-05-09 00:51:44 -07:00
```
(If on windows, replace `rogueserver` with `rogueserver.exe`.)
2024-05-09 00:51:44 -07:00
Now, go to the main repo root and run `npm run start` to boot it up. With some luck, the frontend should connect to the local backend and run smoothly!
2024-05-09 00:51:44 -07:00
[^1]: After doing this, you shouldn't have to re-build it again unless making changes to backend code.
2024-05-09 01:44:04 -07:00
### Hosting for other computers
Now, if you want to access your local server from _other_ machines using localhost, you will need to configure your device's firewalls to allow inbound connections for the ports running the API and server (8000 & 8001).
An example to allow incoming connections using UFW on Linux:
```bash
2024-05-09 00:51:44 -07:00
sudo ufw allow 8000,8001/tcp
```
This should allow you to reach the game from other computers on the same network.
2024-05-09 00:51:44 -07:00
## Tying to a Domain
If you want to tie the local instance to a _domain_ and make it publicly accessible, there are a few extra steps to be done.
2024-05-09 00:51:44 -07:00
**This is FULLY OPTIONAL.** The first 2 steps should be enough for most users merely wanting to test stuff out.
[Caddy](https://caddyserver.com/docs/install) is recommended for use as a reverse proxy.
After installing it, set up a config file like so:
2024-05-09 00:51:44 -07:00
```
pokerogue.exampledomain.com {
reverse_proxy localhost:8000
}
pokeapi.exampledomain.com {
reverse_proxy localhost:8001
}
2024-05-09 00:51:44 -07:00
```
(Replace the URLs with whatever domain name you want to tie the server to.)
Then, set up caddy as a service [as shown here](https://caddyserver.com/docs/running).
2024-05-09 00:51:44 -07:00
Once this is good to go, take your API url (https://pokeapi.exampledomain.com) and paste it into **.env.development** inside the main repo, replacing the prior `0.0.0.0:8001` address.
2024-05-09 00:51:44 -07:00
Make sure that ports 8000 and 8001 are both portforwarded on your router.
2024-05-09 00:51:44 -07:00
Enjoy!