24 files changed
+11
-596
No files matched your search
@@ -2,16 +2,15 @@
|
||||
set -Eeuo pipefail
|
||||
|
||||
usage() {
|
||||
echo "Usage: $0 <business-slug> <domain> [image-tag] [business-name]" >&2
|
||||
echo "Example: $0 blake-heritage blakeheritage.com nextchair:2026-09-04 \"Blake Heritage\"" >&2
|
||||
echo "Usage: $0 <business-slug> <domain> [image-tag]" >&2
|
||||
echo "Example: $0 blake-heritage blakeheritage.com nextchair:2026-09-04" >&2
|
||||
exit 2
|
||||
}
|
||||
|
||||
[[ $# -ge 2 && $# -le 4 ]] || usage
|
||||
[[ $# -ge 2 && $# -le 3 ]] || usage
|
||||
business_slug="$1"
|
||||
domain="$2"
|
||||
image_tag="${3:-nextchair:latest}"
|
||||
business_name="${4:-$business_slug}"
|
||||
repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
stack_root="${NEXTCHAIR_STACK_ROOT:-${repo_root}/stacks}"
|
||||
infra_env="${NEXTCHAIR_INFRA_ENV:-${repo_root}/.env.infra}"
|
||||
@@ -21,7 +20,6 @@ compose_template="${repo_root}/deploy/business-compose.yaml.template"
|
||||
[[ "$business_slug" =~ ^[a-z0-9]+([a-z0-9-]*[a-z0-9])?$ ]] || { echo "Invalid slug: use lowercase letters, numbers, and hyphens." >&2; exit 2; }
|
||||
[[ ${#business_slug} -le 22 ]] || { echo "Invalid slug: maximum length is 22 characters." >&2; exit 2; }
|
||||
[[ "$domain" =~ ^[A-Za-z0-9.-]+$ ]] || { echo "Invalid domain." >&2; exit 2; }
|
||||
[[ "$image_tag" =~ ^[A-Za-z0-9._/@:-]+$ ]] || { echo "Invalid image tag." >&2; exit 2; }
|
||||
[[ -f "$infra_env" ]] || { echo "Missing $infra_env. Copy .env.infra.example first." >&2; exit 1; }
|
||||
[[ -f "$compose_template" ]] || { echo "Missing $compose_template." >&2; exit 1; }
|
||||
[[ ! -e "$stack_dir" ]] || { echo "Stack already exists: $stack_dir" >&2; exit 1; }
|
||||
@@ -76,23 +74,6 @@ $domain {
|
||||
}
|
||||
EOF
|
||||
|
||||
registry_file="$stack_root/registry.json"
|
||||
REGISTRY_FILE="$registry_file" BUSINESS_NAME="$business_name" BUSINESS_SLUG="$business_slug" BUSINESS_DOMAIN="$domain" BUSINESS_IMAGE="$image_tag" node <<'NODE'
|
||||
const fs = require("node:fs");
|
||||
const file = process.env.REGISTRY_FILE;
|
||||
const items = fs.existsSync(file) ? JSON.parse(fs.readFileSync(file, "utf8")) : [];
|
||||
const now = new Date().toISOString();
|
||||
items.push({
|
||||
name: process.env.BUSINESS_NAME,
|
||||
slug: process.env.BUSINESS_SLUG,
|
||||
domain: process.env.BUSINESS_DOMAIN,
|
||||
image: process.env.BUSINESS_IMAGE,
|
||||
createdAt: now,
|
||||
updatedAt: now,
|
||||
});
|
||||
fs.writeFileSync(file, `${JSON.stringify(items, null, 2)}\n`, { mode: 0o600 });
|
||||
NODE
|
||||
|
||||
chmod 600 "$stack_dir/.env"
|
||||
printf '\nCreated Dockge stack: %s\n' "$stack_dir"
|
||||
printf 'Created Caddy route: %s/%s.caddy\n' "$caddy_sites_dir" "$business_slug"
|
||||
|
||||
Reference in new issue
Block a user