Add database to nova-timetable job (#62)

This commit is contained in:
nova 2024-09-29 18:35:33 +01:00 committed by GitHub
parent 544277e206
commit 083faa2209
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -6,10 +6,14 @@ job "nova-timetable" {
count = 1
network {
port "db" {
port "redis" {
to = 6379
}
port "db" {
to = 5432
}
port "frontend" {
to = 3000
}
@ -52,7 +56,7 @@ job "nova-timetable" {
driver = "docker"
env {
REDIS_ADDRESS = "${NOMAD_ADDR_db}"
REDIS_ADDRESS = "${NOMAD_ADDR_redis}"
}
config {
@ -81,16 +85,39 @@ job "nova-timetable" {
}
}
task "redis-db" {
task "redis" {
driver = "docker"
config {
image = "redis:latest"
ports = ["db"]
ports = ["redis"]
}
}
task "timetablebot" {
task "timetable-db" {
driver = "docker"
config {
image = "postgres:17.0-alpine"
ports = ["db"]
volumes = [
"/opt/postgres/nova-timetable:/var/lib/postgresql/data"
]
}
template {
data = <<EOH
POSTGRES_USER={{ key "user-projects/nova/db/user" }}
POSTGRES_PASSWORD={{ key "user-projects/nova/db/password" }}
POSTGRES_DB={{ key "user-projects/nova/db/db" }}
EOH
destination = "local/db.env"
env = true
}
}
task "timetable-bot" {
driver = "docker"
config {
@ -99,8 +126,13 @@ job "nova-timetable" {
template {
data = <<EOH
BOT_TOKEN={{ key "user-projects/nova/timetablebot/token" }}
REDIS_ADDRESS={{ env "NOMAD_ADDR_db" }}
BOT_TOKEN={{ key "user-projects/nova/bot/token" }}
REDIS_ADDRESS={{ env "NOMAD_ADDR_redis" }}
POSTGRES_USER={{ key "user-projects/nova/db/user" }}
POSTGRES_PASSWORD={{ key "user-projects/nova/db/password" }}
POSTGRES_DB={{ key "user-projects/nova/db/db" }}
POSTGRES_HOST={{ env "NOMAD_IP_db" }}
POSTGRES_PORT={{ env "NOMAD_PORT_db" }}
EOH
destination = "local/.env"
env = true