#!/usr/bin/env bash # DEV gateway on the private network (docs/development/ENVIRONMENTS.md §3). # pnpm dev:gateway # up: generates the Mailpit credentials once, starts faunosteo_dev_gateway # pnpm dev:gateway:stop # down # Serves Mailpit behind basic auth on :54325; the raw ports the # Supabase CLI publishes on 0.0.0.0 (54322 PostgreSQL, 54323 Studio, 54324 Mailpit) are # closed to the LAN by the host firewall rules of ENVIRONMENTS.md §3.2. set -euo pipefail cd "$(dirname "$0")/.." . scripts/dev-env.sh dir=docker/dev-gateway htpasswd="$dir/htpasswd" secret="$dir/mailpit-password" case "${1:-up}" in up) if [ ! -s "$htpasswd" ]; then password="$(openssl rand -base64 18 | tr -d '/+=' | cut -c1-20)" printf 'dev:%s\n' "$(openssl passwd -apr1 "$password")" > "$htpasswd" printf '%s\n' "$password" > "$secret" # Rootless Docker: the container's nginx user maps to a subordinate uid and cannot # read a 600 file of this account; the htpasswd holds only a hash. The clear # password stays 600. chmod 644 "$htpasswd" chmod 600 "$secret" echo "== Mailpit credentials generated: user dev, password in $secret (not committed)" fi docker compose --profile dev up -d dev-gateway echo "== gateway: api $FAUNOSTEO_DEV_API_URL mailpit $FAUNOSTEO_DEV_MAILPIT_URL (user dev, password: cat $secret)" ;; down) docker compose --profile dev rm -sf dev-gateway ;; *) echo "usage: dev-gateway.sh [up|down]" >&2; exit 2 ;; esac