Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,034 changes: 547 additions & 487 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ tokio-stream = { version = "0.1.15", features = ["sync"] }
pin-project = "1"
# Other dep
time = { version = "0.3.36", features = ["serde"] }
chrono = { version = "0.4", features = ["serde"] }
chrono-humanize = "0.2"
parking_lot = "~0.12"
num-bigint = "~0.4"
# Web deps
Expand Down
6 changes: 6 additions & 0 deletions config/database_sample.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
url = "mongodb://bridge-user:admin123456789@127.0.0.1:27017/?authSource=bridge"
url_local = "mongodb://bridge-user:admin123456789@127.0.0.1:27017/?authSource=bridge"
url_prod = "mongodb://bridge-user:admin123456789@127.0.0.1:27017/?authSource=bridge"

# Apple Silicon:
# url = "mongodb://127.0.0.1:27017/bridge"
# url_local = "mongodb://127.0.0.1:27017/bridge"
# url_prod = "mongodb://127.0.0.1:27017/bridge"

name = "bridge"

[keydb]
Expand Down
242 changes: 145 additions & 97 deletions doc/deployment.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,46 +11,88 @@
just certs
just gen-curve
```
- If you intend to public face Bridge, properly obtain certificates from a trusted authority

> **Note:** If you intend to deploy Bridge publicly, properly obtain certificates from a trusted authority.

3. Copy or rename the provided configuration files:

- `config/configurations_sample.toml` → `config/configurations.toml`
- `config/database_sample.toml` → `config/database.toml`

4. Update the relevant variables:

**configurations.toml**

- `redirect_url`: Set to their localhost versions (commented out)
- `client_id` / `client_secret`: If you're with IBM, you can find instructions on how to generate these [here](https://github.com/acceleratedscience/configurations/tree/main/bridge/prod).
If you're developing your own application, you will need to register it with IBM ID to use the IBM ID authentication. For now, no other auth methods are supported (PRs welcome)

**database.toml**

- `[mongodb]`: Use the urls without auth (commented out) if you're using an Apple Silicon device (M1/M2/M3 etc.)

<br>

### Running Bridge locally

1. Start a local DB instances
1. Start a local DB instance

Ensure you have Podman installed on your local machine. If you prefer Docker, updated "podman" commands to "docker" commands
Ensure you have Podman installed and running on your local machine.

```shell
just local-mongo
```

Optionally you can start a cache instance
> **Apple Silicon Support:** Use the ARM install instead, and set the DB urls in `database.toml` without auth: `url="mongodb://127.0.0.1:27017/bridge"`
>
> ```
> just local-mongo-arm
> ```

> **Docker Support:** If you prefer Docker, updated "podman" commands to "docker" commands in the [justfile](../justfile).

2. Optionally you can start a cache instance

```shell
just local-keydb
```

2. Start the Bridge server
3. Start the Bridge server

```shell
cargo run --feature=full --release
cargo run --features=full
```

The release flag will enable all optimizations and compilation will take a longer time

Look in the Cargo.toml for the available feature flags
Refer to [Cargo.toml](../Cargo.toml) for the available `--features` flags.

3. See the result at [localhost:8080](https://localhost:8080)
The `--release` flag will enable all optimizations and compilation will take a longer time:

```shell
cargo run --features=full --release
```

> **Development:**
> To have the server restart on change, use cargo-watch:
>
> ```
> cargo install cargo-watch
> ```
>
> ```
> cargo watch -x 'run --features=full
> ```
>
> **Note:** Be patient as the initial build may take multiple minutes.

4. See the result at [localhost:8080](https://localhost:8080) (HTTPS required)

<br>

### Destroying Bridge running locally

1. Stop the Bridge server

Press `Ctrl + C` in the terminal where the server is running or send a sigterm.
Simply press `Ctrl` + `C` in the terminal where the server is running or send a sigterm.

2. Stop the local DB instances

Expand All @@ -64,105 +106,111 @@
cargo clean
```

<br>

### Deployment to Kubernetes / Openshift

> [!NOTE]
> This is one possible way to deploy and it is not a hard requirement.

1. Build the Bridge container image

Check what features you want to enable for your deployment

```shell
just build-full
```

2. Tag and push the image to your choice of Image repository

