mirror of
https://github.com/Nutomic/ibis.git
synced 2024-11-22 03:31:09 +00:00
local federation setup
This commit is contained in:
parent
0f0f83bc3a
commit
88dd4c69c2
9 changed files with 58 additions and 28 deletions
28
Cargo.lock
generated
28
Cargo.lock
generated
|
@ -1773,9 +1773,9 @@ checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38"
|
|||
|
||||
[[package]]
|
||||
name = "js-sys"
|
||||
version = "0.3.67"
|
||||
version = "0.3.68"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9a1d36f1235bc969acba30b7f5990b864423a6068a10f7c90ae8f0112e3a59d1"
|
||||
checksum = "406cda4b368d531c842222cf9d2600a9a4acce8d29423695379c6868a143a9ee"
|
||||
dependencies = [
|
||||
"wasm-bindgen",
|
||||
]
|
||||
|
@ -3951,9 +3951,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
|
|||
|
||||
[[package]]
|
||||
name = "wasm-bindgen"
|
||||
version = "0.2.90"
|
||||
version = "0.2.91"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b1223296a201415c7fad14792dbefaace9bd52b62d33453ade1c5b5f07555406"
|
||||
checksum = "c1e124130aee3fb58c5bdd6b639a0509486b0338acaaae0c84a5124b0f588b7f"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"wasm-bindgen-macro",
|
||||
|
@ -3961,9 +3961,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-backend"
|
||||
version = "0.2.90"
|
||||
version = "0.2.91"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fcdc935b63408d58a32f8cc9738a0bffd8f05cc7c002086c6ef20b7312ad9dcd"
|
||||
checksum = "c9e7e1900c352b609c8488ad12639a311045f40a35491fb69ba8c12f758af70b"
|
||||
dependencies = [
|
||||
"bumpalo",
|
||||
"log",
|
||||
|
@ -3988,9 +3988,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-macro"
|
||||
version = "0.2.90"
|
||||
version = "0.2.91"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3e4c238561b2d428924c49815533a8b9121c664599558a5d9ec51f8a1740a999"
|
||||
checksum = "b30af9e2d358182b5c7449424f017eba305ed32a7010509ede96cdc4696c46ed"
|
||||
dependencies = [
|
||||
"quote",
|
||||
"wasm-bindgen-macro-support",
|
||||
|
@ -3998,9 +3998,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-macro-support"
|
||||
version = "0.2.90"
|
||||
version = "0.2.91"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bae1abb6806dc1ad9e560ed242107c0f6c84335f1749dd4e8ddb012ebd5e25a7"
|
||||
checksum = "642f325be6301eb8107a83d12a8ac6c1e1c54345a7ef1a9261962dfefda09e66"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
|
@ -4011,9 +4011,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-shared"
|
||||
version = "0.2.90"
|
||||
version = "0.2.91"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4d91413b1c31d7539ba5ef2451af3f0b833a005eb27a631cec32bc0635a8602b"
|
||||
checksum = "4f186bd2dcf04330886ce82d6f33dd75a7bfcf69ecf5763b89fcde53b6ac9838"
|
||||
|
||||
[[package]]
|
||||
name = "wasm-streams"
|
||||
|
@ -4030,9 +4030,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "web-sys"
|
||||
version = "0.3.67"
|
||||
version = "0.3.68"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "58cd2333b6e0be7a39605f0e255892fd7418a682d8da8fe042fe25128794d2ed"
|
||||
checksum = "96565907687f7aceb35bc5fc03770a8a0471d82e479f25832f54a0e3f4b28446"
|
||||
dependencies = [
|
||||
"js-sys",
|
||||
"wasm-bindgen",
|
||||
|
|
|
@ -71,7 +71,7 @@ console_log = "1.0.0"
|
|||
time = "0.3.31"
|
||||
tower = "0.4.13"
|
||||
markdown-it = "0.6.0"
|
||||
web-sys = "0.3.67"
|
||||
web-sys = "0.3.68"
|
||||
config = { version = "0.14.0", features = ["toml"] }
|
||||
doku = "0.21.1"
|
||||
smart-default = "0.7.1"
|
||||
|
|
|
@ -1,11 +1,35 @@
|
|||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
# You have to add the following lines to /etc/hosts to make this work:
|
||||
#
|
||||
# 127.0.0.1 ibis-alpha
|
||||
# 127.0.0.1 ibis-beta
|
||||
#
|
||||
# Then run this script and open http://ibis-alpha:8070/, http://ibis-beta:8080/ in your browser.
|
||||
|
||||
DB_FOLDER="$(pwd)/target/federation_db"
|
||||
mkdir -p "$DB_FOLDER/"
|
||||
ALPHA_DB_PATH="$DB_FOLDER/alpha"
|
||||
BETA_DB_PATH="$DB_FOLDER/beta"
|
||||
|
||||
# TODO: shouldnt wipe/recreate data if folder already exists
|
||||
./tests/scripts/start_dev_db.sh $ALPHA_DB_PATH
|
||||
./tests/scripts/start_dev_db.sh $BETA_DB_PATH
|
||||
|
||||
ALPHA_DB_URL="postgresql://ibis:password@/ibis?host=$ALPHA_DB_PATH"
|
||||
BETA_DB_URL="postgresql://ibis:password@/ibis?host=$BETA_DB_PATH"
|
||||
echo $ALPHA_DB_URL
|
||||
|
||||
# get rid of processes leftover from previous runs
|
||||
killall ibis || true
|
||||
|
||||
# launch a couple of local instances to test federation
|
||||
# sometimes ctrl+c doesnt work properly, so you have to kill trunk, cargo-watch and ibis manually
|
||||
# TODO: somehow instances use wrong port resulting in cors errors
|
||||
(trap 'kill 0' SIGINT;
|
||||
sh -c 'TRUNK_SERVE_PORT=8070 IBIS_BACKEND_PORT=8071 IBIS_DATABASE_URL="postgres://ibis:password@localhost:5432/ibis" ./scripts/watch.sh' &
|
||||
sh -c 'TRUNK_SERVE_PORT=8080 IBIS_BACKEND_PORT=8081 ./scripts/watch.sh' &
|
||||
sh -c 'TRUNK_SERVE_PORT=8090 IBIS_BACKEND_PORT=8091 ./scripts/watch.sh'
|
||||
sh -c "CARGO_TARGET_DIR=target/frontend trunk serve -w src/frontend/ --proxy-backend http://127.0.0.1:8071 --port 8070" &
|
||||
sh -c "IBIS__BIND=127.0.0.1:8071 IBIS__FEDERATION__DOMAIN=ibis-alpha:8070 IBIS__DATABASE_URL=$ALPHA_DB_URL cargo run" &
|
||||
sh -c "CARGO_TARGET_DIR=target/frontend trunk serve -w src/frontend/ --proxy-backend http://127.0.0.1:8081 --port 8080" &
|
||||
sh -c "IBIS__BIND=127.0.0.1:8081 IBIS__FEDERATION__DOMAIN=ibis-beta:8080 IBIS__DATABASE_URL=$BETA_DB_URL cargo run" &
|
||||
)
|
|
@ -1,13 +1,13 @@
|
|||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
IBIS_BACKEND_PORT="${IBIS_BACKEND_PORT:-8081}"
|
||||
IBIS__BIND="${IBIS_BIND:-"127.0.0.1:8081"}"
|
||||
|
||||
# run processes in parallel
|
||||
# https://stackoverflow.com/a/52033580
|
||||
(trap 'kill 0' SIGINT;
|
||||
# start frontend
|
||||
CARGO_TARGET_DIR=target/frontend trunk serve -w src/frontend/ --proxy-backend http://127.0.0.1:$IBIS_BACKEND_PORT &
|
||||
# # start backend, with separate target folder to avoid rebuilds from arch change
|
||||
CARGO_TARGET_DIR=target/frontend trunk serve -w src/frontend/ --proxy-backend http://$IBIS__BIND &
|
||||
# start backend, with separate target folder to avoid rebuilds from arch change
|
||||
cargo watch -x run
|
||||
)
|
||||
|
|
|
@ -94,7 +94,8 @@ fn create_cookie(jwt: String, data: &Data<IbisData>) -> Cookie<'static> {
|
|||
.same_site(SameSite::Strict)
|
||||
.path("/")
|
||||
.http_only(true)
|
||||
.secure(true)
|
||||
// TODO: not in debug mode
|
||||
//.secure(true)
|
||||
.expires(Expiration::DateTime(
|
||||
OffsetDateTime::now_utc() + Duration::weeks(52),
|
||||
))
|
||||
|
|
|
@ -136,6 +136,7 @@ pub struct LocalUserView {
|
|||
#[cfg_attr(feature = "ssr", diesel(table_name = local_user, check_for_backend(diesel::pg::Pg)))]
|
||||
pub struct DbLocalUser {
|
||||
pub id: i32,
|
||||
#[serde(skip)]
|
||||
pub password_encrypted: String,
|
||||
pub person_id: i32,
|
||||
pub admin: bool,
|
||||
|
|
|
@ -62,8 +62,12 @@ impl GlobalState {
|
|||
|
||||
#[component]
|
||||
pub fn App() -> impl IntoView {
|
||||
let port = option_env!("TRUNK_SERVE_PORT").unwrap_or("8080");
|
||||
let backend_hostname = format!("127.0.0.1:{port}");
|
||||
#[allow(unused_mut, unused_assignments)]
|
||||
let mut backend_hostname = "127.0.0.1:8080".to_string();
|
||||
#[cfg(not(feature = "ssr"))]
|
||||
{
|
||||
backend_hostname = web_sys::window().unwrap().location().host().unwrap();
|
||||
}
|
||||
|
||||
provide_meta_context();
|
||||
let backend_hostname = GlobalState {
|
||||
|
|
|
@ -18,7 +18,8 @@ pub async fn main() -> ibis_lib::backend::error::MyResult<()> {
|
|||
|
||||
let config = Config::builder()
|
||||
.add_source(config::File::with_name("config/config.toml"))
|
||||
.add_source(config::Environment::with_prefix("IBIS"))
|
||||
// Cant use _ as separator due to https://github.com/mehcode/config-rs/issues/391
|
||||
.add_source(config::Environment::with_prefix("IBIS").separator("__"))
|
||||
.build()
|
||||
.unwrap();
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/bin/bash
|
||||
set -e
|
||||
set -ex
|
||||
|
||||
export PGHOST=$1
|
||||
export PGHOST="$1"
|
||||
export PGDATA="$1/dev_pgdata"
|
||||
|
||||
# If cluster exists, stop the backend
|
||||
|
@ -19,7 +19,6 @@ rm -rf $1
|
|||
initdb --username=postgres --auth=trust --no-instructions
|
||||
|
||||
touch "$PGHOST/.s.PGSQL.5432"
|
||||
echo "$PGHOST/.s.PGSQL.5432"
|
||||
|
||||
# Start backend that only listens to socket in current directory
|
||||
pg_ctl start --options="-c listen_addresses= -c unix_socket_directories=$PGHOST"
|
||||
|
|
Loading…
Reference in a new issue