3.8 KiB · text History 8b74183
set shell := ["bash", "-cu"]

assets_dir := "assets"
tailwind := "./node_modules/.bin/tailwindcss"
esbuild := "./node_modules/.bin/esbuild"
css_in := "f/css/style.css"
css_out := "f/css/app.css"
js_in := "f/js/src.js"
js_out := "f/js/app.js"

# Default: list available recipes
default:
    @just --list

# One-shot CSS + JS build + sync vendored webfonts/fonts
assets: webfonts js
    cd {{assets_dir}} && {{tailwind}} -c tailwind.config.js -i {{css_in}} -o {{css_out}}

# Bundle + minify JS (src.js -> app.js), mirroring the Dockerfile assets stage
js:
    cd {{assets_dir}} && {{esbuild}} {{js_in}} --bundle --minify --outfile={{js_out}}

# Watch CSS for changes; webfonts only need to be synced once per dep change
watch: webfonts js
    cd {{assets_dir}} && {{tailwind}} -c tailwind.config.js -i {{css_in}} -o {{css_out}} --watch

# Copy vendored fonts into the served /assets tree.
# FontAwesome's CSS uses url(../webfonts/...), which resolves to
# /assets/f/webfonts/* once app.css is served from /assets/f/css/.
webfonts:
    mkdir -p {{assets_dir}}/f/webfonts
    cp -u {{assets_dir}}/node_modules/@fortawesome/fontawesome-free/webfonts/*.woff2 {{assets_dir}}/f/webfonts/
    cp -u {{assets_dir}}/node_modules/@fortawesome/fontawesome-free/webfonts/*.ttf {{assets_dir}}/f/webfonts/

# Install JS deps (run once after cloning)
deps:
    cd {{assets_dir}} && npm install

# Apply pending DB migrations
migrate:
    cargo run -p migration -- up

# Run the webservice (auto-migrates by default)
serve:
    cargo run --bin webservice

# Run a categorizer worker. Usage: just worker thumbnail | ocr | describe | extract_tags
worker kind:
    cargo run --bin queue-worker -- --kind {{kind}}

# Download ocrs detection + recognition models into ./models/ and print the
# env vars to set so the OCR worker can find them.
ocr-models:
    mkdir -p models
    [ -f models/text-detection.rten ] || curl -L -o models/text-detection.rten https://ocrs-models.s3-accelerate.amazonaws.com/text-detection.rten
    [ -f models/text-recognition.rten ] || curl -L -o models/text-recognition.rten https://ocrs-models.s3-accelerate.amazonaws.com/text-recognition.rten
    @echo ""
    @echo "Set these env vars before running 'just worker ocr':"
    @echo "  export OCRS_DETECTION_MODEL=$PWD/models/text-detection.rten"
    @echo "  export OCRS_RECOGNITION_MODEL=$PWD/models/text-recognition.rten"

# Generate an invite token. Usage: just invite [days]
invite days="7":
    cargo run --bin registration-token -- create --days {{days}}

# Manage users. Usage: just user list | just user "show alice" | just user "reset-password alice --generate"
user *args:
    cargo run --bin user-admin -- {{args}}

# Reset a user's password, prompting for the new one. Usage: just reset-password alice
reset-password user:
    cargo run --bin user-admin -- reset-password {{user}}

# Lint + test (unit only)
check:
    cargo check --bins --lib
    cargo test --lib

# Integration tests against the local Postgres (compose stack must be up)
test-integration:
    DMS_TEST_DATABASE_URL=postgres://dms_user:dms_password@localhost:5433/dms cargo test --test search_integration -- --nocapture

# Build the runtime image (multi-stage: assets + cargo release + debian-slim).
build-image:
    podman compose build webservice

# Bring up the full stack (postgres, rabbitmq, webservice, every worker).
up:
    podman compose up -d

down:
    podman compose down

# Tail webservice logs
logs:
    podman compose logs -f webservice

# Bootstrap an invite token from inside the running webservice container.
invite-in-pod days="7":
    podman compose exec webservice dms-registration-token create --days {{days}}

# Manage users inside the running webservice container.
# Usage: just user-in-pod "reset-password alice --generate"
user-in-pod *args:
    podman compose exec webservice dms-user-admin {{args}}