Add pre-built frontend Docker approach - workaround for Zscaler proxy
Corporate proxy (Zscaler) causes npm to fail inside Docker builds with 'Exit handler never called' error. This approach builds frontend on host where npm works, then copies pre-built dist/ into Docker image. New files: - Dockerfile.prebuilt: Single-stage build, copies frontend/dist - docker-compose.prebuilt.yml: Uses Dockerfile.prebuilt - .dockerignore.prebuilt: Allows frontend/dist to be included - start-docker-quick.sh: Quick restart without rebuild - DOCKER-PREBUILT-APPROACH.md: Documents workaround and comparison Benefits: - Builds in 2-3 minutes (not 15+) - Works behind corporate proxy - Simpler to debug - Faster iteration Trade-off: Requires npm on host, two-step build process For production: CI/CD builds frontend + image, pushes to registry
This commit is contained in:
75
start-docker-quick.sh
Normal file
75
start-docker-quick.sh
Normal file
@@ -0,0 +1,75 @@
|
||||
#!/bin/bash
|
||||
# Quick start for ShopDB Docker - skips rebuild if images exist
|
||||
# Use this for daily restarts after initial build
|
||||
|
||||
set -e
|
||||
|
||||
echo "==> ShopDB Docker - Quick Start"
|
||||
echo ""
|
||||
|
||||
# Check prerequisites
|
||||
if [ ! -f .env ]; then
|
||||
echo "ERROR: .env file not found"
|
||||
echo "Copy .env.docker-dev to .env first:"
|
||||
echo " cp .env.docker-dev .env"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check if API image exists
|
||||
if ! docker images | grep -q "flask-shopdb-api"; then
|
||||
echo "ERROR: Docker images not built yet"
|
||||
echo "Run this first: docker compose build"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Start services (no rebuild)
|
||||
echo "==> Starting services..."
|
||||
docker compose -f docker-compose.yml -f docker-compose.backup.yml --profile backup up -d
|
||||
|
||||
# Wait for database
|
||||
echo "==> Waiting for database..."
|
||||
sleep 10
|
||||
|
||||
# Check status
|
||||
docker compose ps
|
||||
|
||||
# Initialize if needed
|
||||
echo ""
|
||||
echo "==> Checking database state..."
|
||||
if docker compose exec -T api flask db current 2>&1 | grep -q "Can't locate revision"; then
|
||||
echo "==> Running migrations..."
|
||||
docker compose exec api flask db upgrade
|
||||
fi
|
||||
|
||||
# Check plugins
|
||||
echo ""
|
||||
echo "==> Checking plugins..."
|
||||
PLUGIN_COUNT=$(docker compose exec -T api flask plugin list 2>/dev/null | grep -c "^\s\+\w" || echo "0")
|
||||
|
||||
if [ "$PLUGIN_COUNT" -lt 5 ]; then
|
||||
echo "==> Installing plugins..."
|
||||
docker compose exec api bash /app/scripts/bootstrap-plugins.sh
|
||||
else
|
||||
echo "==> Plugins already installed ($PLUGIN_COUNT found)"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "===================================="
|
||||
echo "ShopDB is running!"
|
||||
echo "===================================="
|
||||
echo ""
|
||||
echo "Access: https://localhost:5001"
|
||||
echo ""
|
||||
echo "Services:"
|
||||
echo " - MySQL Database (internal)"
|
||||
echo " - Flask API (https://localhost:5001)"
|
||||
echo " - Backup Store (isolated)"
|
||||
echo " - Backup Watcher (polls every 30s)"
|
||||
echo ""
|
||||
echo "View logs:"
|
||||
echo " docker compose logs -f api"
|
||||
echo " docker compose logs -f backup-watcher"
|
||||
echo ""
|
||||
echo "Stop:"
|
||||
echo " docker compose down"
|
||||
echo ""
|
||||
Reference in New Issue
Block a user