From 7ee6650d16facb0a0f7398ad0d160fc17f1e1338 Mon Sep 17 00:00:00 2001 From: Darryl Yeo Date: Wed, 30 Oct 2024 12:32:45 -0500 Subject: [PATCH 1/6] Docker Compose setup: manually specify default EdgeDB environment variables in `.env.docker` file so SvelteKit can detect them --- .env.docker.example | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.env.docker.example b/.env.docker.example index c4aba08b..83180d64 100644 --- a/.env.docker.example +++ b/.env.docker.example @@ -7,3 +7,11 @@ EDGEDB_SERVER_PASSWORD=secret # A SendGrid API Key used to authenticate the SendGrid email relay service (https://www.twilio.com/docs/sendgrid/api-reference). # To use a different email relay service, modify the environment variables in docker-compose.yml found at services › smtp › environment. SENDGRID_KEY=SG.xx-xxxxxxxxxxxx-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + +# --- + +# Variables shared by EdgeDB and SvelteKit – do not edit +EDGEDB_HOST=edgedb +EDGEDB_PORT=5656 +EDGEDB_BRANCH=main +EDGEDB_SERVER_PROTOCOL=http From d82ecda49a8515f71b490d4cc6bb084148d8cb89 Mon Sep 17 00:00:00 2001 From: Darryl Yeo Date: Wed, 30 Oct 2024 12:34:32 -0500 Subject: [PATCH 2/6] README: update --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 698ad4ae..d39952b8 100644 --- a/README.md +++ b/README.md @@ -232,7 +232,7 @@ To access the Infernet Cloud UI from a different machine, you will need to set u Find more commands and their definitions in the `scripts` section of [`package.json`](package.json). -## Docker Compose setup (recommended for production) +## Docker Compose setup 1. Install [Docker Compose](https://docs.docker.com/compose/install). From 9b7d364b10917fc04021d11a761015c04dda2439 Mon Sep 17 00:00:00 2001 From: Darryl Yeo Date: Wed, 30 Oct 2024 12:43:35 -0500 Subject: [PATCH 3/6] Docker Compose setup: copy `.env.docker` to `.env` during build to allow SvelteKit to read as $env/static/private --- server.Dockerfile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/server.Dockerfile b/server.Dockerfile index 2522f09b..f19c01e4 100644 --- a/server.Dockerfile +++ b/server.Dockerfile @@ -21,6 +21,9 @@ FROM base AS build COPY .env.docker .env.docker +# Also copy to .env to allow SvelteKit to read as $env/static/private +COPY .env.docker .env + # pnpm install RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile From ce386c96ac723642c857d30e6c9a9ff102fe242a Mon Sep 17 00:00:00 2001 From: Darryl Yeo Date: Wed, 30 Oct 2024 13:12:57 -0500 Subject: [PATCH 4/6] Local setup: update default redirect URL for EdgeDB Auth --- dbschema/bootstrap/auth.edgeql | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/dbschema/bootstrap/auth.edgeql b/dbschema/bootstrap/auth.edgeql index f2be1e2b..96c666eb 100644 --- a/dbschema/bootstrap/auth.edgeql +++ b/dbschema/bootstrap/auth.edgeql @@ -11,7 +11,10 @@ ext::auth::AuthConfig::token_time_to_live := "24 hours"; CONFIGURE CURRENT BRANCH SET ext::auth::AuthConfig::allowed_redirect_urls := { # Local setup - 'http://localhost:5173', + 'http://localhost:4173', + + # Local setup (dev) + # 'http://localhost:5173', # Docker Compose setup # 'http://localhost:3000', From 7188c8614e4e8753d176e280f84567e0e091c42e Mon Sep 17 00:00:00 2001 From: Darryl Yeo Date: Wed, 30 Oct 2024 13:15:43 -0500 Subject: [PATCH 5/6] EdgeDB Auth: update default sender email to placeholder --- dbschema/bootstrap/auth.edgeql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dbschema/bootstrap/auth.edgeql b/dbschema/bootstrap/auth.edgeql index 96c666eb..1df34493 100644 --- a/dbschema/bootstrap/auth.edgeql +++ b/dbschema/bootstrap/auth.edgeql @@ -28,7 +28,7 @@ INSERT ext::auth::EmailPasswordProviderConfig { # SMTP Configuration CONFIGURE CURRENT BRANCH SET -ext::auth::SMTPConfig::sender := 'infernet-cloud@ritual.net'; +ext::auth::SMTPConfig::sender := 'your-sender-email@example.com'; CONFIGURE CURRENT BRANCH SET ext::auth::SMTPConfig::host := 'smtp'; CONFIGURE CURRENT BRANCH SET From 8c966df01102bd0451819251220abae55aa691d6 Mon Sep 17 00:00:00 2001 From: Darryl Yeo Date: Wed, 30 Oct 2024 14:30:45 -0500 Subject: [PATCH 6/6] Docker Compose setup: fix `docker:edgedb:init:auth` script --- package.json | 2 +- src/routes/+layout.svelte | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 214bb40f..78170e4d 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,7 @@ "docker:clean": "docker system prune -f", "docker:server:restart": "pnpm run docker:clean && pnpm run docker-compose up --build --no-deps --detach server", "docker:edgedb:init": "pnpm run docker:edgedb:init:auth", - "docker:edgedb:init:auth": "pnpm run docker-compose up edgedb --wait && pnpm run docker:edgedb:cli query -f ./dbschema/bootstrap/auth.edgeql", + "docker:edgedb:init:auth": "pnpm run docker-compose up edgedb --wait && sh -c '. .env.docker && printf \"%s\\n\" \"$EDGEDB_SERVER_PASSWORD\" | pnpm run docker-compose exec -T edgedb edgedb --tls-security insecure --password-from-stdin query -f ./dbschema/bootstrap/auth.edgeql'", "docker:edgedb:restart": "pnpm run docker:clean && pnpm run docker-compose up --build --no-deps --detach edgedb", "docker:edgedb:backup": "cp -r edgedb-data \"edgedb-data.backup.$(date +%s)\"", "docker:edgedb:destroy": "sh -c 'read -p \"Destroy EdgeDB Docker volume? (y/N): \" confirm && case $confirm in y|Y) pnpm run docker-compose down edgedb && rm -rf edgedb-data ;; *) echo \"Operation cancelled\" ;; esac'", diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte index 26fa19d7..79e1b2e7 100644 --- a/src/routes/+layout.svelte +++ b/src/routes/+layout.svelte @@ -128,7 +128,7 @@