Skip to content

Commit

Permalink
deploy github.com/twentyhq/twenty
Browse files Browse the repository at this point in the history
  • Loading branch information
foodelevator committed Nov 30, 2024
1 parent 6db52b4 commit 5c79506
Show file tree
Hide file tree
Showing 3 changed files with 116 additions and 0 deletions.
105 changes: 105 additions & 0 deletions jobs/twenty.nomad.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
# To initialize the database, i had to run
# `tsx ./scripts/setup-db.ts` and `yarn database:migrate:prod`
# In the container with `nomad alloc exec ...`. The first command did complain
# a bunch about missing postgresql extensions but nothing else has complained
# about it so far...
# Making the container do this automatically does not work because then it
# wants to also CREATE THE DATABASE and is not happy about using an existing
# one, which might be the dumbest thing I've seen.

variable "image_tag" {
type = string
default = "v0.33"
}

variable "env" {
type = string
default = <<EOF
PORT={{ env "NOMAD_PORT_http" }}
SERVER_URL=https://twenty.datasektionen.se
FRONT_BASE_URL=https://twenty.datasektionen.se
STORAGE_TYPE=s3
STORAGE_S3_REGION=eu-north-1
STORAGE_S3_NAME=dsekt-twenty
STORAGE_S3_ACCESS_KEY_ID=AKIATUCF4UAOU4JCDGND
CACHE_STORAGE_TYPE=memory
MESSAGE_QUEUE_TYPE=pg-boss
MESSAGING_PROVIDER_GMAIL_ENABLED=false
CALENDAR_PROVIDER_GOOGLE_ENABLED=false
IS_SIGN_UP_DISABLED=true
{{ with nomadVar "nomad/jobs/twenty" }}
PG_DATABASE_URL=postgres://twenty:{{ .database_password }}@postgres.dsekt.internal:5432/twenty
APP_SECRET={{ .app_secret }} # openssl rand -base64 32
STORAGE_S3_SECRET_ACCESS_KEY={{ .s3_secret_access_key }}
{{ end }}
EOF
}

job "twenty" {
namespace = "twenty"

group "twenty" {
network {
port "http" { }
}

service {
name = "twenty"
port = "http"
provider = "nomad"
tags = [
"traefik.enable=true",
"traefik.http.routers.twenty.rule=Host(`twenty.datasektionen.se`)",
"traefik.http.routers.twenty.tls.certresolver=default",
]
}

task "server" {
driver = "docker"

config {
image = "twentycrm/twenty:${var.image_tag}"
ports = ["http"]
}

template {
data = var.env
destination = "local/.env"
env = true
}

resources {
memory = 600 # oh my god what bloat this is
}
}

task "worker" {
driver = "docker"

config {
image = "twentycrm/twenty:${var.image_tag}"
command = "yarn"
args = ["worker:prod"]
}

template {
data = var.env
destination = "local/.env"
env = true
}

resources {
memory = 600 # oh my god what bloat this is
}

lifecycle {
hook = "poststart"
sidecar = true
}
}
}
}
10 changes: 10 additions & 0 deletions nomad.tf
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,16 @@ resource "nomad_variable" "jobs_vault" {
}
}

# Twenty

resource "nomad_namespace" "twenty" {
name = "twenty"
}

resource "nomad_job" "twenty" {
jobspec = file("${path.module}/jobs/twenty.nomad.hcl")
}

# Auth

resource "nomad_namespace" "auth" {
Expand Down
1 change: 1 addition & 0 deletions profiles/traefik.nix
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ in
"auth"
"mattermost"
"vault"
"twenty"
];
};

Expand Down

0 comments on commit 5c79506

Please sign in to comment.