Compare commits

..

2 Commits

Author SHA1 Message Date
16d72f40ce add packaging script
All checks were successful
Backend Actions / check (push) Successful in 15s
Backend Actions / build (push) Successful in 26s
Backend Actions / test (push) Successful in 37s
2025-07-25 00:40:04 +01:00
50cee580de make shutdown endpoint default 2025-07-25 00:39:51 +01:00
7 changed files with 30 additions and 10 deletions

View File

@ -55,8 +55,8 @@ jobs:
~/.cargo/git ~/.cargo/git
backend/target backend/target
key: ${{ runner.os }}-cargo-test-${{ hashFiles('backend/Cargo.lock') }} key: ${{ runner.os }}-cargo-test-${{ hashFiles('backend/Cargo.lock') }}
- name: Build Binary with Shutdown - name: Build Binary
run: cargo build --features shutdown --bin nuchat run: cargo build --locked --bin nuchat
- name: Run Tests - name: Run Tests
run: ./scripts/test.sh run: ./scripts/test.sh
- name: Upload Test Logs - name: Upload Test Logs

2
.gitignore vendored
View File

@ -1 +1,3 @@
.env .env
package/
package.tar.zst

View File

@ -28,5 +28,6 @@ path = "src/main.rs"
name ="nuchat" name ="nuchat"
[features] [features]
default = [] default = [ "shutdown" ]
all = ["shutdown"]
shutdown = [] shutdown = []

View File

@ -1,11 +1,11 @@
build: build:
cargo build --features shutdown cargo build
run: run:
cargo run --features shutdown cargo run
start: start:
cargo run --features shutdown 2>&1 > logs/nuchat.log cargo run 2>&1 > logs/nuchat.log
test: test:
./scripts/test.sh ./scripts/test.sh

View File

@ -1,9 +1,10 @@
# Backend # Backend
Generate random secret using. This secret will be used to authenticate users on all `/admin` routes Generate random secret using openssl. This secret will be used to authenticate users on all `/admin` routes.
If no secret is given then no authentication will be required
```bash ```bash
ADMIN_SECRET=$(openssl rand --base64 32) nuchat --admin-secret $(openssl rand --base64 32)
``` ```
## Features ## Features
@ -11,5 +12,5 @@ ADMIN_SECRET=$(openssl rand --base64 32)
### shutdown ### shutdown
this feature enables an endpoint that allows you to shutdown the server. this feature enables an endpoint that allows you to shutdown the server.
**WARNING**: If the `ADMIN_SECRET` env var is not set then this endpoint is completely exposed and allows anyone to shutdown the server. **WARNING**: If the `admin-secret` flag is not set then this endpoint is completely exposed and allows anyone to shutdown the server.

View File

@ -14,7 +14,7 @@ fi
curl -s -X POST localhost:7001/admin/shutdown 2>&1 > /dev/null curl -s -X POST localhost:7001/admin/shutdown 2>&1 > /dev/null
# start server # start server
cargo run --features shutdown -- --port 7001 2>&1 > logs/nuchat.log & cargo run -- --port 7001 2>&1 > logs/nuchat.log &
# run tests # run tests
cargo nextest run --color=always 2>&1 | tee logs/test-output.log cargo nextest run --color=always 2>&1 | tee logs/test-output.log

16
package.sh Executable file
View File

@ -0,0 +1,16 @@
#!/usr/bin/env bash
mkdir package
pushd backend
cargo build --release
cp -v target/release/nuchat ../package/
popd
pushd ui
pnpm run build
cp -rv .output ../package/ui
popd
tar -cf - package/ | zstd -19 -T0 -o package.tar.zst