Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,8 @@ services:
dockerfile: Dockerfile
ports:
- "8787:8787"
volumes:
- ./rust/sync-service/src:/app/src
environment:
- INTERNAL_API_SECRET_KEY=${INTERNAL_API_SECRET_KEY}
- DOCUMENT_PERMISSIONS_SECRET=${DOCUMENT_PERMISSION_JWT_SECRET_KEY}
Expand Down Expand Up @@ -402,10 +404,31 @@ services:
retries: 3
start_period: 10s

# ============================================================================
# rust-builder
# Persistent Rust toolchain container for hot-swap dev rebuilds.
# Source is mounted in; compiled artifacts live in the rust_dev_target volume.
# Usage: just dev-rebuild <service>
# ============================================================================
rust-builder:
image: rust:latest
working_dir: /app
volumes:
- ./rust/cloud-storage:/app
- rust_dev_target:/app/target
- ~/.cargo/registry:/usr/local/cargo/registry
- ~/.cargo/git:/usr/local/cargo/git
environment:
SQLX_OFFLINE: "true"
command: tail -f /dev/null

networks:
services:
driver: bridge
databases:
external: true
auth:
external: true

volumes:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we make this volume external so it can be used across workspaces/worktrees to improve shared caching

rust_dev_target:
4 changes: 4 additions & 0 deletions js/app/packages/app/vite.base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,10 @@ export const createAppViteConfig = (): UserConfigFn => {
host: process.env.TAURI_DEV_HOST || 'localhost',
},
cors: true,
proxy: {
// always redirect root to /app
'^/$': { target: 'http://localhost:3000', rewrite: () => '/app' },
},
Comment on lines +189 to +192

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

FILE="js/app/packages/app/vite.base.ts"

echo "== File exists? =="
ls -la "$FILE"

echo
echo "== Relevant line range (around 160-220) =="
nl -ba "$FILE" | sed -n '160,220p'

echo
echo "== Find PORT usage in file =="
rg -n "PORT" "$FILE" || true

echo
echo "== Find proxy configuration in file =="
rg -n "proxy|rewrite|target" "$FILE"

Repository: macro-inc/macro

Length of output: 266


🏁 Script executed:

#!/bin/bash
set -euo pipefail

FILE="js/app/packages/app/vite.base.ts"

echo "== Relevant line range (160-220) =="
cat -n "$FILE" | sed -n '160,220p'

echo
echo "== PORT usage in file =="
rg -n "PORT" "$FILE" || true

echo
echo "== proxy/rewrite/target usage in file =="
rg -n "(proxy|rewrite|target)" "$FILE"

Repository: macro-inc/macro

Length of output: 2457


🏁 Script executed:

#!/bin/bash
set -euo pipefail
FILE="js/app/packages/app/vite.base.ts"

echo "== Lines around NO_MINIFY =="
rg -n "NO_MINIFY" "$FILE"
echo
# show a window around first occurrence
LINE=$(rg -n "NO_MINIFY" "$FILE" | head -n1 | cut -d: -f1)
START=$((LINE-20))
END=$((LINE+20))
sed -n "${START},${END}p" "$FILE" | cat -n

echo
echo "== Show proxy block context =="
# show around the proxy '^/$' line
PROXYLINE=$(rg -n "'\\^/\\$':|\\^/\\$" "$FILE" | head -n1 | cut -d: -f1)
START=$((PROXYLINE-15))
END=$((PROXYLINE+15))
sed -n "${START},${END}p" "$FILE" | cat -n

Repository: macro-inc/macro

Length of output: 2739


Root proxy hardcodes 3000 despite PORT override
js/app/packages/app/vite.base.ts sets server.port from Number(process.env.PORT || 3000), but the '^/$' proxy target is hardcoded to http://localhost:3000, so / forwards to the wrong port when PORT != 3000.

Suggested fix
@@
-    const NO_MINIFY = process.env.NO_MINIFY === 'true';
+    const NO_MINIFY = process.env.NO_MINIFY === 'true';
+    const DEV_PORT = Number(process.env.PORT || 3000);
@@
-        port: Number(process.env.PORT || 3000),
+        port: DEV_PORT,
@@
-          '^/$': { target: 'http://localhost:3000', rewrite: () => '/app' },
+          '^/$': { target: `http://localhost:${DEV_PORT}`, rewrite: () => '/app' },
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@js/app/packages/app/vite.base.ts` around lines 189 - 192, The proxy target
for the root route '^/$' is hardcoded to http://localhost:3000 while server.port
is derived from Number(process.env.PORT || 3000); update the proxy config so it
uses the same port value instead of 3000. Replace the literal target string in
the proxy entry (the '^/$' mapping) to construct the host using the server port
value (from process.env.PORT or the server.port variable) so that requests
forwarded by the proxy go to the actual configured port.

watch: {
usePolling: true,
interval: 100,
Expand Down
29 changes: 29 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -196,3 +196,32 @@ setup:
destroy:
just infra/stacks/fusionauth-instance/destroy
docker compose down -v

dev-rebuild service:
#!/usr/bin/env bash
set -euo pipefail

container="macro-{{ service }}-1"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this always the container name or will this depend on what worktree/workspace you are in?


if [ "{{ service }}" = "sync_service" ]; then
echo "==> Building sync_service wasm inside container..."
docker exec "$container" worker-build --release
docker restart "$container"
else
bin=$(docker inspect "$container" | jq -r '.[0].Config.Cmd[0]' | xargs basename)

echo "==> Building $bin (incremental)..."
docker compose up rust-builder -d --wait 2>/dev/null || true
docker exec macro-rust-builder-1 cargo build --bin "$bin"

echo "==> Copying binary into $container..."
tmp=$(mktemp)
docker cp "macro-rust-builder-1:/app/target/debug/$bin" "$tmp"
docker cp "$tmp" "$container:/app/out/$bin"
rm "$tmp"

echo "==> Restarting $container..."
docker restart "$container"
fi

echo "==> Done. $container is live with the new binary."
Loading