-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
updates to allow for testing services with notifications #371
Merged
tonytheleg
merged 1 commit into
project-kessel:main
from
tonytheleg:local-testing-w-notifications
Feb 13, 2025
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do the steps in this link bring up a db to work with gorm?
make migrate
makes me think of an in-memory db maybe?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the config is setup to use sqllite by default. The
make migrate
will call the migrate command which leverages gorm to setup the db.The config can be manualy changed for postgres if needed and such, but sqllite should be sufficient enough or testing gorm changes i would suspect
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://github.com/project-kessel/inventory-api/blob/6871f97398ff2655f75bce48482022d2d7c19402/internal/data/migrate.go#L14