From 05b80fbe4fa55ba723d7725fc4bb3d5ccbc4608a Mon Sep 17 00:00:00 2001 From: ConnorYoh <40631091+ConnorYoh@users.noreply.github.com> Date: Tue, 26 May 2026 15:40:44 +0100 Subject: [PATCH] Working local Saas (#6450) Env file for setting backend saas and taskfile for running it --- .env.saas.example | 34 ++++++++++++++++++++++++++++++++++ .gitignore | 1 + .taskfiles/backend.yml | 19 +++++++++++++++++++ 3 files changed, 54 insertions(+) create mode 100644 .env.saas.example diff --git a/.env.saas.example b/.env.saas.example new file mode 100644 index 000000000..d9d787fe0 --- /dev/null +++ b/.env.saas.example @@ -0,0 +1,34 @@ +############################################################################### +# Stirling-PDF SaaS local environment template. +# +# Copy this file to `.env.saas.local` (gitignored) and fill in real values. +# Loaded by `task backend:dev:saas` via Taskfile's `dotenv:` directive, then +# read by Spring Boot's `${...}` placeholders in application-saas.properties +# and application-dev.properties. +# +# DO NOT commit `.env.saas.local`. Only `.env.saas.example` is checked in. +############################################################################### + +# ---------- Supabase project ---------- +# Project reference (the subdomain part of .supabase.co). Required. +# Example dev project: +SAAS_DB_PROJECT_REF= + +# Edge function secret used by billing/license rollup calls. +SUPABASE_EDGE_FUNCTION_SECRET= + +# ---------- Database (saas profile) ---------- +# Direct JDBC URL to the Supabase Postgres. Required when running the plain +# `saas` profile (i.e. without `--spring.profiles.include=dev`). +# Example: jdbc:postgresql://db..supabase.co:5432/postgres +SAAS_DB_URL= +SAAS_DB_USERNAME=postgres +SAAS_DB_PASSWORD= + +# ---------- Database (dev profile overrides) ---------- +# Used when `--spring.profiles.include=dev` is active. The dev profile +# defaults the URL/username to the shared dev Supabase project, but the +# password must still be provided here. +SAAS_DEV_DB_URL= +SAAS_DEV_DB_USERNAME=postgres +SAAS_DEV_DB_PASSWORD= diff --git a/.gitignore b/.gitignore index 261b2a40a..5c3bd57cc 100644 --- a/.gitignore +++ b/.gitignore @@ -174,6 +174,7 @@ venv.bak/ # Env files (secrets / local overrides). Subproject .gitignore files whitelist any committed defaults. .env* +!.env.saas.example # VS Code /.vscode/**/* diff --git a/.taskfiles/backend.yml b/.taskfiles/backend.yml index 56db8eb4a..ccf3a7775 100644 --- a/.taskfiles/backend.yml +++ b/.taskfiles/backend.yml @@ -39,6 +39,25 @@ tasks: - cmd: ./gradlew clean bootRun -PbuildWithFrontend=true platforms: [linux, darwin] + dev:saas: + desc: "Start backend in SaaS flavor against Supabase (loads .env.saas.local)" + # `dotenv:` reads from the root Taskfile's directory (".") because this + # subtaskfile is included with `dir: .`. Drop the file at the repo root. + dotenv: ['.env.saas.local'] + ignore_error: true + vars: + PORT: '{{.PORT | default "8080"}}' + # Override to "" to run the pure `saas` profile against your own SAAS_DB_*. + PROFILES: '{{.PROFILES | default "dev"}}' + env: + SERVER_PORT: '{{.PORT}}' + STIRLING_FLAVOR: saas + cmds: + - cmd: cmd /c ".\gradlew.bat :stirling-pdf:bootRun {{if .PROFILES}}--args=\"--spring.profiles.include={{.PROFILES}}\"{{end}}" + platforms: [windows] + - cmd: ./gradlew :stirling-pdf:bootRun {{if .PROFILES}}--args='--spring.profiles.include={{.PROFILES}}'{{end}} + platforms: [linux, darwin] + build: desc: "Full backend build" cmds: