parent
c7a592933e
commit
69e0484f8d
5 changed files with 55 additions and 3 deletions
|
|
@ -1,4 +1,5 @@
|
||||||
DATABASE_URL=postgres://postgres:postgres@localhost:5432/chattz
|
DATABASE_URL=postgres://postgres:postgres@localhost:5432/chattz
|
||||||
|
PORT=3000
|
||||||
|
|
||||||
# Authentik OIDC app values
|
# Authentik OIDC app values
|
||||||
OIDC_CLIENT_ID=replace-me
|
OIDC_CLIENT_ID=replace-me
|
||||||
|
|
|
||||||
43
.forgejo/workflows/pipeline.yaml
Normal file
43
.forgejo/workflows/pipeline.yaml
Normal file
|
|
@ -0,0 +1,43 @@
|
||||||
|
on:
|
||||||
|
release:
|
||||||
|
types: [published]
|
||||||
|
jobs:
|
||||||
|
upload:
|
||||||
|
runs-on: host
|
||||||
|
permissions:
|
||||||
|
packages: write
|
||||||
|
steps:
|
||||||
|
- uses: actions/setup-node@v6
|
||||||
|
with:
|
||||||
|
node-version: 24
|
||||||
|
- uses: actions/checkout@v6
|
||||||
|
- name: Cache Cargo registry
|
||||||
|
uses: actions/cache@v4
|
||||||
|
with:
|
||||||
|
path: |
|
||||||
|
~/.cargo/bin/
|
||||||
|
~/.cargo/registry/index/
|
||||||
|
~/.cargo/registry/cache/
|
||||||
|
~/.cargo/git/db/
|
||||||
|
key: ${{ runner.os }}-cargo-${{ hashFiles('Cargo.lock') }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-cargo-
|
||||||
|
- name: Cache Cargo target
|
||||||
|
uses: actions/cache@v4
|
||||||
|
with:
|
||||||
|
path: target/
|
||||||
|
key: ${{ runner.os }}-cargo-target-${{ hashFiles('Cargo.lock') }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-cargo-target-
|
||||||
|
- run: |
|
||||||
|
cd frontend
|
||||||
|
npm install
|
||||||
|
npm run build
|
||||||
|
- run: ~/.cargo/bin/cargo build -r
|
||||||
|
- run: |
|
||||||
|
export XDG_RUNTIME_DIR=/run/user/$(id -u)
|
||||||
|
export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$(id -u)/bus
|
||||||
|
systemctl --user stop discord
|
||||||
|
cp target/release/discord ~/discord/discord
|
||||||
|
chmod +x ~/discord/discord
|
||||||
|
systemctl --user start discord
|
||||||
|
|
@ -49,8 +49,8 @@ cargo run
|
||||||
|
|
||||||
Migrations are applied automatically during startup.
|
Migrations are applied automatically during startup.
|
||||||
|
|
||||||
Server starts on `http://localhost:3000`.
|
Server binds to `0.0.0.0:${PORT}` (defaults to `3000`).
|
||||||
Web UI is available at `http://localhost:3000/`.
|
Web UI is available at `http://localhost:${PORT}/`.
|
||||||
|
|
||||||
## Authentik setup notes
|
## Authentik setup notes
|
||||||
|
|
||||||
|
|
@ -58,6 +58,8 @@ Create an Authentik OAuth2/OIDC provider + application and set:
|
||||||
- Redirect URI: `http://localhost:3000/auth/callback`
|
- Redirect URI: `http://localhost:3000/auth/callback`
|
||||||
- Scopes including at least: `openid profile email`
|
- Scopes including at least: `openid profile email`
|
||||||
|
|
||||||
|
If you change `PORT`, update `OIDC_REDIRECT_URL` and this redirect URI to match.
|
||||||
|
|
||||||
Then copy provider endpoints into env:
|
Then copy provider endpoints into env:
|
||||||
- `OIDC_AUTHORIZE_URL`
|
- `OIDC_AUTHORIZE_URL`
|
||||||
- `OIDC_TOKEN_URL`
|
- `OIDC_TOKEN_URL`
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ use anyhow::{Context, Result};
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct Settings {
|
pub struct Settings {
|
||||||
|
pub port: u16,
|
||||||
pub database_url: String,
|
pub database_url: String,
|
||||||
pub oidc_client_id: String,
|
pub oidc_client_id: String,
|
||||||
pub oidc_client_secret: String,
|
pub oidc_client_secret: String,
|
||||||
|
|
@ -21,6 +22,10 @@ pub struct Settings {
|
||||||
impl Settings {
|
impl Settings {
|
||||||
pub fn from_env() -> Result<Self> {
|
pub fn from_env() -> Result<Self> {
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
|
port: std::env::var("PORT")
|
||||||
|
.unwrap_or_else(|_| "3000".into())
|
||||||
|
.parse()
|
||||||
|
.context("PORT must be a valid u16")?,
|
||||||
database_url: required("DATABASE_URL")?,
|
database_url: required("DATABASE_URL")?,
|
||||||
oidc_client_id: required("OIDC_CLIENT_ID")?,
|
oidc_client_id: required("OIDC_CLIENT_ID")?,
|
||||||
oidc_client_secret: required("OIDC_CLIENT_SECRET")?,
|
oidc_client_secret: required("OIDC_CLIENT_SECRET")?,
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,7 @@ async fn main() -> anyhow::Result<()> {
|
||||||
http: reqwest::Client::new(),
|
http: reqwest::Client::new(),
|
||||||
voice: Arc::new(VoiceHub::default()),
|
voice: Arc::new(VoiceHub::default()),
|
||||||
};
|
};
|
||||||
|
let port = state.settings.port;
|
||||||
|
|
||||||
let app = Router::new()
|
let app = Router::new()
|
||||||
.route("/health", get(handlers::health))
|
.route("/health", get(handlers::health))
|
||||||
|
|
@ -55,7 +56,7 @@ async fn main() -> anyhow::Result<()> {
|
||||||
.with_state(state)
|
.with_state(state)
|
||||||
.layer(TraceLayer::new_for_http());
|
.layer(TraceLayer::new_for_http());
|
||||||
|
|
||||||
let addr: SocketAddr = "0.0.0.0:3000".parse()?;
|
let addr = SocketAddr::from(([0, 0, 0, 0], port));
|
||||||
info!(%addr, "server started");
|
info!(%addr, "server started");
|
||||||
|
|
||||||
let listener = tokio::net::TcpListener::bind(addr).await?;
|
let listener = tokio::net::TcpListener::bind(addr).await?;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue