Rahul Ravikumar | 8777e6e | 2019-11-19 13:52:49 -0800 | [diff] [blame] | 1 | # Setting up the Gradle Build Cache Node on Google Cloud Platform. |
| 2 | |
| 3 | To setup the [Gradle Remote Cache](https://docs.gradle.com/build-cache-node) you need to do the following: |
| 4 | |
| 5 | ## Create a new Instance |
| 6 | |
| 7 | * Open the Cloud Platform [console](https://console.cloud.google.com/home/dashboard?project=fetch-licenses). |
| 8 | |
Aurimas Liutikas | 3a57f0e | 2022-01-24 16:56:58 -0800 | [diff] [blame] | 9 | * In the search box type in and select `VM Instances`. |
Rahul Ravikumar | 8777e6e | 2019-11-19 13:52:49 -0800 | [diff] [blame] | 10 | |
Aurimas Liutikas | 3a57f0e | 2022-01-24 16:56:58 -0800 | [diff] [blame] | 11 | * Click on an existing node to see details page, then use `Create Similar` to create a new node. |
Rahul Ravikumar | 8777e6e | 2019-11-19 13:52:49 -0800 | [diff] [blame] | 12 | *Note*: This node has to be tagged with a network tag called `gradle-remote-cache-node` |
| 13 | for it to be picked up by the load balancer. Make sure you create the node in the zone `us-east-1-b`. |
| 14 | |
| 15 | * Click `Allow HTTP Traffic` and `Allow HTTPs Traffic`. By doing do, you are allowing UberProxy access |
| 16 | to the remote cache. The load balancer is only available when you are on a corp network. |
| 17 | |
| 18 | * Connect to the newly created node using an SSH session. You can use the `gcloud` CLI for this. |
| 19 | *Note*: Use the `external` IP of the newly created node to SSH. |
| 20 | |
| 21 | ```bash |
Rahul Ravikumar | 34d5f48 | 2020-02-28 14:10:31 -0800 | [diff] [blame] | 22 | # Note: To switch projects use `gcloud config set project fetch-licenses` |
Rahul Ravikumar | 8777e6e | 2019-11-19 13:52:49 -0800 | [diff] [blame] | 23 | # Will show the newly created instance |
| 24 | gcloud compute instances list |
| 25 | # Will setup ssh configurations |
| 26 | gcloud compute config-ssh |
Aurimas Liutikas | b073af5e0 | 2020-08-07 22:59:28 +0000 | [diff] [blame] | 27 | ssh 123.123.123.123 |
Rahul Ravikumar | 8777e6e | 2019-11-19 13:52:49 -0800 | [diff] [blame] | 28 | ``` |
| 29 | |
| 30 | ## Starting the Gradle Remote Cache Node |
| 31 | |
Aurimas Liutikas | b073af5e0 | 2020-08-07 22:59:28 +0000 | [diff] [blame] | 32 | ```bash |
Aurimas Liutikas | 3a57f0e | 2022-01-24 16:56:58 -0800 | [diff] [blame] | 33 | # Install some prerequisite packages |
| 34 | sudo apt update |
| 35 | sudo apt upgrade |
| 36 | sudo apt install openjdk-11-jdk tmux wget |
Aurimas Liutikas | b073af5e0 | 2020-08-07 22:59:28 +0000 | [diff] [blame] | 37 | # Create a folder `Workspace` in the home directory. |
| 38 | mkdir Workspace |
| 39 | cd Workspace |
Aurimas Liutikas | 3a57f0e | 2022-01-24 16:56:58 -0800 | [diff] [blame] | 40 | mkdir -p data/conf |
Aurimas Liutikas | b073af5e0 | 2020-08-07 22:59:28 +0000 | [diff] [blame] | 41 | # using the template in this checkout create config.yaml |
Aurimas Liutikas | 3a57f0e | 2022-01-24 16:56:58 -0800 | [diff] [blame] | 42 | vi data/conf/config.yaml |
Aurimas Liutikas | b073af5e0 | 2020-08-07 22:59:28 +0000 | [diff] [blame] | 43 | # using the template in this checkout create run_node, replace YOURUSERNAME with your username |
| 44 | vi run_node |
| 45 | chmod +x run_node |
Aurimas Liutikas | b073af5e0 | 2020-08-07 22:59:28 +0000 | [diff] [blame] | 46 | mkdir gradle-node |
Aurimas Liutikas | 3a57f0e | 2022-01-24 16:56:58 -0800 | [diff] [blame] | 47 | wget https://docs.gradle.com/build-cache-node/jar/build-cache-node-11.1.jar -P gradle-node |
Aurimas Liutikas | b073af5e0 | 2020-08-07 22:59:28 +0000 | [diff] [blame] | 48 | # Create a `tmux` session |
| 49 | tmux new -s gradle |
Aurimas Liutikas | 3a57f0e | 2022-01-24 16:56:58 -0800 | [diff] [blame] | 50 | sudo ./run_node & |
Aurimas Liutikas | b073af5e0 | 2020-08-07 22:59:28 +0000 | [diff] [blame] | 51 | # Detach from the tmux session ctrl+b then d |
| 52 | exit |
| 53 | ``` |
Rahul Ravikumar | 8777e6e | 2019-11-19 13:52:49 -0800 | [diff] [blame] | 54 | |
| 55 | ## Update the `gradle-remote-cache-group` instance group. |
| 56 | |
Aurimas Liutikas | b073af5e0 | 2020-08-07 22:59:28 +0000 | [diff] [blame] | 57 | * Open `Instance groups` in gcloud console |
| 58 | * Click on `gradle-remote-cache-group` and select `Edit Group`. |
| 59 | * Select the new node(s), from the drop-down list. |
| 60 | * Remove old nodes from the list |
Rahul Ravikumar | 8777e6e | 2019-11-19 13:52:49 -0800 | [diff] [blame] | 61 | * Click `Save`. |