1#!/bin/bash 2 3# mount an SSD for fast repo syncing 4mkfs.ext4 -F /dev/nvme0n1 5mkdir /ssd 6mount /dev/nvme0n1 /ssd 7chmod a+w /ssd 8 9# configure Docker to run on the SSD 10mkdir -p /ssd/docker 11mkdir -p /etc/docker 12echo "{\"graph\": \"/ssd/docker\"}" > /etc/docker/daemon.json 13 14# install Docker 15apt-get update 16apt-get -qq -y --force-yes install docker.io 17author=$(curl "http://metadata.google.internal/computeMetadata/v1/instance/attributes/AUTHOR" -H "Metadata-Flavor: Google") 18usermod -a -G docker $author 19 20# authenticate to Google Cloud as service account 21serviceAccount=$(curl "http://metadata.google.internal/computeMetadata/v1/instance/attributes/SERVICE_ACCOUNT" -H "Metadata-Flavor: Google") 22googleProjectID=$(curl "http://metadata.google.internal/computeMetadata/v1/instance/attributes/GOOGLE_PROJECT_ID" -H "Metadata-Flavor: Google") 23gcloud projects add-iam-policy-binding $googleProjectID --member serviceAccount:$serviceAccount --role roles/compute.instanceAdmin.v1 24