homelab/nomad-job/drone.nomad

117 lines
3.2 KiB
Plaintext
Raw Normal View History

2022-04-24 10:47:17 +00:00
job "drone" {
datacenters = ["homelab"]
2022-12-10 16:10:32 +00:00
priority = 50
2022-10-29 08:40:01 +00:00
type = "service"
2022-05-10 08:35:33 +00:00
vault {
2022-10-30 08:33:39 +00:00
policies = ["droneci"]
2022-04-27 18:22:49 +00:00
}
2022-04-24 10:47:17 +00:00
2022-05-10 08:35:33 +00:00
2022-04-24 10:47:17 +00:00
group "droneCI" {
network {
mode = "host"
port "http" {
to = 80
}
2022-11-27 14:25:26 +00:00
port "vault" {
to= 3000
2022-11-27 14:25:26 +00:00
}
2022-04-24 10:47:17 +00:00
}
2022-05-10 08:35:33 +00:00
constraint {
attribute = "${attr.cpu.arch}"
2022-10-29 08:40:01 +00:00
value = "amd64"
2022-04-24 10:47:17 +00:00
}
task "drone-server" {
driver = "docker"
service {
name = "drone"
port = "http"
tags = [
2022-05-23 19:44:34 +00:00
"homer.enable=true",
"homer.name=DroneCI",
"homer.service=Platform",
"homer.logo=https://drone.ducamps.win/static/media/logo.76c744d4.svg",
"homer.target=_blank",
"homer.url=https://${NOMAD_JOB_NAME}.ducamps.win",
2022-04-24 10:47:17 +00:00
"traefik.enable=true",
2022-04-24 20:19:18 +00:00
"traefik.http.routers.${NOMAD_JOB_NAME}.rule=Host(`${NOMAD_JOB_NAME}.ducamps.win`)",
2022-04-24 10:47:17 +00:00
"traefik.http.routers.${NOMAD_JOB_NAME}.tls.domains[0].sans=${NOMAD_JOB_NAME}.ducamps.win",
2022-04-24 20:19:18 +00:00
"traefik.http.routers.${NOMAD_JOB_NAME}.tls.certresolver=myresolver",
"traefik.http.middlewares.httpsRedirect.redirectscheme.scheme=https",
2023-10-07 16:40:40 +00:00
"traefik.http.routers.${NOMAD_JOB_NAME}.middlewares=httpsRedirect",
"traefik.http.routers.${NOMAD_JOB_NAME}.entrypoints=web,websecure",
2022-04-24 20:19:18 +00:00
2022-04-24 10:47:17 +00:00
]
}
config {
image = "drone/drone:latest"
ports = [
"http"
]
}
env {
}
template {
2022-10-29 08:40:01 +00:00
data = <<EOH
{{ with secret "secrets/data/nomad/droneci"}}
2022-04-24 10:47:17 +00:00
DRONE_GITEA_SERVER="https://git.ducamps.win"
DRONE_GITEA_CLIENT_ID="{{ .Data.data.DRONE_GITEA_CLIENT_ID }}"
DRONE_GITEA_CLIENT_SECRET="{{ .Data.data.DRONE_GITEA_CLIENT_SECRET }}"
DRONE_GITEA_ALWAYS_AUTH="True"
DRONE_USER_CREATE="username:vincent,admin:true"
DRONE_DATABASE_DRIVER="postgres"
DRONE_RPC_SECRET="{{ .Data.data.DRONE_RPC_SECRET }}"
DRONE_SERVER_HOST="drone.ducamps.win"
DRONE_SERVER_PROTO="https"
{{end}}
2022-10-30 08:33:39 +00:00
{{ with secret "secrets/data/database/droneci"}}
2023-11-01 07:42:04 +00:00
DRONE_DATABASE_DATASOURCE="postgres://drone:{{ .Data.data.password }}@active.db.service.consul:5432/drone?sslmode=disable"
2022-10-30 08:33:39 +00:00
{{end}}
2022-04-24 10:47:17 +00:00
EOH
2022-11-27 14:25:26 +00:00
destination = "secrets/drone.env"
2022-10-29 08:40:01 +00:00
env = true
2022-04-24 10:47:17 +00:00
}
2022-05-12 09:36:04 +00:00
resources {
memory = 100
}
2022-04-24 10:47:17 +00:00
}
2022-11-27 14:25:26 +00:00
task "vault" {
2022-04-24 10:47:17 +00:00
driver = "docker"
2022-11-27 14:25:26 +00:00
service {
name = "drone-vault"
port = "vault"
2022-04-24 10:47:17 +00:00
}
2022-11-27 14:25:26 +00:00
config {
ports = ["vault"]
image = "drone/vault:latest"
2022-04-24 10:47:17 +00:00
}
template {
2022-11-27 14:25:26 +00:00
data= <<EOH
DRONE_DEBUG=true
{{ with secret "secrets/data/nomad/droneci"}}
2022-11-27 14:25:26 +00:00
DRONE_SECRET= {{ .Data.data.DRONE_VAULT_SECRET}}
{{end}}
2022-11-29 20:03:12 +00:00
VAULT_TOKEN=
2022-11-27 14:25:26 +00:00
VAULT_ADDR=http://active.vault.service.consul:8200
VAULT_AUTH_TYPE=approle
VAULT_TOKEN_TTL=72h
VAULT_TOKEN_RENEWAL=24h
{{ with secret "secrets/data/nomad/droneci/approle"}}
2022-11-29 20:03:12 +00:00
VAULT_APPROLE_ID= {{ .Data.data.approleID}}
VAULT_APPROLE_SECRET= {{ .Data.data.approleSecretID}}
{{end}}
2022-11-27 14:25:26 +00:00
EOH
destination = "secrets/drone-vault.env"
env = true
2022-05-10 08:35:33 +00:00
}
2022-11-27 14:25:26 +00:00
}
2022-05-10 08:35:33 +00:00
}
2022-04-24 10:47:17 +00:00
}