Spaces:
Sleeping
Sleeping
| set -euo pipefail | |
| # Helper to create a local env file with secrets and start the docker stack. | |
| # Usage: ./scripts/start_local.sh | |
| ROOT_DIR="$(cd "$(dirname "$0")/.." && pwd)" | |
| ENV_LOCAL="$ROOT_DIR/.env.local" | |
| echo "This helper creates a local .env.local (gitignored) and starts the Docker stack." | |
| read -p "Label mode (hf/openai/mock) [hf]: " LABEL_MODE | |
| LABEL_MODE=${LABEL_MODE:-hf} | |
| read -p "Label model (for hf, e.g. google/flan-t5-large) [google/flan-t5-large]: " LABEL_MODEL | |
| LABEL_MODEL=${LABEL_MODEL:-google/flan-t5-large} | |
| if [ "$LABEL_MODE" = "hf" ]; then | |
| # prompt for HF token | |
| echo "Enter Hugging Face token (will not be echoed):" | |
| read -s HF_TOKEN | |
| echo | |
| else | |
| HF_TOKEN="" | |
| fi | |
| if [ "$LABEL_MODE" = "openai" ]; then | |
| echo "Enter OpenAI API key (will not be echoed):" | |
| read -s OPENAI_API_KEY | |
| echo | |
| else | |
| OPENAI_API_KEY="" | |
| fi | |
| cat > "$ENV_LOCAL" <<EOF | |
| # Local environment file (auto-generated by scripts/start_local.sh) | |
| LABEL_MODE=$LABEL_MODE | |
| LABEL_MODEL=$LABEL_MODEL | |
| HF_TOKEN=$HF_TOKEN | |
| OPENAI_API_KEY=$OPENAI_API_KEY | |
| # keep other defaults | |
| MODEL_DIR=/app/storage/models | |
| HUGGINGFACE_CACHE=/root/.cache/huggingface | |
| DATABASE_URL=postgresql://dark:secret@postgres:5432/darkint | |
| REDIS_URL=redis://redis:6379/0 | |
| SECRET_KEY=change-me | |
| MODEL_STORAGE_PATH=./storage/models | |
| EOF | |
| echo ".env.local created at $ENV_LOCAL" | |
| echo "Starting Docker services (this may take a while on first run)..." | |
| docker compose --env-file "$ENV_LOCAL" up -d postgres redis backend worker | |
| echo "Tailing worker logs (press Ctrl-C to stop)" | |
| docker compose --env-file "$ENV_LOCAL" logs -f worker | |