Mercurial
view mrjunejune/deploy.sh @ 267:a78f5986011f
discover bundled production runtimes
Locate Bazel-packaged Copilot and Python binaries by stable suffix instead of hardcoding an external repository prefix.
Co-authored-by: Copilot <[email protected]>
| author | MrJuneJune <me@mrjunejune.com> |
|---|---|
| date | Fri, 07 Aug 2026 12:58:55 -0700 |
| parents | efaf4c63cc94 |
| children | f7b1188d5fb1 |
line wrap: on
line source
#!/usr/bin/env bash set -euo pipefail bazel build -c opt //mrjunejune:mrjunejune_server_bundle bundle="$(realpath bazel-bin/mrjunejune/mrjunejune_server_bundle)" staging="/opt/mrjunejune_server_bundle_new" active="/opt/mrjunejune_server_bundle_active" # Always create staging from an empty directory. Copying into an existing # directory nests the bundle and can promote stale/incomplete runtime files. sudo rm -rf "$staging" sudo mkdir -p "$staging" sudo cp -a "$bundle"/. "$staging"/ sudo mv \ "$staging/mrjunejune_server" \ "$staging/mrjunejune_server_binary" sudo cp \ "$staging/mrjunejune/production_entrypoint.sh" \ "$staging/mrjunejune_server" copilot_cli="$( sudo find -L "$staging" -type f \ -path '*/copilot_cli_linux_x86_64/copilot' -print -quit )" python_runtime="$( sudo find -L "$staging" -type f \ -path '*/rules_python++python+python_3_11_x86_64-unknown-linux-gnu/bin/python3' \ -print -quit )" if [[ -z "$copilot_cli" ]]; then echo "Deployment bundle does not contain the Copilot CLI" >&2 exit 1 fi if [[ -z "$python_runtime" ]]; then echo "Deployment bundle does not contain the Python runtime" >&2 exit 1 fi required_runtime=( "$staging/mrjunejune_server" "$staging/mrjunejune_server_binary" "$staging/mrjunejune/inference_stack.sh" "$staging/mrjunejune/inference_sidecar_launcher.sh" "$staging/mrjunejune/inference/copilot_sidecar.zip" "$staging/mrjunejune/inference/litellm_proxy.zip" "$staging/mrjunejune/inference/litellm_config.yaml" "$copilot_cli" "$python_runtime" ) for runtime_path in "${required_runtime[@]}"; do if [[ ! -e "$runtime_path" ]]; then echo "Deployment bundle is missing runtime: $runtime_path" >&2 exit 1 fi done sudo chmod +x \ "$staging/mrjunejune_server" \ "$staging/mrjunejune/inference_stack.sh" \ "$staging/mrjunejune/inference_sidecar_launcher.sh" \ "$copilot_cli" \ "$python_runtime" sudo chown -R mrjunejune_server:zenbu_team "$staging" # Persistent database, config, and Copilot tokens stay outside the immutable # bundle and survive swaps. sudo mkdir -p /opt/data/mrjunejune/ sudo chown -R mrjunejune_server:zenbu_team /opt/data/mrjunejune/ # Swap sudo rm -rf "$active" sudo mv "$staging" "$active" sudo systemctl restart mrjunejune_server.service echo "Deployment complete!"