-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
doc: align deployment guides with code
- Loading branch information
Showing
2 changed files
with
92 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
### GFI-Bot Development Setup | ||
|
||
> **The dev setup is pretty alpha-stage, it's only tested on the production machine (Ubuntu 20.04) with one user.** | ||
#### Development Setup Explained | ||
|
||
`gfidev.sh` starts a MongoDB instance `gfidev_xxx_mongo`, a caddy webserver, and 2 screen sessions: | ||
|
||
**gfidev_xxx_vite** runs a vite dev server (with hmr, the dev frontend refreshes within 1 sec on code changes) | ||
|
||
**gfidev_xxx_backend** runs a FastAPI backend (automatically reloads on backend code changes; to avoid wasting rate limits, the background scheduler is disabled by default) | ||
|
||
#### Initial Setup | ||
|
||
##### Building the dataset | ||
|
||
The most effortless way to build the dev dataset is to copy it from the production server. (stop the production database before copying) | ||
|
||
```bash | ||
cp -r <path-to-gfi-data> <path-to-gfi-data-alt> | ||
``` | ||
|
||
Alternatively, you may build the dataset from scratch. (this will take a while) | ||
|
||
```bash | ||
GFIBOT_ENV=dev python3 -m gfibot.backend.scheduled_tasks --init | ||
``` | ||
|
||
##### Starting the dev setup | ||
|
||
First, rename `example.env` to `.env` and set deployment configurations: | ||
|
||
**Note each GFI-Bot instance needs unique ports and a unique GFIBOT_DATA_DIR to avoid conflicts.** | ||
|
||
```ini | ||
# MongoDB port (exposed to the host machine) | ||
GFIBOT_MONGO_PORT=127.0.0.1:27021 # <- check pyproject.toml | ||
# Backend port | ||
GFIBOT_BACKEND_PORT=127.0.0.1:8123 | ||
# Frontend https / http port | ||
GFIBOT_HTTPS_PORT=80 | ||
GFIBOT_HTTPS_PORT=443 | ||
GFIBOT_DATA_DIR=<path-to-gfi-data-alt> | ||
``` | ||
|
||
Then, run the dev setup: | ||
|
||
```bash | ||
cd development/ | ||
./gfidev.sh up | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,50 @@ | ||
### GFI-Bot Production Build | ||
|
||
> **Notice: Do not make the docker image public after building.** | ||
**Preliminary**, we're using docker-compose to build a production instance of GFI-Bot, which includes a Flask backend, a Mongo database, RecGFI and data retrieving modules. | ||
|
||
You should initially create a `production_secrets.json` file in this directory in order to register your GitHub APP id and secrets, as well as information of a g-mail account (if you want to send emails to users). The file should be laid out as below: | ||
|
||
```json | ||
{ | ||
"web_client": { | ||
"id": "$web_client_id", | ||
"secret": "$web_client_secret" | ||
}, | ||
"git_app": { | ||
"id": "$github_app_id", | ||
"secret": "$github_app_secret" | ||
}, | ||
"mail": { | ||
"email": "$gmail_address", | ||
"password": "$gmail_service_password" | ||
} | ||
} | ||
### GFI-Bot Development Setup | ||
|
||
> **The dev setup is pretty alpha-stage, it's only tested on the production machine (Ubuntu 20.04) with one user.** | ||
#### Development Setup Explained | ||
|
||
`gfidev.sh` starts a MongoDB instance `gfidev_xxx_mongo`, a caddy webserver (the CORS walkaround), and 2 screen sessions: | ||
|
||
**gfidev_xxx_vite** runs a vite dev server (with hmr, the dev frontend refreshes within 1 sec on code changes) | ||
|
||
**gfidev_xxx_backend** runs a FastAPI backend (automatically reloads on backend code changes; to avoid wasting rate limits, the background scheduler is disabled by default) | ||
|
||
#### Building the dataset | ||
|
||
The most effortless way to build the dev dataset is to copy it from the production server. (stop the production database before copying) | ||
|
||
```bash | ||
cp -r <path-to-gfi-data> <path-to-gfi-data-alt> | ||
``` | ||
|
||
Then, try executing | ||
Alternatively, you may build the dataset from scratch. (this will take a while) | ||
|
||
```bash | ||
cd production | ||
./gfibot.sh up | ||
GFIBOT_ENV=dev python3 -m gfibot.backend.scheduled_tasks --init | ||
``` | ||
|
||
to start your GFI-Bot service. | ||
#### Starting the dev setup | ||
|
||
The docker image been built doesn't consist a web server, so it's up to you to choose which kind of web server to use. Currently, we're using [caddy](https://caddyserver.com/) as our web server. A Caddy file as below would be capable for development environment: | ||
First, rename `example.env` to `.env` and set deployment configurations: | ||
|
||
**Note each GFI-Bot instance needs unique ports and a unique GFIBOT_DATA_DIR to avoid conflicts.** | ||
|
||
```ini | ||
# MongoDB port (exposed to the host machine) | ||
# NEVER expose the production database to internet | ||
GFIBOT_MONGO_PORT=127.0.0.1:27021 # <- check pyproject.toml | ||
# Backend port | ||
GFIBOT_BACKEND_PORT=127.0.0.1:8123 | ||
# Frontend https / http port | ||
GFIBOT_HTTP_PORT=80 | ||
GFIBOT_HTTPS_PORT=443 | ||
GFIBOT_DATA_DIR=<path-to-gfi-data-alt> | ||
``` | ||
|
||
Then, run the dev setup: | ||
|
||
```bash | ||
cd production/ | ||
./gfidev.sh up | ||
``` | ||
$your_web_domain { | ||
route { | ||
reverse_proxy /api/* $your_server_url { | ||
header_down +Access-Control-Allow-Origin "*" | ||
header_down +Access-Control-Allow-Methods "OPTIONS, DELETE, GET, HEAD, POST, PUT" | ||
} | ||
root * $frontend_builds_location | ||
try_files {path} /index.html | ||
file_server | ||
} | ||
} | ||
``` |