Something went wrong. Try again.
[ALPHA] an open source, atproto-powered, web-based 2D/3D graphing calculator cartesium.org
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162#!/bin/shset -eu
usage() { cat >&2 <<'EOF'Usage: ./deploy.sh test|prod
Targets: test test.example.org/ -> /path/to/cartesium-test:2222 prod example.org/ -> /path/to/cartesium-prod:3333
Set CARTESIUM_DEPLOY_REMOTE to the SSH destination, for example: CARTESIUM_DEPLOY_REMOTE=root@your-host ./deploy.sh testEOF}
TARGET=${1:-}REMOTE=${CARTESIUM_DEPLOY_REMOTE:?Set CARTESIUM_DEPLOY_REMOTE to the SSH destination}
case "$TARGET" in test) BASE_PATH= ORIGIN=https://test.example.org HOST_PORT=2222 REMOTE_DIR=/path/to/cartesium-test COMPOSE_PROJECT=cartesium-test ;; prod) BASE_PATH= ORIGIN=https://example.org HOST_PORT=3333 REMOTE_DIR=/path/to/cartesium-prod COMPOSE_PROJECT=cartesium-prod ;; *) usage exit 2 ;;esac
REPO_ROOT=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)APP_ROOT=$REPO_ROOT/apps/web
echo "Preparing $REMOTE:$REMOTE_DIR..."ssh "$REMOTE" "install -d -m 0755 '$REMOTE_DIR'"rsync -avz "$APP_ROOT/.env.example" "$REMOTE:$REMOTE_DIR/"ssh "$REMOTE" \"test -f '$REMOTE_DIR/.env' || { echo 'Missing $REMOTE_DIR/.env.' >&2; echo 'Run: cd $REMOTE_DIR && cp .env.example .env, then edit it.' >&2; exit 1; }"
echo "Building Cartesium for $TARGET ($ORIGIN)..."CARTESIUM_BASE_PATH="$BASE_PATH" npm --prefix "$APP_ROOT" run build
rsync -avz "$APP_ROOT/build/" "$REMOTE:$REMOTE_DIR/build/"rsync -avz \"$APP_ROOT/Dockerfile" \"$APP_ROOT/compose.yaml" \"$APP_ROOT/.dockerignore" \"$REMOTE:$REMOTE_DIR/"
ssh "$REMOTE" \"cd '$REMOTE_DIR' && CARTESIUM_ORIGIN='$ORIGIN' CARTESIUM_HOST_PORT='$HOST_PORT' docker compose -p '$COMPOSE_PROJECT' up --detach --build --remove-orphans --wait"