Skip to content

Instantly share code, notes, and snippets.

@mike-ensor
Last active May 6, 2018 18:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mike-ensor/ce1007683c2af1e8c803b4642a2c0b52 to your computer and use it in GitHub Desktop.
Save mike-ensor/ce1007683c2af1e8c803b4642a2c0b52 to your computer and use it in GitHub Desktop.

Overview

This is a quick "how-to" built off of several other's blogs, twitter posts, gists and such. The goal is to create a workable environment for basic GCP (gcloud) development with VSCode.

Note

This installation process takes about 30-45 minutes each time a container is built from scratch (purely based on network performance, so could be faster or slower, this was my experience).

Steps

  1. Enable chromebook for development (https://github.com/lstoll/cros-crostini/blob/master/README.md)
  2. Run the script (vscode-gcloud-chromebook.sh) to setup VSCode + GCloud
  3. Create service account
  4. Copy/download service account to local
  5. https://console.cloud.google.com/iam-admin/serviceaccounts/project?project=[YOUR PROJECT]
  6. Run
   gcloud auth activate-service-account --key-file my_service_account.json 
   gcloud config set project [YOUR PROJECT]

Tips

  1. Stop container:
    lxc stop [container-name]
  2. Start up the same container (easiest and same as starting it up the first time):
    run_container.sh --container_name=[container-name] --user=[user] --shell
  3. Start up alternative:
lxc start [container-name]
lxc exec [container-name] -- /bin/bash
#!/bin/sh
## Assuming `vmc dev start` and `run_container.sh --container_name=<somename> --user=<someuser> --shell`
## Setup base dependencies and tools (debian)
sudo apt-get update
sudo apt-get install -y gpg git libasound2 libxss1 wget libgconf-2-4 libnss3-dev
## VSCode Debian
curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.gpg
sudo mv microsoft.gpg /etc/apt/trusted.gpg.d/microsoft.gpg
sudo sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/vscode stable main" > /etc/apt/sources.list.d/vscode.list'
# install vscode
sudo apt-get install code
#### (Copied from GCloud Install)
# Create environment variable for correct distribution
export CLOUD_SDK_REPO="cloud-sdk-$(lsb_release -c -s)"
export CLOUD_PROJECT_NAME="...REPLACEME..."
# Add the Cloud SDK distribution URI as a package source
echo "deb http://packages.cloud.google.com/apt $CLOUD_SDK_REPO main" | sudo tee -a /etc/apt/sources.list.d/google-cloud-sdk.list
# Import the Google Cloud Platform public key
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
# Update the package list and install the Cloud SDK
sudo apt-get update && sudo apt-get -y install google-cloud-sdk
gcloud auth activate-service-account --key-file SERVICE_ACCOUNT_DOWNLOADED.json
gcloud config set project ${CLOUD_PROJECT_NAME}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment