-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
updates to allow for testing services with notifications (#371)
- Loading branch information
1 parent
032c78b
commit 43ab93a
Showing
5 changed files
with
149 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
services: | ||
relations-api: | ||
image: "quay.io/cloudservices/kessel-relations:latest" | ||
environment: | ||
- "SPICEDB_PRESHARED=${SPICEDB_GRPC_PRESHARED_KEY}" | ||
- "SPICEDB_SCHEMA_FILE=/schema_file" | ||
# - "SPICEDB_PRESHARED_FILE=/run/secrets/spicedb_pre_shared" | ||
- "SPICEDB_ENDPOINT=spicedb:50051" | ||
build: | ||
dockerfile: Dockerfile | ||
profiles: ["relations-api"] | ||
secrets: | ||
- spicedb_pre_shared | ||
configs: | ||
- schema_file | ||
restart: "always" | ||
ports: | ||
- "8000:8000" | ||
- "9000:9000" | ||
networks: | ||
- kessel | ||
|
||
spicedb: | ||
image: "authzed/spicedb" | ||
command: "serve" | ||
restart: "always" | ||
ports: | ||
- "8080:8080" | ||
- "9090:9090" | ||
- "50051:50051" | ||
environment: | ||
- "SPICEDB_GRPC_PRESHARED_KEY=${SPICEDB_GRPC_PRESHARED_KEY}" | ||
- "SPICEDB_DATASTORE_ENGINE=postgres" | ||
- "SPICEDB_DATASTORE_CONN_URI=postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@database:5433/spicedb?sslmode=disable" | ||
depends_on: | ||
- "migrate" | ||
networks: | ||
- kessel | ||
|
||
migrate: | ||
image: "authzed/spicedb" | ||
command: "migrate head" | ||
restart: "on-failure" | ||
environment: | ||
- "SPICEDB_DATASTORE_ENGINE=postgres" | ||
- "SPICEDB_DATASTORE_CONN_URI=postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@database:5433/spicedb?sslmode=disable" | ||
depends_on: | ||
- "database" | ||
networks: | ||
- kessel | ||
|
||
database: | ||
image: "postgres" | ||
command: -c track_commit_timestamp=on -p 5433 | ||
ports: | ||
- "5433:5433" | ||
environment: | ||
- "POSTGRES_PASSWORD=${POSTGRES_PASSWORD}" | ||
- "POSTGRES_DB=${POSTGRES_DBNAME}" | ||
networks: | ||
- kessel | ||
|
||
configs: | ||
spicedb_pre_shared: | ||
environment: "SPICEDB_GRPC_PRESHARED_KEY" | ||
schema_file: | ||
file: deploy/schema.zed | ||
|
||
secrets: | ||
spicedb_pre_shared: | ||
file: ./.secrets/local-spicedb-secret | ||
|
||
networks: | ||
kessel: | ||
name: kessel | ||
external: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# Running Notifications + Relations + Inventory using Local Built Binaries | ||
|
||
### Running Relations: | ||
```shell | ||
# Start up SpiceDB Alt -- uses a different postgres port to avoid conflicts with notifications | ||
make spicedb-alt-up | ||
|
||
# Start relations | ||
make run | ||
``` | ||
|
||
### Running Inventory: | ||
The process to run Inventory locally can be found in Inventory API's [README](https://github.com/project-kessel/inventory-api?tab=readme-ov-file#kessel-inventory--kessel-relations-using-built-binaries) | ||
|
||
By default, Inventory will leverage a SQLite database and create a local db file called `inventory.db`. If you wish to use postgres, you'll need a postgres database running and the config file used in the above doc would need to be updated. An example of configuring Inventory API for postgres can be found [HERE](https://github.com/project-kessel/inventory-api/blob/b19bc4cef8570b8e34f85336067a0b48f9dcf910/inventory-api-compose.yaml#L19) | ||
|
||
### Running Notifications | ||
|
||
> NOTE: During the clean and install step tests are run that may not work if you do not have Docker -- YMMV | ||
```shell | ||
# Spin up the Notifications DB | ||
podman run --name notifications_db --detach -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=postgres -e POSTGRES_DB=notifications -p 5432:5432 docker.io/postgres:latest -c log_statement=all | ||
|
||
# Clean, Compile, Test, and Install | ||
./mvnw clean install | ||
|
||
# OR to skip tests (takes about 15 mins) | ||
./mvnw clean install -Dmaven.test.skip | ||
|
||
# Run the Notifications Service | ||
./mvnw clean quarkus:dev -Dnotifications.use-default-template=true -Dnotifications.kessel-inventory.enabled=true -Dnotifications.kessel-relations.enabled=true -pl :notifications-backend | ||
``` | ||
|
||
### Cleanup! | ||
```shell | ||
# To kill notifications, enter `q` in the running window to shut it down | ||
# To kill inventory and relations, use whatever fun killing technique you like! | ||
|
||
# Teardown SpiceDB | ||
make spicedb-down | ||
|
||
# Teardown Notifications DB | ||
podman stop notifications_db && podman rm notifications_db | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/bin/bash | ||
set -e | ||
# Function to check if a command is available | ||
source ./spicedb/check_docker_podman.sh | ||
NETWORK_CHECK=$(${DOCKER} network ls --filter name=kessel --format json) | ||
if [[ -z "${NETWORK_CHECK}" || "${NETWORK_CHECK}" == "[]" ]]; then ${DOCKER} network create kessel; fi | ||
${DOCKER} compose --env-file ./spicedb/.env -f ./docker-compose-alt.yaml up -d |