Skip to content

Commit

Permalink
Digital Ocean deploy tweaks (#1239)
Browse files Browse the repository at this point in the history
# Digital Ocean deploy tweaks

## JIRA Ticket

None (Fieldmark)

## Description

Some minor updates to the DO configuration to correct
some bugs and add a few more configuration options.


## Checklist

- [x] I have confirmed all commits have been signed.
- [x] I have added JSDoc style comments to any new functions or classes.
- [x] Relevant documentation such as READMEs, guides, and class comments
are updated.
  • Loading branch information
stevecassidy authored Nov 22, 2024
2 parents c07aecf + b1e4b0b commit 860d7c4
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 22 deletions.
2 changes: 1 addition & 1 deletion app/src/gui/components/notebook/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ export default function NotebookComponent({project}: NotebookComponentProps) {

const {data: template_id} = useQuery({
queryKey: ['project-template-id', project.project_id],
queryFn: async () : Promise<string | null> => {
queryFn: async (): Promise<string | null> => {
// don't return undefined from queryFn
const id = await getMetadataValue(project.project_id, 'template_id');
if (id !== undefined) return id as string;
Expand Down
1 change: 1 addition & 0 deletions infrastructure/digital-ocean/conductor/conductor.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ case "${1}" in
-e COUCHDB_INTERNAL_URL=https://db.$SUBDOMAIN \
-e COUCHDB_PUBLIC_URL=https://db.$SUBDOMAIN \
-e CONDUCTOR_PUBLIC_URL=https://conductor.$SUBDOMAIN \
-e KEY_FILE_PATH=/app\
-v "${keydir}:/app/keys" \
--restart unless-stopped\
--name conductor\
Expand Down
4 changes: 2 additions & 2 deletions infrastructure/digital-ocean/conductor/conductor.tf
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ EOT
resource "digitalocean_droplet" "conductor-droplet" {
image = "ubuntu-22-04-x64"
name = "conductor.${var.subdomain}"
region = "syd1"
size = "s-1vcpu-1gb"
region = var.region
size = var.droplet_size
ssh_keys = [
data.digitalocean_ssh_key.terraform.id
]
Expand Down
11 changes: 11 additions & 0 deletions infrastructure/digital-ocean/conductor/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,14 @@ variable "authorized_key" {
description = "public key for ssh login, added to authorized_keys"
type = string
}
variable "region" {
description = "Region to deploy to"
type = string
default = "syd1"
}

variable "droplet_size" {
description = "Size of the droplet to provision for conductor"
type = string
default = "s-1vcpu-1gb"
}
12 changes: 6 additions & 6 deletions infrastructure/digital-ocean/couchdb/couchdb.tf
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,19 @@ data "cloudinit_config" "couchdb_config" {
}

resource "digitalocean_volume" "couchdb-volume" {
region = "syd1"
region = var.region
count = var.instance_count
name = "couchdb-data"
size = 100
name = "couchdb-data-${count.index}-${var.subdomain}"
size = var.couchdb_volume_size
initial_filesystem_type = "ext4"
description = "couchdb storage"
}

resource "digitalocean_droplet" "couchdb" {
image = "ubuntu-22-04-x64"
name = "couchdb-${count.index}"
region = "syd1"
size = "s-1vcpu-1gb"
name = "couchdb-${count.index}-${var.subdomain}"
region = var.region
size = var.droplet_size
count = var.instance_count
ssh_keys = [
data.digitalocean_ssh_key.terraform.id
Expand Down
5 changes: 3 additions & 2 deletions infrastructure/digital-ocean/couchdb/loadbalancer.tf
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ resource "digitalocean_domain" "couchdb" {
depends_on = [ digitalocean_certificate.lb_certificate ]
}
resource "digitalocean_loadbalancer" "couchdb-lb" {
name = "couchdb-lb"
name = "couchdb-lb-${var.subdomain}"
region = "syd1"

forwarding_rule {
Expand All @@ -27,6 +27,7 @@ resource "digitalocean_loadbalancer" "couchdb-lb" {
protocol = "tcp"
}


depends_on = [ digitalocean_certificate.lb_certificate ]

droplet_ids = digitalocean_droplet.couchdb.*.id
}
18 changes: 18 additions & 0 deletions infrastructure/digital-ocean/couchdb/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,24 @@ variable "do_token" {
type = string
}

variable "region" {
description = "Region to deploy to"
type = string
default = "syd1"
}

variable "droplet_size" {
description = "Size of the droplet to provision for couchdb"
type = string
default = "s-1vcpu-1gb"
}

variable "couchdb_volume_size" {
description = "Size of the volume to attach to the couchdb droplet"
type = number
default = 100
}

variable "instance_count" {
description = "Number of couchdb instances to provision."
type = number
Expand Down
27 changes: 16 additions & 11 deletions infrastructure/digital-ocean/example/deploy.tf
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,24 @@ module "couchdb" {
couchdb_env_b64 = filebase64("./conductor.env")
do_token = var.do_token
authorized_key = file("./assets/public_key.pub")
region = "syd1"
droplet_size = "s-1vcpu-1gb"
couchdb_volume_size = 100
}

# module "conductor" {
# # source = "[email protected]:FAIMS/FAIMS3.git//infrastructure/digital-ocean/conductor"
# source = "../conductor"
# subdomain = "demo.fieldmark.app"
# contact_email = var.contact_email
# do_token = var.do_token
# conductor_env_b64 = filebase64("./conductor.env")
# conductor_pub_key_b64 = filebase64("./assets/public_key.pem")
# conductor_pvt_key_b64 = filebase64("./assets/private_key.pem")
# authorized_key = file("./assets/public_key.pub")
# }
module "conductor" {
# source = "[email protected]:FAIMS/FAIMS3.git//infrastructure/digital-ocean/conductor"
source = "../conductor"
subdomain = "demo.fieldmark.app"
contact_email = var.contact_email
do_token = var.do_token
conductor_env_b64 = filebase64("./conductor.env")
conductor_pub_key_b64 = filebase64("./assets/public_key.pem")
conductor_pvt_key_b64 = filebase64("./assets/private_key.pem")
authorized_key = file("./assets/public_key.pub")
region = "syd1"
droplet_size = "s-1vcpu-1gb"
}

variable "do_token" {
description = "digital ocean access token"
Expand Down

0 comments on commit 860d7c4

Please sign in to comment.