|
| 1 | +#!/usr/bin/env bash |
| 2 | + |
| 3 | +# Runs once when the container is first created. |
| 4 | + |
| 5 | +set -euo pipefail |
| 6 | + |
| 7 | +REPO_ROOT="$(cd "$(dirname "$0")/.." && pwd)" |
| 8 | +export FLUXER_CONFIG="${FLUXER_CONFIG:-$REPO_ROOT/config/config.json}" |
| 9 | + |
| 10 | +GREEN='\033[0;32m' |
| 11 | +NC='\033[0m' |
| 12 | +info() { printf "%b\n" "${GREEN}[devcontainer]${NC} $1"; } |
| 13 | + |
| 14 | +info "Installing pnpm dependencies..." |
| 15 | +pnpm install |
| 16 | + |
| 17 | +# Codegen outputs (e.g. MasterZodSchema.generated.tsx) are gitignored. |
| 18 | +info "Generating config schema..." |
| 19 | +pnpm --filter @fluxer/config generate |
| 20 | + |
| 21 | +if [ ! -f "$FLUXER_CONFIG" ]; then |
| 22 | + info "Creating config from development template..." |
| 23 | + cp "$REPO_ROOT/config/config.dev.template.json" "$FLUXER_CONFIG" |
| 24 | +fi |
| 25 | + |
| 26 | +# Point services at Docker Compose hostnames and adjust settings that differ |
| 27 | +# from the default dev template. |
| 28 | +info "Patching config for Docker Compose networking..." |
| 29 | +jq ' |
| 30 | + # rspack defaults public_scheme to "https" when unset |
| 31 | + .domain.public_scheme = "http" | |
| 32 | + # Relative path so the app works on any hostname (localhost, 127.0.0.1, etc.) |
| 33 | + .app_public.bootstrap_api_endpoint = "/api" | |
| 34 | +
|
| 35 | + .internal.kv = "redis://valkey:6379/0" | |
| 36 | +
|
| 37 | + .integrations.search.url = "http://meilisearch:7700" | |
| 38 | + .integrations.search.api_key = "fluxer-devcontainer-meili-master-key" | |
| 39 | +
|
| 40 | + # Credentials must match .devcontainer/livekit.yaml |
| 41 | + .integrations.voice.url = "ws://livekit:7880" | |
| 42 | + .integrations.voice.webhook_url = "http://app:49319/api/webhooks/livekit" | |
| 43 | + .integrations.voice.api_key = "fluxer-devcontainer-key" | |
| 44 | + .integrations.voice.api_secret = "fluxer-devcontainer-secret-key-00000000" | |
| 45 | +
|
| 46 | + .integrations.email.smtp.host = "mailpit" | |
| 47 | + .integrations.email.smtp.port = 1025 | |
| 48 | +
|
| 49 | + .services.nats.core_url = "nats://nats-core:4222" | |
| 50 | + .services.nats.jetstream_url = "nats://nats-jetstream:4223" | |
| 51 | +
|
| 52 | + # Bluesky OAuth requires HTTPS + loopback IPs (RFC 8252), incompatible with |
| 53 | + # the HTTP-only devcontainer setup. |
| 54 | + .auth.bluesky.enabled = false |
| 55 | +' "$FLUXER_CONFIG" > "$FLUXER_CONFIG.tmp" && mv "$FLUXER_CONFIG.tmp" "$FLUXER_CONFIG" |
| 56 | + |
| 57 | +info "Running bootstrap..." |
| 58 | +"$REPO_ROOT/scripts/dev_bootstrap.sh" |
| 59 | + |
| 60 | +info "Pre-compiling Erlang gateway dependencies..." |
| 61 | +(cd "$REPO_ROOT/fluxer_gateway" && rebar3 compile) || { |
| 62 | + info "Gateway pre-compilation failed (non-fatal, will compile on first start)" |
| 63 | +} |
| 64 | + |
| 65 | +info "Devcontainer setup complete." |
| 66 | +info "" |
| 67 | +info " Start all dev processes: process-compose -f .devcontainer/process-compose.yml up" |
| 68 | +info " Open the app: http://127.0.0.1:48763" |
| 69 | +info " Dev email inbox: http://127.0.0.1:48763/mailpit/" |
| 70 | +info "" |
0 commit comments