Update deploy script: TM files from git, fix orphan containers

- Removed old import_reference_files.py step from --init (TM/ref files
  are now tracked in git, no separate import needed)
- Added file count verification during --init to confirm TM files arrived
- Added --remove-orphans to docker compose commands to prevent stale
  containers serving old builds
- Standard deploy now does compose down before up to ensure clean restart

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
DJP 2026-04-10 19:11:09 -04:00
parent 521f0447bd
commit b0055c53ab

View file

@ -93,9 +93,9 @@ if [ "$INIT" = true ]; then
log ".env already exists, skipping creation"
fi
# Create storage directories
log "Creating storage directories..."
mkdir -p storage/amazon/{tm,ref}
# Storage directories are now tracked in git (storage/amazon/tm + ref)
# Just ensure the base directory exists for runtime uploads
mkdir -p storage
# Build all images
log "Building all Docker images (this may take a few minutes)..."
@ -125,16 +125,13 @@ if [ "$INIT" = true ]; then
log "Running database migrations..."
$COMPOSE exec -T backend alembic upgrade head
# Import reference files (run on host since files are local)
if [ -d "../Agent build + supporting JSONs/JSON REFS and TMs" ]; then
log "Importing reference and TM files..."
python3 seed/import_reference_files.py \
--source "../Agent build + supporting JSONs/JSON REFS and TMs" \
--target storage/amazon
else
warn "Reference files source directory not found at ../Agent build + supporting JSONs/JSON REFS and TMs"
warn "You can import them manually later:"
warn " python3 seed/import_reference_files.py --source /path/to/JSON_REFS_and_TMs --target storage/amazon"
# TM and reference files are now tracked in git — no import step needed.
# Verify they arrived via git pull:
TM_COUNT=$(find storage/amazon/tm -name '*.json' 2>/dev/null | wc -l)
REF_COUNT=$(find storage/amazon/ref -name '*.json' 2>/dev/null | wc -l)
log "Found $TM_COUNT TM files and $REF_COUNT reference files in storage/amazon/"
if [ "$TM_COUNT" -eq 0 ]; then
warn "No TM files found! Check that git pulled storage/amazon/tm/ correctly."
fi
# Seed database
@ -144,7 +141,7 @@ if [ "$INIT" = true ]; then
# Start all remaining services
log "Starting all services..."
$COMPOSE up -d
$COMPOSE up -d --remove-orphans
# ---------------------------------------------------------------
# Apache configuration
@ -240,8 +237,9 @@ $COMPOSE up -d backend
sleep 5
$COMPOSE exec -T backend alembic upgrade head
# Restart all services
# Restart all services (remove orphans to avoid stale containers)
log "Restarting all services..."
$COMPOSE down --remove-orphans
$COMPOSE up -d
# Health check