Skip to content

Commit

Permalink
added nomad file
Browse files Browse the repository at this point in the history
Signed-off-by: lindenmckenzie <[email protected]>
  • Loading branch information
KamenDimitrov97 authored and lindenmckenzie committed Jun 21, 2023
1 parent 31d4a43 commit a9ad5e1
Show file tree
Hide file tree
Showing 3 changed files with 145 additions and 1 deletion.
2 changes: 2 additions & 0 deletions Dockerfile.concourse
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ FROM python:3.10
RUN mkdir data
COPY data data/

COPY .env.default .

COPY dist/dp_nlp_berlin_api-*-py3-none-any.whl .

RUN pip install dp_nlp_berlin_api-*-py3-none-any.whl
Expand Down
4 changes: 3 additions & 1 deletion app/settings.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import time
from dynaconf import Dynaconf

current_time = int(time.time())

settings = Dynaconf(
envvar_prefix="BERLIN_API",
load_dotenv=True,
Expand All @@ -16,5 +18,5 @@
DATA_LOCATION = settings.get("DATA_LOCATION")

# BERLIN_API_START_TIME name of the start_time variable
BUILD_TIME = settings.get("BUILD_TIME")
BUILD_TIME = settings.get("BUILD_TIME", current_time)
GIT_COMMIT = settings.get("GIT_COMMIT")
140 changes: 140 additions & 0 deletions dp-nlp-category-api.nomad
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
job "dp-nlp-category-api" {
datacenters = ["eu-west-2"]
region = "eu"
type = "service"

update {
stagger = "60s"
min_healthy_time = "30s"
healthy_deadline = "2m"
max_parallel = 1
auto_revert = true
}

group "web" {
count = "{{WEB_TASK_COUNT}}"

constraint {
attribute = "${node.class}"
value = "web"
}

restart {
attempts = 3
delay = "15s"
interval = "1m"
mode = "delay"
}

task "dp-nlp-berlin-api-web" {
driver = "docker"

artifact {
source = "s3::https://s3-eu-west-2.amazonaws.com/{{DEPLOYMENT_BUCKET}}/dp-nlp-berlin-api/{{PROFILE}}/{{RELEASE}}.tar.gz"
}

config {
command = "${NOMAD_TASK_DIR}/start-task"

args = ["python", "-m", "app.main"]

image = "{{ECR_URL}}:concourse-{{REVISION}}"

}

service {
name = "dp-nlp-berlin-api"
port = "http"
tags = ["web"]

check {
type = "http"
path = "/health"
interval = "10s"
timeout = "2s"
}
}

resources {
cpu = "{{WEB_RESOURCE_CPU}}"
memory = "{{WEB_RESOURCE_MEM}}"

network {
port "http" {}
}
}

template {
source = "${NOMAD_TASK_DIR}/vars-template"
destination = "${NOMAD_TASK_DIR}/vars"
}

vault {
policies = ["dp-nlp-berlin-api-web"]
}
}
}

group "publishing" {
count = "{{PUBLISHING_TASK_COUNT}}"

constraint {
attribute = "${node.class}"
value = "publishing"
}

restart {
attempts = 3
delay = "15s"
interval = "1m"
mode = "delay"
}

task "dp-nlp-berlin-api-publishing" {
driver = "docker"

artifact {
source = "s3::https://s3-eu-west-2.amazonaws.com/{{DEPLOYMENT_BUCKET}}/dp-nlp-berlin-api/{{PROFILE}}/{{RELEASE}}.tar.gz"
}

config {
command = "${NOMAD_TASK_DIR}/start-task"

args = ["python", "-m", "app.main"]

image = "{{ECR_URL}}:concourse-{{REVISION}}"
}

service {
name = "dp-nlp-berlin-api"
port = "http"
tags = ["publishing"]

check {
type = "http"
path = "/health"
interval = "10s"
timeout = "2s"
}
}

resources {
cpu = "{{PUBLISHING_RESOURCE_CPU}}"
memory = "{{PUBLISHING_RESOURCE_MEM}}"

network {
port "http" {}
}
}

template {
source = "${NOMAD_TASK_DIR}/vars-template"
destination = "${NOMAD_TASK_DIR}/vars"
}

vault {
policies = ["dp-nlp-berlin-api-publishing"]
}
}
}
}

0 comments on commit a9ad5e1

Please sign in to comment.