# Google Cloud

> Create a Compute Engine VM for Grovs with the deploy script, from Cloud Shell or your workstation.

Source: https://docs.grovs.io/docs/self-hosting/clouds/gcp

[Open in Cloud Shell](https://ssh.cloud.google.com/cloudshell/editor?cloudshell_git_repo=https%3A%2F%2Fgithub.com%2Fgrovs-io%2Fself-host&cloudshell_tutorial=deploy%2Fgcp%2Ftutorial.md)

## When to use

You want Grovs on one Compute Engine VM in your Google Cloud project. The script creates a dedicated VPC and subnet, a static public IPv4, HTTP/HTTPS firewall rules, an IAP-only SSH rule and one Ubuntu 24.04 VM. The full Compose stack runs on that VM. The default is `e2-standard-4` with a 100 GB persistent boot disk. **These are billable resources.**

## Prerequisites

| Requirement          | Notes                                                                                                                                                                                                     |
| -------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Project              | Billing enabled                                                                                                                                                                                           |
| Permissions          | Enable the Compute API and create Compute Engine networking, disks and instances                                                                                                                          |
| Admin access         | OS Admin Login and IAP tunnel permissions. See [IAP TCP forwarding](https://cloud.google.com/iap/docs/using-tcp-forwarding) and [OS Login](https://cloud.google.com/compute/docs/oslogin/set-up-oslogin). |
| A domain you control | For the [DNS records](https://docs.grovs.io/docs/self-hosting/get-started/deployment#dns)                                                                                                                 |

The VM has no service account and no Google API scopes. It pulls public images without cloud credentials.

## 1. Prepare DNS and firewall

The script creates the firewall rules. Point the DNS records at the static IP it prints in step 2.

## 2. Create the server

From Cloud Shell or your workstation:

```bash
git clone https://github.com/grovs-io/self-host.git
cd self-host
GROVS_RELEASE_URL="$(curl -fsSL -o /dev/null -w '%{url_effective}' https://github.com/grovs-io/self-host/releases/latest)"
./deploy/gcp/deploy.sh YOUR_PROJECT_ID europe-west1-b example.com admin@example.com "${GROVS_RELEASE_URL##*/}"
```

The lookup selects the latest completed release. Backend and dashboard use that same GHCR tag; see [Images and releases](https://docs.grovs.io/docs/self-hosting/configure/images).

The script shows the project, zone and machine type and asks for confirmation. It passes `--project` explicitly and does not change your gcloud default project.

| Variable              | Effect                                                                                                                                                  |
| --------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `GROVS_INSTANCE_NAME` | Another installation name                                                                                                                               |
| `GROVS_MACHINE_TYPE`  | A different machine size                                                                                                                                |
| `GROVS_STACK_REF`     | A reviewed self-host commit for the Compose files and setup scripts, for repeatable installs. Images still use the release passed as the last argument. |

## 3. Install Grovs

Package installation and migrations continue after the VM is created. Point the DNS records at the printed static IP.

## 4. Deploy and verify

Connect with the SSH command the script printed, then:

```bash
sudo journalctl -u google-startup-scripts.service --no-pager -n 100
sudo systemctl status grovs --no-pager
sudo cat /opt/grovs/.env
```

Open `https://dashboard.<your-domain>` and sign in with the bootstrap admin values from `.env`. Then [verify the deployment](https://docs.grovs.io/docs/self-hosting/get-started/deployment#verify).

## Upgrades

`grovs.service` starts the existing stack on reboot. Bootstrap preserves an existing checkout and `.env`; it does not regenerate secrets or change the application version. Follow [Upgrades](https://docs.grovs.io/docs/self-hosting/operate/upgrades) from `/opt/grovs` as root.

## Gotchas

- The script stops at the first failed cloud command and does not delete resources it already created. Inspect them before retrying: an existing name makes `create` fail instead of replacing your installation. Remove a partial deployment with the commands below, or finish provisioning manually. If VM startup failed, fix the reported issue before rerunning bootstrap.

- To remove the deployment, back up your data and `.env` first. Adjust the values if you chose a different project, name or location:

  ```bash
  PROJECT=YOUR_PROJECT_ID
  ZONE=europe-west1-b
  REGION=europe-west1
  NAME=grovs
  gcloud --project="$PROJECT" compute instances delete "$NAME" --zone="$ZONE"
  gcloud --project="$PROJECT" compute addresses delete "$NAME-ip" --region="$REGION"
  gcloud --project="$PROJECT" compute firewall-rules delete "$NAME-web" "$NAME-ssh"
  gcloud --project="$PROJECT" compute networks subnets delete "$NAME-subnet" --region="$REGION"
  gcloud --project="$PROJECT" compute networks delete "$NAME-network"
  ```

- The boot disk is **retained** and keeps incurring storage charges. List it with `gcloud --project="$PROJECT" compute disks list`, snapshot it if needed, and delete it separately once you no longer need the data. A retained disk is not a database backup.
