bitque/docs/Deploy.md

128 lines
2.6 KiB
Markdown
Raw Normal View History

2021-10-08 23:42:15 +02:00
# Deploy with Nginx
You can deploy easily JIRS to any PC including Raspberry PI. To do this you will need compile it from source code.
We will use following setup, but you can modify it.
* `issues.example.com` - domain
2023-03-31 23:25:20 +02:00
* `postgres://postgres@192.168.1.144:5432/bitque` - database on other machine and within inner network
2021-10-08 23:42:15 +02:00
2023-03-31 23:25:20 +02:00
* `/var/bitque` - main directory
* `/var/bitque/clone` - cloned source code
* `/var/bitque/web` - All static assets including wasm library
* `/var/bitque/config` - config files
* `/var/bitque/uploads` - uploaded files
2021-10-08 23:42:15 +02:00
### JIRS Config files
* `config/db.toml` (REQUIRED)
```toml
concurrency = 2
2023-03-31 23:25:20 +02:00
database_url = "postgres://postgres@192.168.1.144:5432/bitque"
2021-10-08 23:42:15 +02:00
```
* `config/web.toml` (public_path is required)
```toml
concurrency = 2
port = "5000"
bind = "0.0.0.0"
ssl = false
tmp_dir = "/tmp"
public_path = "issues.example.com"
```
* `config/fs.toml` (must match nginx config)
```toml
store_path = "./uploads"
client_path = "/uploads"
tmp_path = "/tmp"
concurrency = 2
```
* `config/mail.toml` (REQUIRED)
```toml
concurrency = 2
user = "apikey"
pass = "SG.ARJL0wAxQk-LLJca9FJ5Lg.ahs7dyashd8a7shd7ahsd978h"
host = "smtp.sendgrid.net"
from = "admin@issues.example.com"
```
### NGINX config file
```nginx
server {
listen 80;
server_name issues.example.com;
2023-03-31 23:25:20 +02:00
root /var/bitque/web;
2021-10-08 23:42:15 +02:00
try_files $uri $uri/index.html index.html;
location ~ /uploads/ {
2023-03-31 23:25:20 +02:00
root /var/bitque;
2021-10-08 23:42:15 +02:00
}
location ~ .js {
add_header 'Content-Type' 'application/javascript';
add_header 'Access-Control-Allow-Origin' '*';
}
location ~ .css {
add_header 'Content-Type' 'text/css';
}
location ~ .wasm {
add_header 'Content-Type' 'application/wasm';
add_header 'Access-Control-Allow-Origin' '*';
}
location /ws/ {
proxy_pass http://localhost:5000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_set_header Host $host;
}
location /avatar {
proxy_pass http://localhost:5000;
}
location ~ / {
add_header 'Content-Type' 'text/html';
add_header 'Access-Control-Allow-Origin' '*';
2023-03-31 23:25:20 +02:00
root /var/bitque/web;
2021-10-08 23:42:15 +02:00
try_files $uri $uri/index.html /index.html;
}
}
```
### Compile application
```bash
cargo install --force wasm-pack
cargo install --force rsass
```
Ensure `$HOME/.cargo/bin` is in `$PATH`
* Compile server
```bash
2023-03-31 23:25:20 +02:00
cargo build --bin bitque --release --no-default-features --features local-storage
cp ./target/release/bitque /usr/bin/bitque
2021-10-08 23:42:15 +02:00
```
* Compile web client
```bash
./web/scripts/prod.sh
2023-03-31 23:25:20 +02:00
cp -r /tmp/wasm/* /var/bitque/web
2021-10-08 23:42:15 +02:00
```
If it fails (there is no wasm-opt for Raspberry PI) you must disable wasm-opt or compile it on any other PC and just
2023-03-31 23:25:20 +02:00
copy everything to `/var/bitque/web`
2021-10-08 23:42:15 +02:00