43 lines
1.4 KiB
Markdown
43 lines
1.4 KiB
Markdown
# Portable Linux server build
|
|
|
|
This build produces one `x86_64` Linux server executable with embedded
|
|
PostgreSQL. The Rust program is statically linked against musl. PostgreSQL is
|
|
compiled against musl and stored inside the executable.
|
|
|
|
PostgreSQL itself remains dynamically loadable so the `btree_gist` extension
|
|
used by the migrations works. Its musl loader is included in the embedded
|
|
archive, and static launcher executables invoke every PostgreSQL tool through
|
|
that loader. Neither glibc, musl, PostgreSQL nor timezone data needs to be
|
|
installed on the target machine.
|
|
|
|
Build directly through the repository's Nix flake:
|
|
|
|
```sh
|
|
nix build '.?submodules=1#portable-server'
|
|
```
|
|
|
|
Output: `result/bin/server`.
|
|
|
|
The resulting executable is intended for 64-bit Linux kernels. Run it normally:
|
|
|
|
```sh
|
|
cp .env_template_musl .env
|
|
# Replace JWT_SECRET in .env before starting.
|
|
./result/bin/server server
|
|
```
|
|
|
|
Required: `JWT_SECRET`.
|
|
|
|
Optional: `KOMP_AC_POSTGRES_DIR` selects the persistent PostgreSQL directory.
|
|
`DATABASE_URL` and `RUST_DB_*` are not required in embedded mode.
|
|
|
|
The portable binary can still use a separately managed PostgreSQL server at
|
|
runtime. Set `RUST_DB_MODE=external` and provide `RUST_DB_USER`,
|
|
`RUST_DB_PASSWORD`, `RUST_DB_HOST`, `RUST_DB_PORT` and `RUST_DB_NAME`.
|
|
|
|
Use the external PostgreSQL build on NixOS when preferred:
|
|
|
|
```sh
|
|
cargo build --release --package server --no-default-features
|
|
```
|