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
|
# Agents
|
||||||
.claude/settings.local.json
|
.claude/settings.local.json
|
||||||
|
|
||||||
# Configuration
|
|
||||||
env.json
|
|
||||||
|
|||||||
@@ -142,12 +142,13 @@ just install
|
|||||||
|
|
||||||
**Configure your custom domain:**
|
**Configure your custom domain:**
|
||||||
|
|
||||||
`env.json` is the single source of truth for your base domain; it is gitignored,
|
For local development, set your base domain in a `.env` file at the repo root; it
|
||||||
so each clone needs its own copy.
|
is gitignored, so each clone needs its own copy. (For CI you can skip the file and
|
||||||
|
export `RECFLARE_DOMAIN` directly — see below.)
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
cp env.example.json env.json
|
cp .env.example .env
|
||||||
# edit env.json and set "domain" to your domain
|
# edit .env and set RECFLARE_DOMAIN to your domain
|
||||||
```
|
```
|
||||||
|
|
||||||
`just deploy` resolves the base domain at deploy time and passes it to wrangler —
|
`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
|
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.
|
control is rewritten; committed `wrangler.jsonc` files have no routes.
|
||||||
|
|
||||||
The domain is read from the `RECFLARE_DOMAIN` environment variable if set,
|
The domain comes from the `RECFLARE_DOMAIN` environment variable; for local dev
|
||||||
otherwise from `env.json`. Per-app subdomain overrides come from
|
that's loaded from `.env`, and an already-exported value (e.g. a CI secret) takes
|
||||||
`RECFLARE_SUBDOMAINS` (a JSON object, e.g. `{"playersettings":"settings"}`) or
|
precedence over the file. Per-app subdomain overrides come from
|
||||||
the `subdomains` key in `env.json`. For CI, set `RECFLARE_DOMAIN` as a secret and
|
`RECFLARE_SUBDOMAINS` (a JSON object, e.g. `{"playersettings":"settings"}`). For
|
||||||
skip `env.json` entirely:
|
CI, set `RECFLARE_DOMAIN` as a secret and skip `.env` entirely:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
RECFLARE_DOMAIN=rec.example.com just deploy
|
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
|
# — committed wrangler.jsonc has no routes, and the base domain is passed as the
|
||||||
# DOMAIN var at runtime.
|
# DOMAIN var at runtime.
|
||||||
#
|
#
|
||||||
# Source order: the RECFLARE_DOMAIN env var wins (handy for CI secrets), else the
|
# The domain comes from the RECFLARE_DOMAIN env var. For local dev that's set in a
|
||||||
# gitignored env.json at the repo root. Per-app subdomain overrides come from
|
# gitignored .env at the repo root; in CI it's an exported secret. An already-set
|
||||||
# RECFLARE_SUBDOMAINS (a JSON object) or env.json's "subdomains".
|
# RECFLARE_DOMAIN wins and skips the file. Per-app subdomain overrides come from
|
||||||
if [ -n "${RECFLARE_DOMAIN:-}" ]; then
|
# RECFLARE_SUBDOMAINS (a JSON object, e.g. {"playersettings":"settings"}).
|
||||||
DOMAIN="$RECFLARE_DOMAIN"
|
if [ -z "${RECFLARE_DOMAIN:-}" ]; then
|
||||||
SUBDOMAINS_JSON=${RECFLARE_SUBDOMAINS:-}
|
ENV_FILE="$(git rev-parse --show-toplevel)/.env"
|
||||||
[ -n "$SUBDOMAINS_JSON" ] || SUBDOMAINS_JSON='{}'
|
if [ -f "$ENV_FILE" ]; then
|
||||||
else
|
set -a
|
||||||
ENV_JSON="$(git rev-parse --show-toplevel)/env.json"
|
. "$ENV_FILE"
|
||||||
if [ ! -f "$ENV_JSON" ]; then
|
set +a
|
||||||
echo "error: set RECFLARE_DOMAIN or create $ENV_JSON (copy env.example.json)" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
DOMAIN=$(jq -r '.domain' "$ENV_JSON")
|
|
||||||
SUBDOMAINS_JSON=$(jq -c '.subdomains // {}' "$ENV_JSON")
|
|
||||||
fi
|
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")
|
DIR=$(basename "$PWD")
|
||||||
# Per-app subdomain override, falling back to the worker's directory name.
|
# Per-app subdomain override, falling back to the worker's directory name.
|
||||||
SUBDOMAIN=$(printf '%s' "$SUBDOMAINS_JSON" | jq -r --arg d "$DIR" '.[$d] // $d')
|
SUBDOMAIN=$(printf '%s' "$SUBDOMAINS_JSON" | jq -r --arg d "$DIR" '.[$d] // $d')
|
||||||
|
|||||||
Reference in New Issue
Block a user