Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 16e1c8ee40 | |||
| 71c0671a25 | |||
| 26ec688fec | |||
|
|
d085cbca26 | ||
|
|
a7836f0c4b | ||
|
|
21371410d4 | ||
|
|
e29ad75c55 | ||
| 24b0c5889f | |||
| 4e69cfe270 |
3
.gitignore
vendored
3
.gitignore
vendored
@ -13,3 +13,6 @@
|
|||||||
|
|
||||||
# Keep the root pb_migrations folder tracked (empty placeholder for production)
|
# Keep the root pb_migrations folder tracked (empty placeholder for production)
|
||||||
!/pb_migrations/.gitkeep
|
!/pb_migrations/.gitkeep
|
||||||
|
|
||||||
|
|
||||||
|
.yarn
|
||||||
|
|||||||
Binary file not shown.
@ -1,8 +1,15 @@
|
|||||||
import PocketBase from 'pocketbase';
|
import PocketBase from 'pocketbase';
|
||||||
import { reachableUrl } from '~/lib/local-url';
|
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
|
// Defaults to the local PocketBase dev server when VITE_POCKETBASE_URL is unset
|
||||||
const rawUrl = (import.meta.env.VITE_POCKETBASE_URL ?? '').trim() || 'http://127.0.0.1:8099';
|
const rawUrl = envUrl || 'http://127.0.0.1:8099';
|
||||||
// Ensure URL always has a protocol so PocketBase SDK treats it as absolute
|
// Ensure URL always has a protocol so PocketBase SDK treats it as absolute
|
||||||
const pbUrl = rawUrl.startsWith('http') ? rawUrl : `https://${rawUrl}`;
|
const pbUrl = rawUrl.startsWith('http') ? rawUrl : `https://${rawUrl}`;
|
||||||
|
|
||||||
|
|||||||
@ -1,11 +1,28 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
set -e
|
set -euo pipefail
|
||||||
|
|
||||||
REGISTRY="registry.digitalocean.com/thob-blr1"
|
REGISTRY="registry.digitalocean.com/thob-blr1"
|
||||||
SHA=$(git rev-parse --short=10 HEAD)
|
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 "Building commit: $SHA"
|
||||||
|
echo " VITE_POCKETBASE_URL=$VITE_POCKETBASE_URL"
|
||||||
|
echo " VITE_FRONTEND_URL=$VITE_FRONTEND_URL"
|
||||||
|
|
||||||
# Login
|
# Login
|
||||||
doctl registry login
|
doctl registry login
|
||||||
@ -14,13 +31,25 @@ doctl registry login
|
|||||||
echo "Building AR App..."
|
echo "Building AR App..."
|
||||||
docker buildx build \
|
docker buildx build \
|
||||||
--platform linux/amd64 \
|
--platform linux/amd64 \
|
||||||
--build-arg VITE_POCKETBASE_URL=$VITE_POCKETBASE_URL \
|
--build-arg "VITE_POCKETBASE_URL=$VITE_POCKETBASE_URL" \
|
||||||
--build-arg VITE_FRONTEND_URL=$VITE_FRONTEND_URL \
|
--build-arg "VITE_FRONTEND_URL=$VITE_FRONTEND_URL" \
|
||||||
-f Dockerfile \
|
-f Dockerfile \
|
||||||
--load \
|
--load \
|
||||||
-t $REGISTRY/ar:$SHA \
|
-t "$REGISTRY/ar:$SHA" \
|
||||||
-t $REGISTRY/ar:latest .
|
-t "$REGISTRY/ar:latest" .
|
||||||
docker push $REGISTRY/ar:$SHA
|
|
||||||
docker push $REGISTRY/ar:latest
|
|
||||||
|
|
||||||
echo "✅ All images built and pushed successfully"
|
# 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)"
|
||||||
|
|||||||
@ -79,9 +79,10 @@ services:
|
|||||||
- VITE_POCKETBASE_URL=${VITE_POCKETBASE_URL:-https://pb.ar.thob.studio}
|
- VITE_POCKETBASE_URL=${VITE_POCKETBASE_URL:-https://pb.ar.thob.studio}
|
||||||
expose:
|
expose:
|
||||||
- "3000"
|
- "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:
|
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
|
- INTERNAL_POCKETBASE_URL=http://ar-pb:8090
|
||||||
depends_on:
|
depends_on:
|
||||||
- pocketbase
|
- pocketbase
|
||||||
@ -89,6 +90,9 @@ services:
|
|||||||
- traefik
|
- traefik
|
||||||
labels:
|
labels:
|
||||||
- "wud.watch=true"
|
- "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.enable=true"
|
||||||
- "traefik.docker.network=traefik"
|
- "traefik.docker.network=traefik"
|
||||||
- "traefik.http.routers.ar-app.rule=Host(`ar.thob.studio`)"
|
- "traefik.http.routers.ar-app.rule=Host(`ar.thob.studio`)"
|
||||||
|
|||||||
1556
package-lock.json
generated
1556
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user