Compare commits

..

No commits in common. "main" and "main" have entirely different histories.
main ... main

7 changed files with 5325 additions and 4156 deletions

3
.gitignore vendored
View File

@ -13,6 +13,3 @@
# Keep the root pb_migrations folder tracked (empty placeholder for production)
!/pb_migrations/.gitkeep
.yarn

Binary file not shown.

View File

@ -1,15 +1,8 @@
import PocketBase from 'pocketbase';
import { reachableUrl } from '~/lib/local-url';
const envUrl = (import.meta.env.VITE_POCKETBASE_URL ?? '').trim();
// VITE_ vars are inlined at build time, so a production image built without --build-arg VITE_POCKETBASE_URL must fail loudly
if (!envUrl && import.meta.env.PROD) {
throw new Error('VITE_POCKETBASE_URL is not set. Pass it as a --build-arg when building the Docker image; setting it at runtime has no effect.');
}
// Defaults to the local PocketBase dev server when VITE_POCKETBASE_URL is unset
const rawUrl = envUrl || 'http://127.0.0.1:8099';
const rawUrl = (import.meta.env.VITE_POCKETBASE_URL ?? '').trim() || 'http://127.0.0.1:8099';
// Ensure URL always has a protocol so PocketBase SDK treats it as absolute
const pbUrl = rawUrl.startsWith('http') ? rawUrl : `https://${rawUrl}`;

View File

@ -1,28 +1,11 @@
#!/bin/bash
set -euo pipefail
set -e
REGISTRY="registry.digitalocean.com/thob-blr1"
SHA=$(git rev-parse --short=10 HEAD)
# Load .env if present, so VITE_* don't have to be exported by hand.
if [ -f .env ]; then
echo "Loading build vars from .env"
set -a
# shellcheck disable=SC1091
. ./.env
set +a
fi
# VITE_ vars are inlined into the client bundle at BUILD time. If they are empty
# here, the app ships with a broken PocketBase URL (https://api/...) that fails
# in the browser as a DNS error resembling CORS. Refuse to build.
: "${VITE_POCKETBASE_URL:?VITE_POCKETBASE_URL is not set — export it or add it to .env}"
: "${VITE_FRONTEND_URL:?VITE_FRONTEND_URL is not set — export it or add it to .env}"
echo "Building commit: $SHA"
echo " VITE_POCKETBASE_URL=$VITE_POCKETBASE_URL"
echo " VITE_FRONTEND_URL=$VITE_FRONTEND_URL"
# Login
doctl registry login
@ -31,25 +14,13 @@ doctl registry login
echo "Building AR App..."
docker buildx build \
--platform linux/amd64 \
--build-arg "VITE_POCKETBASE_URL=$VITE_POCKETBASE_URL" \
--build-arg "VITE_FRONTEND_URL=$VITE_FRONTEND_URL" \
--build-arg VITE_POCKETBASE_URL=$VITE_POCKETBASE_URL \
--build-arg VITE_FRONTEND_URL=$VITE_FRONTEND_URL \
-f Dockerfile \
--load \
-t "$REGISTRY/ar:$SHA" \
-t "$REGISTRY/ar:latest" .
-t $REGISTRY/ar:$SHA \
-t $REGISTRY/ar:latest .
docker push $REGISTRY/ar:$SHA
docker push $REGISTRY/ar:latest
# Verify the URL actually made it into the client bundle before pushing.
echo "Verifying baked-in PocketBase URL..."
PB_HOST=$(echo "$VITE_POCKETBASE_URL" | sed -e 's#^https\?://##' -e 's#/.*$##')
if ! docker run --rm --entrypoint sh "$REGISTRY/ar:$SHA" \
-c "grep -rq '$PB_HOST' /app/build/client"; then
echo "❌ Build verification failed: '$PB_HOST' not found in the client bundle."
echo " The image was NOT pushed."
exit 1
fi
echo "✅ Verified: $PB_HOST is baked into the client bundle"
docker push "$REGISTRY/ar:$SHA"
docker push "$REGISTRY/ar:latest"
echo "✅ All images built and pushed successfully (tag: $SHA)"
echo "✅ All images built and pushed successfully"

View File

@ -79,10 +79,9 @@ services:
- VITE_POCKETBASE_URL=${VITE_POCKETBASE_URL:-https://pb.ar.thob.studio}
expose:
- "3000"
# NOTE: VITE_* vars are inlined into the client bundle at BUILD time by Vite.
# Setting them here has NO effect on the pulled image — they must be passed
# as --build-arg in build-and-push.sh. Only server-side vars belong below.
environment:
- VITE_POCKETBASE_URL=${VITE_POCKETBASE_URL:-https://pb.ar.thob.studio}
- VITE_FRONTEND_URL=${VITE_FRONTEND_URL:-https://ar.thob.studio}
- INTERNAL_POCKETBASE_URL=http://ar-pb:8090
depends_on:
- pocketbase
@ -90,9 +89,6 @@ services:
- traefik
labels:
- "wud.watch=true"
# Required: the :latest tag doesn't change, so wud must compare digests
# to notice a new image was pushed to the same tag.
- "wud.watch.digest=true"
- "traefik.enable=true"
- "traefik.docker.network=traefik"
- "traefik.http.routers.ar-app.rule=Host(`ar.thob.studio`)"

1546
package-lock.json generated

File diff suppressed because it is too large Load Diff

7868
yarn.lock

File diff suppressed because it is too large Load Diff