forked from arriven/db1000n
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Digital Ocean setup + Docker optimization (arriven#142)
* Fix some misspells and misslinks * Add DO docs * Remove redundant layers * Compact dockerfile
- Loading branch information
Showing
7 changed files
with
97 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,7 +23,6 @@ config.json | |
|
||
# terraform | ||
**/.terraform* | ||
**/terraform.tfvars | ||
**/terraform.tfstate* | ||
|
||
.history |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Digital Ocean deployment | ||
|
||
## Requirements | ||
|
||
- Digital Ocean account | ||
- API token (Go to API - Personal access tokens) and generate Personal access token (with write permissions) | ||
- `terraform` (1.0+) installed | ||
|
||
## Deploy | ||
|
||
To deploy run: | ||
|
||
```terraform | ||
export DO_TOKEN=<place-api-token-here> | ||
terraforim init | ||
terraform plan -var "do_token=${DO_TOKEN}" | ||
terraform apply -var "do_token=${DO_TOKEN}" | ||
``` | ||
|
||
After deployment (usually takes 5-10 mins) go to [Apps List](https://cloud.digitalocean.com/apps), find an app with name `db1000n` and chek Runtime Logs. | ||
|
||
## Destroy | ||
|
||
To destroy infrastructure use commands: | ||
|
||
```terraform | ||
export DO_TOKEN=<place-api-token-here> | ||
terraform destroy -var "do_token=${DO_TOKEN}" | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
resource "digitalocean_app" "db1000n" { | ||
spec { | ||
name = "db1000n" | ||
region = var.region | ||
|
||
worker { | ||
name = "db1000n-service" | ||
environment_slug = "go" | ||
instance_count = var.instance_count | ||
instance_size_slug = var.instance_size_slug | ||
|
||
git { | ||
repo_clone_url = var.repo | ||
branch = "main" | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
terraform { | ||
required_providers { | ||
digitalocean = { | ||
source = "digitalocean/digitalocean" | ||
version = "~> 2.0" | ||
} | ||
} | ||
required_version = "~> 1.0" | ||
} | ||
|
||
provider "digitalocean" { | ||
token = var.do_token | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
instance_count = 1 | ||
instance_size_slug = "professional-xs" | ||
region = "nyc" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
variable "do_token" { | ||
type = string | ||
} | ||
|
||
variable "repo" { | ||
type = string | ||
default = "https://github.com/Arriven/db1000n" | ||
} | ||
|
||
variable "instance_count" { | ||
type = number | ||
default = 1 | ||
} | ||
|
||
# https://docs.digitalocean.com/reference/api/api-reference/#operation/list_instance_sizes | ||
variable "instance_size_slug" { | ||
type = string | ||
default = "professional-xs" | ||
} | ||
|
||
# https://docs.digitalocean.com/reference/api/api-reference/#operation/list_all_regions | ||
variable "region" { | ||
type = string | ||
default = "nyc1" | ||
} |