## Major Changes **Deployment Manifest (k8s/local/deployment.yaml):** - Switch from PHP 8.2 to PHP 8.3 (matches production Dockerfile) - Add PHP_EXTENSIONS env var for intl, pdo_pgsql, pgsql, redis, gd, zip, bcmath - Set ABSOLUTE_APACHE_DOCUMENT_ROOT to /var/www/html/public - Remove init container (Sail-like approach: composer runs in main container) - Add composer install, npm install, and npm build to startup script - Use TCP connection checks instead of pg_isready/redis-cli (not in image) - Increase health check delays and failure thresholds for slower startup **Makefile:** - Read DB_USERNAME, DB_PASSWORD, DB_DATABASE from .env (not hardcoded) - PostgreSQL credentials now match .env for consistent auth **DNS Setup Script:** - Add scripts/setup-local-dns.sh for one-time dnsmasq configuration - Idempotent script that's safe to run multiple times - Works on macOS with Homebrew dnsmasq ## Architecture Now fully Sail-like: - Code volume-mounted from worktree (instant changes) - Composer/npm run inside container at startup - No pre-installation needed on host - Each worktree = isolated k8s namespace - Database credentials from .env (like Sail) ## Testing Startup sequence verified: 1. Wait for PostgreSQL + Redis 2. Composer install 3. npm install + build 4. Migrations 5. Cache clearing 6. Apache starts 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
106 lines
2.9 KiB
Bash
Executable File
106 lines
2.9 KiB
Bash
Executable File
#!/bin/bash
|
||
#
|
||
# Local DNS Setup for K8s Development
|
||
#
|
||
# This script configures *.cannabrands.test to resolve to 127.0.0.1
|
||
# Run once per developer machine. Safe to run multiple times (idempotent).
|
||
#
|
||
# Requirements: dnsmasq installed via Homebrew
|
||
#
|
||
|
||
set -e
|
||
|
||
echo ""
|
||
echo "🌐 Local DNS Setup for *.cannabrands.test"
|
||
echo "=========================================="
|
||
echo ""
|
||
|
||
# Check if running on macOS
|
||
if [[ "$(uname)" != "Darwin" ]]; then
|
||
echo "❌ Error: This script is for macOS only"
|
||
exit 1
|
||
fi
|
||
|
||
# Check if dnsmasq is installed
|
||
if ! command -v dnsmasq &> /dev/null; then
|
||
echo "❌ Error: dnsmasq not found"
|
||
echo " Install with: brew install dnsmasq"
|
||
exit 1
|
||
fi
|
||
|
||
# 1. Configure dnsmasq
|
||
echo "📝 Step 1/4: Configuring dnsmasq..."
|
||
DNSMASQ_CONF="/opt/homebrew/etc/dnsmasq.d/cannabrands.conf"
|
||
|
||
if [[ -f "$DNSMASQ_CONF" ]]; then
|
||
echo " ℹ️ Config already exists: $DNSMASQ_CONF"
|
||
echo " Current content: $(cat $DNSMASQ_CONF)"
|
||
else
|
||
sudo mkdir -p /opt/homebrew/etc/dnsmasq.d
|
||
echo 'address=/.cannabrands.test/127.0.0.1' | sudo tee "$DNSMASQ_CONF" > /dev/null
|
||
echo " ✅ Created: $DNSMASQ_CONF"
|
||
fi
|
||
|
||
# 2. Restart dnsmasq
|
||
echo ""
|
||
echo "🔄 Step 2/4: Restarting dnsmasq service..."
|
||
sudo brew services restart dnsmasq
|
||
sleep 2 # Give dnsmasq time to start
|
||
|
||
# Check if dnsmasq is running
|
||
if brew services list | grep -q "dnsmasq.*started"; then
|
||
echo " ✅ dnsmasq is running"
|
||
else
|
||
echo " ⚠️ Warning: dnsmasq may not be running properly"
|
||
echo " Check with: brew services list"
|
||
fi
|
||
|
||
# 3. Configure macOS resolver
|
||
echo ""
|
||
echo "📝 Step 3/4: Configuring macOS resolver..."
|
||
RESOLVER_CONF="/etc/resolver/cannabrands.test"
|
||
|
||
if [[ -f "$RESOLVER_CONF" ]]; then
|
||
echo " ℹ️ Resolver already exists: $RESOLVER_CONF"
|
||
echo " Current content: $(cat $RESOLVER_CONF)"
|
||
else
|
||
sudo mkdir -p /etc/resolver
|
||
echo 'nameserver 127.0.0.1' | sudo tee "$RESOLVER_CONF" > /dev/null
|
||
echo " ✅ Created: $RESOLVER_CONF"
|
||
fi
|
||
|
||
# 4. Flush DNS cache
|
||
echo ""
|
||
echo "🧹 Step 4/4: Flushing macOS DNS cache..."
|
||
sudo killall -HUP mDNSResponder 2>/dev/null || true
|
||
echo " ✅ DNS cache flushed"
|
||
|
||
# Test DNS resolution
|
||
echo ""
|
||
echo "🧪 Testing DNS resolution..."
|
||
sleep 1 # Give resolver time to pick up changes
|
||
|
||
if ping -c 1 -W 2 test.cannabrands.test &>/dev/null; then
|
||
echo " ✅ SUCCESS! test.cannabrands.test resolves to 127.0.0.1"
|
||
echo ""
|
||
echo "✅ DNS Setup Complete!"
|
||
echo ""
|
||
echo "All *.cannabrands.test domains now resolve to 127.0.0.1"
|
||
echo "You can now use: make k-dev in any worktree"
|
||
else
|
||
echo " ⚠️ Warning: DNS test failed"
|
||
echo ""
|
||
echo "Troubleshooting:"
|
||
echo "1. Check dnsmasq: brew services list"
|
||
echo "2. Test manually: dig test.cannabrands.test"
|
||
echo "3. Check config: cat $DNSMASQ_CONF"
|
||
echo "4. Check resolver: cat $RESOLVER_CONF"
|
||
echo ""
|
||
echo "If issues persist, try:"
|
||
echo " - Restart your terminal"
|
||
echo " - Restart your Mac"
|
||
exit 1
|
||
fi
|
||
|
||
echo ""
|