All checks were successful
Deploy to Test Environment / deploy-to-test (push) Successful in 19m9s
85 lines
2.8 KiB
Bash
85 lines
2.8 KiB
Bash
#!/bin/bash
|
|
# scripts/dev-entrypoint.sh
|
|
# ============================================================================
|
|
# Development Container Entrypoint
|
|
# ============================================================================
|
|
# This script starts the development server automatically when the container
|
|
# starts, both with VS Code Dev Containers and with plain podman-compose.
|
|
#
|
|
# Services started:
|
|
# - Nginx (proxies Vite 5173 → 3000)
|
|
# - Bugsink (error tracking) on port 8000
|
|
# - Logstash (log aggregation)
|
|
# - Node.js dev server (API + Frontend) on ports 3001 and 5173
|
|
# ============================================================================
|
|
|
|
set -e
|
|
|
|
echo "🚀 Starting Flyer Crawler Dev Container..."
|
|
|
|
# Configure Bugsink HTTPS (ADR-015)
|
|
echo "🔒 Configuring Bugsink HTTPS..."
|
|
mkdir -p /etc/bugsink/ssl
|
|
if [ ! -f "/etc/bugsink/ssl/localhost+2.pem" ]; then
|
|
cd /etc/bugsink/ssl && mkcert localhost 127.0.0.1 ::1 > /dev/null 2>&1
|
|
fi
|
|
|
|
# Create nginx config for Bugsink HTTPS
|
|
cat > /etc/nginx/sites-available/bugsink <<'NGINX_EOF'
|
|
server {
|
|
listen 8443 ssl http2;
|
|
listen [::]:8443 ssl http2;
|
|
server_name localhost;
|
|
|
|
ssl_certificate /etc/bugsink/ssl/localhost+2.pem;
|
|
ssl_certificate_key /etc/bugsink/ssl/localhost+2-key.pem;
|
|
ssl_protocols TLSv1.2 TLSv1.3;
|
|
ssl_ciphers HIGH:!aNULL:!MD5;
|
|
ssl_prefer_server_ciphers on;
|
|
|
|
location / {
|
|
proxy_pass http://127.0.0.1:8000;
|
|
proxy_set_header Host $host;
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
proxy_set_header X-Forwarded-Proto $scheme;
|
|
proxy_redirect off;
|
|
proxy_buffering off;
|
|
client_max_body_size 20M;
|
|
}
|
|
}
|
|
NGINX_EOF
|
|
|
|
ln -sf /etc/nginx/sites-available/bugsink /etc/nginx/sites-enabled/bugsink
|
|
|
|
# Start nginx in background (if installed)
|
|
if command -v nginx &> /dev/null; then
|
|
echo "🌐 Starting nginx (HTTPS: Vite 5173 → 443, Bugsink 8000 → 8443)..."
|
|
nginx &
|
|
fi
|
|
|
|
# Start Bugsink in background
|
|
echo "📊 Starting Bugsink error tracking..."
|
|
/usr/local/bin/start-bugsink.sh > /var/log/bugsink/server.log 2>&1 &
|
|
|
|
# Start Logstash in background
|
|
echo "📝 Starting Logstash..."
|
|
/usr/share/logstash/bin/logstash -f /etc/logstash/conf.d/bugsink.conf > /var/log/logstash/logstash.log 2>&1 &
|
|
|
|
# Wait a few seconds for services to initialize
|
|
sleep 3
|
|
|
|
# Change to app directory
|
|
cd /app
|
|
|
|
# Start development server
|
|
echo "💻 Starting development server..."
|
|
echo " - Frontend: https://localhost (nginx HTTPS → Vite on 5173)"
|
|
echo " - Backend API: http://localhost:3001"
|
|
echo " - Bugsink: https://localhost:8443 (nginx HTTPS → Bugsink on 8000)"
|
|
echo " - Note: Accept the self-signed certificate warnings in your browser"
|
|
echo ""
|
|
|
|
# Run npm dev server (this will block and keep container alive)
|
|
exec npm run dev:container
|