Skip to content
Deploy Sourcegraph on DigitalOcean using Terraform
Shell HCL Makefile
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
bin
resources
.gitignore
LICENSE
Makefile
README.md
main.tf
outputs.tf
terraform.tfvars.sample
vars.tf

README.md

Deploying Sourcegraph on DigitalOcean

This Terraform plan creates an SSH key and Droplet and deploys the latest stable version of Sourcegraph with TLS using a self-signed certificate.

DigitalOcean Terraform

🎬 Watch screencast on Vimeo.com

Prerequisites

  • Make
  • Terraform
  • mkcert (optional but required for self-signed cert validation)

NOTE: A basic level of knowledge and experience using Terraform is required.

Terraform DigitalOcean authentication

Authentication requires a a DigitalOcean API token set to the DIGITALOCEAN_TOKEN environment variable.

Terraform plan configuration

The existence of a terraform.tfvars file is required. To create it, copy the contents of terraform.tfvars.sample to a new terraform.tfvars file and review to see which variables (if any) you'd like to set.

The only required variable is ssh_key_file.

Commands

The Makefile has commands to cover the most common use-cases. The easiest way to create your Droplet is to run:

make deploy

This will create the Droplet and poll the server to let you know when Sourcegraph is ready.

Other commands include:

  • make init: Downloads the required Terraform provider packages.
  • make plan: Review what resources Terraform will create, change or remove.
  • make apply: Creates the Droplet and SSH key.
  • make sourcegraph: Waits for Sourcegraph to accept connections.
  • make output: Displays the same output as when make apply completes.
  • make destroy: Removes the Droplet and SSH key.

WARNING: make destroy will destroy the Droplet so back-up the /etc/sourcegraph and /var/opt/sourcegraph directories first.

Upgrading Sourcegraph

  1. SSH into the Droplet
  2. Run ./sourcegraph-upgrade

The newer Docker image will be pulled and Sourcegraph will be restarted.

Troubleshooting

./bin/wait-for-it.sh: line 58: timeout: command not found

The bin/wait-for-it.sh script uses the timeout binary which is not included in macOS. Install using homebrew:

  brew install coreutils
You can’t perform that action at this time.