|
| 1 | +# Justfile for building and uploading dstack runner and shim |
| 2 | +# |
| 3 | +# Build Process: |
| 4 | +# - Runner is always built for linux/amd64 |
| 5 | +# - Shim can be built for any platform (defaults to host platform) |
| 6 | +# - When uploading, shim is automatically built for linux/amd64 |
| 7 | +# |
| 8 | +# Upload Process: |
| 9 | +# - Both runner and shim are uploaded to S3 with version prefix |
| 10 | +# - Shim is validated to ensure it's built for linux/amd64 before upload |
| 11 | +# - Upload commands automatically rebuild binaries before uploading |
| 12 | +# |
| 13 | +# Development Workflows: |
| 14 | +# - Local Development: |
| 15 | +# * Use build recipes to build binaries for local testing |
| 16 | +# * See runner/README.md for instructions on running dstack server with local binaries |
| 17 | +# * No need to upload binaries for local development |
| 18 | +# |
| 19 | +# - Remote Development: |
| 20 | +# * Use upload recipes to build and upload binaries to S3 |
| 21 | +# * See runner/README.md for instructions on running dstack server with uploaded binaries |
| 22 | +# * Upload is required for testing with standard backends (including SSH fleets) |
| 23 | +# |
| 24 | +# Common Commands: |
| 25 | +# - just build: Build both runner and shim |
| 26 | +# - just upload: Upload both runner and shim |
| 27 | +# - just build-upload: Build and upload both |
| 28 | +# - just upload-shim: Build and upload only shim |
| 29 | +# - just upload-runner: Build and upload only runner |
| 30 | + |
| 31 | +# Default recipe to display available commands |
| 32 | +default: |
| 33 | + @just --list |
| 34 | + |
| 35 | +# Export version variable |
| 36 | +export version := "0.0.0" |
| 37 | + |
| 38 | +# Shim build configuration |
| 39 | +export shim_os := "" |
| 40 | +export shim_arch := "" |
| 41 | + |
| 42 | +# Download URLs |
| 43 | +export runner_download_url := "s3://dstack-runner-downloads-stgn/" + version + "/binaries/dstack-runner-linux-amd64" |
| 44 | +export shim_download_url := "s3://dstack-runner-downloads-stgn/" + version + "/binaries/dstack-shim-linux-amd64" |
| 45 | + |
| 46 | +# Build runner |
| 47 | +build-runner: |
| 48 | + #!/usr/bin/env bash |
| 49 | + set -e |
| 50 | + echo "Building runner for linux/amd64" |
| 51 | + cd runner/cmd/runner && GOOS=linux GOARCH=amd64 go build |
| 52 | + echo "Runner build complete!" |
| 53 | + |
| 54 | +# Build shim |
| 55 | +build-shim: |
| 56 | + #!/usr/bin/env bash |
| 57 | + set -e |
| 58 | + cd runner/cmd/shim |
| 59 | + if [ -n "$shim_os" ] && [ -n "$shim_arch" ]; then |
| 60 | + echo "Building shim for $shim_os/$shim_arch" |
| 61 | + GOOS=$shim_os GOARCH=$shim_arch go build |
| 62 | + else |
| 63 | + echo "Building shim for current platform" |
| 64 | + go build |
| 65 | + fi |
| 66 | + echo "Shim build complete!" |
| 67 | + |
| 68 | +# Build both runner and shim |
| 69 | +build: build-runner build-shim |
| 70 | + echo "Build complete! Linux AMD64 binaries are in their respective cmd directories." |
| 71 | + |
| 72 | +# Clean build artifacts |
| 73 | +clean: |
| 74 | + rm -f runner/cmd/runner/runner |
| 75 | + rm -f runner/cmd/shim/shim |
| 76 | + echo "Build artifacts cleaned!" |
| 77 | + |
| 78 | +# Run tests for runner and shim |
| 79 | +test: |
| 80 | + cd runner && go test -v ./... |
| 81 | + |
| 82 | +# Validate shim is built for linux/amd64 |
| 83 | +validate-shim: |
| 84 | + #!/usr/bin/env bash |
| 85 | + set -e |
| 86 | + if ! file runner/cmd/shim/shim | grep -q "ELF 64-bit LSB executable, x86-64"; then |
| 87 | + echo "Error: Shim must be built for linux/amd64 for upload" |
| 88 | + exit 1 |
| 89 | + fi |
| 90 | + |
| 91 | +# Upload both runner and shim to S3 |
| 92 | +upload: upload-runner upload-shim |
| 93 | + |
| 94 | +# Upload runner to S3 |
| 95 | +upload-runner: |
| 96 | + #!/usr/bin/env bash |
| 97 | + set -e |
| 98 | + just build-runner |
| 99 | + aws s3 cp runner/cmd/runner/runner "{{runner_download_url}}" --acl public-read |
| 100 | + echo "Uploaded runner to S3" |
| 101 | + |
| 102 | +# Upload shim to S3 |
| 103 | +upload-shim: |
| 104 | + #!/usr/bin/env bash |
| 105 | + set -e |
| 106 | + just --set shim_os linux --set shim_arch amd64 build-shim |
| 107 | + just validate-shim |
| 108 | + aws s3 cp runner/cmd/shim/shim "{{shim_download_url}}" --acl public-read |
| 109 | + echo "Uploaded shim to S3" |
| 110 | + |
| 111 | +# Build and upload both runner and shim to S3 |
| 112 | +build-upload: build upload |
0 commit comments