98 lines
2.4 KiB
Bash
Executable File
98 lines
2.4 KiB
Bash
Executable File
#!/bin/zsh # Match your shell
|
|
set -e
|
|
|
|
echo "Fixing NoCap W.Y.A. deployment..."
|
|
|
|
# 1. Update docker-compose.yml (no version, project name, M1 tweaks)
|
|
cat > docker-compose.yml <<'DOCS'
|
|
name: nocapwya # Explicit project name (ignores dir spaces)
|
|
services:
|
|
db:
|
|
image: postgis/postgis:15-3.4-alpine # Alpine for M1 arm64 efficiency
|
|
container_name: nocapwya-db
|
|
environment:
|
|
POSTGRES_DB: wya
|
|
POSTGRES_USER: wya
|
|
POSTGRES_PASSWORD: wya
|
|
volumes:
|
|
- pg_data:/var/lib/postgresql/data
|
|
- ./backend/app/init.sql:/docker-entrypoint-initdb.d/init.sql
|
|
restart: unless-stopped
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "pg_isready -U wya -d wya"]
|
|
interval: 10s
|
|
timeout: 5s
|
|
retries: 5
|
|
networks:
|
|
- wya-net
|
|
|
|
backend:
|
|
build:
|
|
context: ./backend
|
|
dockerfile: Dockerfile
|
|
container_name: nocapwya-backend
|
|
ports:
|
|
- "8000:8000"
|
|
volumes:
|
|
- ./data:/data
|
|
depends_on:
|
|
db:
|
|
condition: service_healthy
|
|
env_file:
|
|
- .env
|
|
restart: unless-stopped
|
|
networks:
|
|
- wya-net
|
|
|
|
frontend:
|
|
build:
|
|
context: ./frontend
|
|
dockerfile: Dockerfile
|
|
container_name: nocapwya-frontend
|
|
ports:
|
|
- "3000:80"
|
|
volumes:
|
|
- ./data/tiles:/usr/share/nginx/html/tiles:ro
|
|
depends_on:
|
|
- backend
|
|
env_file:
|
|
- .env
|
|
restart: unless-stopped
|
|
networks:
|
|
- wya-net
|
|
|
|
volumes:
|
|
pg_data: # Named volume for persistence
|
|
|
|
networks:
|
|
wya-net:
|
|
driver: bridge
|
|
DOCS
|
|
|
|
# 2. Create .env (add your Mapbox token here; get free from mapbox.com)
|
|
cat > .env <<'ENV'
|
|
# Database (auto from compose)
|
|
# API_BASE_URL=http://localhost:8000 # For frontend if needed
|
|
|
|
# Mapbox (required for maps; replace with your pk.eyJ1Oi... token)
|
|
VITE_MAPBOX_TOKEN=pk.eyJ1OnlvdXJ1c2VybmFtZSIsImEiOiJqbG... # TODO: Update this!
|
|
ENV
|
|
|
|
# 3. Tweak frontend Dockerfile for M1 (use full node if alpine fails)
|
|
if [[ $(uname -m) == "arm64" ]]; then
|
|
sed -i '' 's/node:18-alpine/node:18/' frontend/Dockerfile
|
|
echo "Applied M1 fix to frontend Dockerfile"
|
|
fi
|
|
|
|
# 4. Ensure data dir and perms (M1/macOS volume issues)
|
|
mkdir -p data/tiles
|
|
chmod -R 755 data
|
|
echo "Data dir ready (perms fixed)"
|
|
|
|
# 5. Verify init.sql exists (seed data)
|
|
if [[ ! -f backend/app/init.sql ]]; then
|
|
echo "Warning: init.sql missing—re-run install.sh to regenerate files"
|
|
fi
|
|
|
|
echo "Fixes applied! Now run: docker compose down -v && docker compose up -d --build"
|