Install Drone-VM and using Google Drivers

To install Drone-VM and use Google Cloud Platform (GCP) drivers, you can follow these steps:

  1. Create a new GCP project and enable the Compute Engine API.
  2. Set up a service account in the project with the following IAM roles:
  • Compute Admin
  • Service Account User
  1. Generate a JSON key for the service account and download it.
  2. Install the Google Cloud SDK on your local machine.
  3. Configure the SDK with your GCP project:
gcloud init
  1. Install Docker and Docker Compose on your local machine.
  2. Create a new directory for the Drone-VM configuration files:
mkdir drone-vm
cd drone-vm
  1. Create a new file named docker-compose.yml and add the following code:
version: '3'

services:
  drone-vm:
    image: drone/drone-vm
    restart: always
    privileged: true
    environment:
      - GOOGLE_APPLICATION_CREDENTIALS=/gcp-key.json
      - GOOGLE_ZONE=<your-google-zone>
      - GOOGLE_PROJECT=<your-google-project>
      - GOOGLE_INSTANCE_NAME_PREFIX=drone-
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - ./gcp-key.json:/gcp-key.json:ro
    command: start

Replace <your-google-zone> with the zone you want to use (e.g., us-central1-a) and <your-google-project> with your GCP project ID.
9. Create a new JSON key file for the GCP service account and save it as gcp-key.json in the same directory as the docker-compose.yml file.
10. Start the Drone-VM container:

docker-compose up -d
  1. Verify that the container is running:

Copy code

docker ps
  1. You can now use the GCP drivers in your Drone pipelines. For example, you can use the gcloud CLI tool to interact with GCP resources:
kind: pipeline
type: docker
name: example

steps:
- name: deploy
  image: google/cloud-sdk:alpine
  commands:
  - gcloud auth activate-service-account --key-file=/gcp-key.json
  - gcloud config set project <your-google-project>
  - gcloud compute instances list

Replace <your-google-project> with your GCP project ID.

That’s it! You now have Drone-VM running with GCP drivers and can use them in your Drone pipelines.