https://github.com/sourcegraph/deploy-sourcegraph-digitalocean
Deploy Sourcegraph on DigitalOcean using Terraform
https://github.com/sourcegraph/deploy-sourcegraph-digitalocean
repo-type-infrastructure
Last synced: 3 months ago
JSON representation
Deploy Sourcegraph on DigitalOcean using Terraform
- Host: GitHub
- URL: https://github.com/sourcegraph/deploy-sourcegraph-digitalocean
- Owner: sourcegraph
- License: apache-2.0
- Archived: true
- Created: 2019-02-26T17:50:15.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2024-04-30T19:21:15.000Z (over 1 year ago)
- Last Synced: 2025-02-10T04:08:20.939Z (12 months ago)
- Topics: repo-type-infrastructure
- Language: Shell
- Homepage:
- Size: 150 KB
- Stars: 8
- Watchers: 58
- Forks: 3
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 🚨 Deprecation Notice 🚨
This repository is no longer a supported Sourcegraph deployment method.
If you'd like to deploy Sourcegraph, please see our [Deployment Documentation](https://sourcegraph.com/docs/admin/deploy) to learn about our supported deployment methods.
---
# 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.

🎬 [Watch screencast on Vimeo.com](https://vimeo.com/333392180)
## Prerequisites
- Make
- [Terraform](https://learn.hashicorp.com/terraform/getting-started/install.html)
- [mkcert](https://github.com/FiloSottile/mkcert) (optional but required for self-signed cert validation)
> NOTE: A basic level of knowledge and experience using [Terraform](https://www.terraform.io/intro/index.html) is required.
## Terraform DigitalOcean authentication
Authentication requires a a [DigitalOcean API token](https://www.digitalocean.com/docs/api/create-personal-access-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:
```bash
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
1. Run `./sourcegraph-upgrade`
The newer Docker image will be pulled and Sourcegraph will be restarted.
## Troubleshooting
```bash
./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:
```bash
brew install coreutils
```