mirror of
https://github.com/djdevin/recflare.git
synced 2026-09-08 14:41:28 -07:00
move to .env
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
# Base domain all service hosts are derived from, e.g. accounts.<domain>.
|
||||
RECFLARE_DOMAIN=rec.example.com
|
||||
|
||||
# Optional per-app subdomain overrides, as a compact JSON object keyed by the
|
||||
# worker's directory name. Defaults to the directory name when unset.
|
||||
# RECFLARE_SUBDOMAINS={"playersettings":"settings"}
|
||||
@@ -47,6 +47,3 @@ yarn-error.log*
|
||||
|
||||
# Agents
|
||||
.claude/settings.local.json
|
||||
|
||||
# Configuration
|
||||
env.json
|
||||
|
||||
@@ -142,12 +142,13 @@ just install
|
||||
|
||||
**Configure your custom domain:**
|
||||
|
||||
`env.json` is the single source of truth for your base domain; it is gitignored,
|
||||
so each clone needs its own copy.
|
||||
For local development, set your base domain in a `.env` file at the repo root; it
|
||||
is gitignored, so each clone needs its own copy. (For CI you can skip the file and
|
||||
export `RECFLARE_DOMAIN` directly — see below.)
|
||||
|
||||
```bash
|
||||
cp env.example.json env.json
|
||||
# edit env.json and set "domain" to your domain
|
||||
cp .env.example .env
|
||||
# edit .env and set RECFLARE_DOMAIN to your domain
|
||||
```
|
||||
|
||||
`just deploy` resolves the base domain at deploy time and passes it to wrangler —
|
||||
@@ -156,11 +157,11 @@ and the base domain is injected as the `DOMAIN` var so the `ns` service-discover
|
||||
document and the api share-link base URL are built at runtime. Nothing in version
|
||||
control is rewritten; committed `wrangler.jsonc` files have no routes.
|
||||
|
||||
The domain is read from the `RECFLARE_DOMAIN` environment variable if set,
|
||||
otherwise from `env.json`. Per-app subdomain overrides come from
|
||||
`RECFLARE_SUBDOMAINS` (a JSON object, e.g. `{"playersettings":"settings"}`) or
|
||||
the `subdomains` key in `env.json`. For CI, set `RECFLARE_DOMAIN` as a secret and
|
||||
skip `env.json` entirely:
|
||||
The domain comes from the `RECFLARE_DOMAIN` environment variable; for local dev
|
||||
that's loaded from `.env`, and an already-exported value (e.g. a CI secret) takes
|
||||
precedence over the file. Per-app subdomain overrides come from
|
||||
`RECFLARE_SUBDOMAINS` (a JSON object, e.g. `{"playersettings":"settings"}`). For
|
||||
CI, set `RECFLARE_DOMAIN` as a secret and skip `.env` entirely:
|
||||
|
||||
```bash
|
||||
RECFLARE_DOMAIN=rec.example.com just deploy
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
{
|
||||
"domain": "rec.example.com",
|
||||
"subdomains": {
|
||||
"playersettings": "settings"
|
||||
}
|
||||
}
|
||||
@@ -10,23 +10,28 @@ VERSION=$(get-version)
|
||||
# — committed wrangler.jsonc has no routes, and the base domain is passed as the
|
||||
# DOMAIN var at runtime.
|
||||
#
|
||||
# Source order: the RECFLARE_DOMAIN env var wins (handy for CI secrets), else the
|
||||
# gitignored env.json at the repo root. Per-app subdomain overrides come from
|
||||
# RECFLARE_SUBDOMAINS (a JSON object) or env.json's "subdomains".
|
||||
if [ -n "${RECFLARE_DOMAIN:-}" ]; then
|
||||
DOMAIN="$RECFLARE_DOMAIN"
|
||||
SUBDOMAINS_JSON=${RECFLARE_SUBDOMAINS:-}
|
||||
[ -n "$SUBDOMAINS_JSON" ] || SUBDOMAINS_JSON='{}'
|
||||
else
|
||||
ENV_JSON="$(git rev-parse --show-toplevel)/env.json"
|
||||
if [ ! -f "$ENV_JSON" ]; then
|
||||
echo "error: set RECFLARE_DOMAIN or create $ENV_JSON (copy env.example.json)" >&2
|
||||
exit 1
|
||||
# The domain comes from the RECFLARE_DOMAIN env var. For local dev that's set in a
|
||||
# gitignored .env at the repo root; in CI it's an exported secret. An already-set
|
||||
# RECFLARE_DOMAIN wins and skips the file. Per-app subdomain overrides come from
|
||||
# RECFLARE_SUBDOMAINS (a JSON object, e.g. {"playersettings":"settings"}).
|
||||
if [ -z "${RECFLARE_DOMAIN:-}" ]; then
|
||||
ENV_FILE="$(git rev-parse --show-toplevel)/.env"
|
||||
if [ -f "$ENV_FILE" ]; then
|
||||
set -a
|
||||
. "$ENV_FILE"
|
||||
set +a
|
||||
fi
|
||||
DOMAIN=$(jq -r '.domain' "$ENV_JSON")
|
||||
SUBDOMAINS_JSON=$(jq -c '.subdomains // {}' "$ENV_JSON")
|
||||
fi
|
||||
|
||||
if [ -z "${RECFLARE_DOMAIN:-}" ]; then
|
||||
echo "error: RECFLARE_DOMAIN is not set — export it or add it to .env (see .env.example)" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
DOMAIN="$RECFLARE_DOMAIN"
|
||||
SUBDOMAINS_JSON=${RECFLARE_SUBDOMAINS:-}
|
||||
[ -n "$SUBDOMAINS_JSON" ] || SUBDOMAINS_JSON='{}'
|
||||
|
||||
DIR=$(basename "$PWD")
|
||||
# Per-app subdomain override, falling back to the worker's directory name.
|
||||
SUBDOMAIN=$(printf '%s' "$SUBDOMAINS_JSON" | jq -r --arg d "$DIR" '.[$d] // $d')
|
||||
|
||||
Reference in New Issue
Block a user