|
| 1 | +# Default command when 'just' is run without arguments |
| 2 | +# Run 'just <command>' to execute a command. |
| 3 | +default: list |
| 4 | + |
| 5 | +# Display help |
| 6 | +help: |
| 7 | + @printf "\nSee Makefile targets for just and direnv installation." |
| 8 | + @printf "\nRun 'just -n <command>' to print what would be executed...\n\n" |
| 9 | + @just --list --unsorted |
| 10 | + @echo "\n...by running 'just <command>'.\n" |
| 11 | + @echo "This message is printed by 'just help'." |
| 12 | + @echo "Just 'just' will just list the available recipes.\n" |
| 13 | + |
| 14 | +# List just recipes |
| 15 | +list: |
| 16 | + @just --list --unsorted |
| 17 | + |
| 18 | +# List evaluated just variables |
| 19 | +vars: |
| 20 | + @just --evaluate |
| 21 | + |
| 22 | +builder := env_var_or_default('BUILDER', 'podman') |
| 23 | +container_user := "runner" |
| 24 | +container_home := "/home" / container_user |
| 25 | +container_work := container_home / "work" |
| 26 | +git_username := env_var_or_default('GITHUB_USERNAME', 'pinellolab') |
| 27 | +git_org_name := env_var_or_default('GITHUB_ORG_NAME', 'pinellolab') |
| 28 | +git_repo_name := env_var_or_default('GITHUB_REPO_NAME', 'pyrovelocity') |
| 29 | +git_branch_name := env_var_or_default('GITHUB_BRANCH_NAME', 'master') |
| 30 | +container_registry := "ghcr.io/" + git_org_name + "/" |
| 31 | +pod_accelerator_type := env_var_or_default('POD_ACCELERATOR_TYPE', 'nvidia-tesla-t4') |
| 32 | +accelerator_node_selector := "gpu-type=" + pod_accelerator_type |
| 33 | + |
| 34 | +container_type := "dev" # or "app" |
| 35 | +container_image := if container_type == "dev" { |
| 36 | + "pyrovelocitygpu" |
| 37 | + } else if container_type == "app" { |
| 38 | + "pyrovelocityapp" |
| 39 | + } else { |
| 40 | + error("container_type must be either 'dev' or 'app'") |
| 41 | + } |
| 42 | +container_tag := "latest" |
| 43 | + |
| 44 | +pod_source_type := env_var_or_default('POD_SOURCE_TYPE', 'git') |
| 45 | +pod_git_provider := env_var_or_default('POD_GIT_PROVIDER', 'github') |
| 46 | +pod_disk_size := env_var_or_default('POD_DISK_SIZE', '400Gi') |
| 47 | +pod_min_cpu := env_var_or_default('POD_MIN_CPU', '16') |
| 48 | +pod_min_mem := env_var_or_default('POD_MIN_MEM', '64Gi') |
| 49 | +pod_max_cpu := env_var_or_default('POD_MAX_CPU', '32') |
| 50 | +pod_max_mem := env_var_or_default('POD_MAX_MEM', '96Gi') |
| 51 | +pod_max_accel := env_var_or_default('POD_MAX_ACCEL', '1') |
| 52 | +pod_resources := "requests.cpu=" + pod_min_cpu + ",requests.memory=" + pod_min_mem + ",limits.cpu=" + pod_max_cpu + ",limits.memory=" + pod_max_mem + ",limits.nvidia.com/gpu=" + pod_max_accel |
| 53 | + |
| 54 | +architecture := if arch() == "x86_64" { |
| 55 | + "amd64" |
| 56 | + } else if arch() == "aarch64" { |
| 57 | + "arm64" |
| 58 | + } else { |
| 59 | + error("unsupported architecture must be amd64 or arm64") |
| 60 | + } |
| 61 | + |
| 62 | +opsys := if os() == "macos" { |
| 63 | + "darwin" |
| 64 | + } else if os() == "linux" { |
| 65 | + "linux" |
| 66 | + } else { |
| 67 | + error("unsupported operating system must be darwin or linux") |
| 68 | + } |
| 69 | + |
| 70 | +devpod_release := "latest" # or "v0.3.7" or "v0.4.0-alpha.4" |
| 71 | + |
| 72 | +devpod_binary_url := if devpod_release == "latest" { |
| 73 | + "https://github.com/loft-sh/devpod/releases/latest/download/devpod-" + opsys + "-" + architecture |
| 74 | +} else { |
| 75 | + "https://github.com/loft-sh/devpod/releases/download/" + devpod_release + "/devpod-" + opsys + "-" + architecture |
| 76 | +} |
| 77 | + |
| 78 | +# Install devpod (check/set: devpod_release) |
| 79 | +[unix] |
| 80 | +install-devpod: |
| 81 | + curl -L -o devpod {{devpod_binary_url}} && \ |
| 82 | + sudo install -c -m 0755 devpod /usr/local/bin && \ |
| 83 | + rm -f devpod |
| 84 | + which devpod |
| 85 | + devpod version |
| 86 | + |
| 87 | +# Print devpod info |
| 88 | +devpod: |
| 89 | + devpod version && echo |
| 90 | + devpod context list |
| 91 | + devpod provider list |
| 92 | + devpod list |
| 93 | + |
| 94 | +# Install and use devpod kubernetes provider |
| 95 | +provider: |
| 96 | + devpod provider add kubernetes --silent || true \ |
| 97 | + && devpod provider use kubernetes |
| 98 | + |
| 99 | +# Run latest container_image in current kube context |
| 100 | +pod: |
| 101 | + devpod up \ |
| 102 | + --debug \ |
| 103 | + --devcontainer-image {{container_registry}}{{container_image}}:{{container_tag}} \ |
| 104 | + --provider kubernetes \ |
| 105 | + --ide vscode \ |
| 106 | + --open-ide \ |
| 107 | + --source {{pod_source_type}}:https://{{pod_git_provider}}.com/{{git_username}}/{{git_repo_name}} \ |
| 108 | + --provider-option DISK_SIZE={{pod_disk_size}} \ |
| 109 | + --provider-option NODE_SELECTOR={{accelerator_node_selector}} \ |
| 110 | + --provider-option RESOURCES={{pod_resources}} \ |
| 111 | + {{container_image}} |
| 112 | + |
| 113 | +# Stop devpod (check container_image hasn't changed with -n) |
| 114 | +stop: |
| 115 | + devpod stop {{container_image}} |
| 116 | + |
| 117 | +# Delete devpod (check container_image hasn't changed with -n) |
| 118 | +delete: |
| 119 | + devpod delete {{container_image}} |
0 commit comments