3. Apply this service as a deployment
- Ensure you give it the proper permission to access various namespaces and create CRDs
- The following was generated with Helm
```yaml
kind: Deployment
metadata:
annotations:
deployment.kubernetes.io/revision: "39"
meta.helm.sh/release-name: bridge-openad
meta.helm.sh/release-namespace: openbridge
creationTimestamp: "2025-05-15T03:42:42Z"
generation: 39
labels:
app.kubernetes.io/instance: bridge-openad
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: bridge-openad
app.kubernetes.io/version: 1.16.0
helm.sh/chart: bridge-openad-0.1.0
name: bridge-openad
namespace: bridge
resourceVersion: ""
uid: ""
spec:
progressDeadlineSeconds: 600
replicas: 1
revisionHistoryLimit: 10
selector:
matchLabels:
app.kubernetes.io/instance: bridge-openad
app.kubernetes.io/name: bridge-openad
strategy:
rollingUpdate:
maxSurge: 25%
maxUnavailable: 25%
type: RollingUpdate
template:

- Ensure you give it the proper permission to access various namespaces and create CRDs
- The following was generated with Helm:

```yaml
kind: Deployment
metadata:
annotations:
kubectl.kubernetes.io/restartedAt: "2025-07-04T22:24:19-04:00"
creationTimestamp: null
labels:
app.kubernetes.io/instance: bridge-openad
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: bridge-openad
app.kubernetes.io/version: 1.16.0
helm.sh/chart: bridge-openad-0.1.0
spec:
containers:
- image: xxx.amazonaws.com/bridge/openad:v0.0.1
imagePullPolicy: Always
livenessProbe:
failureThreshold: 3
httpGet:
path: /health
port: 8080
scheme: HTTPS
periodSeconds: 10
successThreshold: 1
timeoutSeconds: 1
annotations:
deployment.kubernetes.io/revision: "39"
meta.helm.sh/release-name: bridge-openad
meta.helm.sh/release-namespace: openbridge
creationTimestamp: "2025-05-15T03:42:42Z"
generation: 39
labels:
app.kubernetes.io/instance: bridge-openad
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: bridge-openad
app.kubernetes.io/version: 1.16.0
helm.sh/chart: bridge-openad-0.1.0
name: bridge-openad
ports:
- containerPort: 8080
name: http
protocol: TCP
readinessProbe:
failureThreshold: 3
httpGet:
path: /health
port: 8080
scheme: HTTPS
periodSeconds: 10
successThreshold: 1
timeoutSeconds: 1
resources:
requests:
cpu: 100m
memory: 1Gi
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
dnsPolicy: ClusterFirst
imagePullSecrets:
- name: ecr-registry-openad
restartPolicy: Always
schedulerName: default-scheduler
securityContext: {}
serviceAccount: bridge-openad
serviceAccountName: bridge-openad
terminationGracePeriodSeconds: 30
```
namespace: bridge
resourceVersion: ""
uid: ""
spec:
progressDeadlineSeconds: 600
replicas: 1
revisionHistoryLimit: 10
selector:
matchLabels:
app.kubernetes.io/instance: bridge-openad
app.kubernetes.io/name: bridge-openad
strategy:
rollingUpdate:
maxSurge: 25%
maxUnavailable: 25%
type: RollingUpdate
template:
metadata:
annotations:
kubectl.kubernetes.io/restartedAt: "2025-07-04T22:24:19-04:00"
creationTimestamp: null
labels:
app.kubernetes.io/instance: bridge-openad
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: bridge-openad
app.kubernetes.io/version: 1.16.0
helm.sh/chart: bridge-openad-0.1.0
spec:
containers:
- image: xxx.amazonaws.com/bridge/openad:v0.0.1
imagePullPolicy: Always
livenessProbe:
failureThreshold: 3
httpGet:
path: /health
port: 8080
scheme: HTTPS
periodSeconds: 10
successThreshold: 1
timeoutSeconds: 1
name: bridge-openad
ports:
- containerPort: 8080
name: http
protocol: TCP
readinessProbe:
failureThreshold: 3
httpGet:
path: /health
port: 8080
scheme: HTTPS
periodSeconds: 10
successThreshold: 1
timeoutSeconds: 1
resources:
requests:
cpu: 100m
memory: 1Gi
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
dnsPolicy: ClusterFirst
imagePullSecrets:
- name: ecr-registry-openad
restartPolicy: Always
schedulerName: default-scheduler
securityContext: {}
serviceAccount: bridge-openad
serviceAccountName: bridge-openad
terminationGracePeriodSeconds: 30
```
10 changes: 5 additions & 5 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,12 @@ build-full: (build-features "notebook,lifecycle,observe,mcp,openwebui")

# --- Frontend & Minification ---
mini-js:
uglifyjs ./static/js/main.js -o ./static/js/main.js -c -m
npx uglifyjs ./static/js/main.js -o ./static/js/main.js -c -m

build-front:
tailwindcss -i ./static/css/input.css -o ./static/css/output.css --minify
tsc
uglifyjs ./static/js/main.js -o ./static/js/main.js -c -m
npx tailwindcss -i ./static/css/input.css -o ./static/css/output.css --minify
npx tsc
npx uglifyjs ./static/js/main.js -o ./static/js/main.js -c -m

# --- Local Development Services ---
local-mongo:
Expand Down Expand Up @@ -123,6 +123,6 @@ certs:
mkdir certs
@openssl req -x509 -newkey rsa:2048 -nodes -keyout certs/key.pem -out certs/cert.pem -days 365 -subj '/CN=open.accelerator.cafe'

gen_curve:
gen-curve:
@openssl ecparam -name prime256v1 -genkey -noout -out certs/private.ec.key
@openssl ec -in certs/private.ec.key -pubout -out certs/public-key.pem
12 changes: 4 additions & 8 deletions src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,10 @@ pub fn init_once() -> Configuration {
validation.set_audience(&AUD);
validation.leeway = 0;

let (config_location_str, database_location_str) = if cfg!(debug_assertions) {
(
"config/configurations_sample.toml",
"config/database_sample.toml",
)
} else {
("config/configurations.toml", "config/database.toml")
};
let (config_location_str, database_location_str) = (
"config/configurations.toml",
"config/database.toml",
);

let conf_table: toml::Table =
toml::from_str(&read_to_string(PathBuf::from_str(config_location_str).unwrap()).unwrap())
Expand Down
Loading