• Что бы вступить в ряды "Принятый кодер" Вам нужно:
    Написать 10 полезных сообщений или тем и Получить 10 симпатий.
    Для того кто не хочет терять время,может пожертвовать средства для поддержки сервеса, и вступить в ряды VIP на месяц, дополнительная информация в лс.

  • Пользаватели которые будут спамить, уходят в бан без предупреждения. Спам сообщения определяется администрацией и модератором.

  • Гость, Что бы Вы хотели увидеть на нашем Форуме? Изложить свои идеи и пожелания по улучшению форума Вы можете поделиться с нами здесь. ----> Перейдите сюда
  • Все пользователи не прошедшие проверку электронной почты будут заблокированы. Все вопросы с разблокировкой обращайтесь по адресу электронной почте : info@guardianelinks.com . Не пришло сообщение о проверке или о сбросе также сообщите нам.

Deploying Docker-Compose Projects with Nomad Using raw_exec

Sascha Оффлайн

Sascha

Заместитель Администратора
Команда форума
Администратор
Регистрация
9 Май 2015
Сообщения
1,483
Баллы
155
Hi there! I'm

Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.

. Right now, I’m building

Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.

, a first-of-its-kind tool that helps you automatically index API endpoints across all your repositories. LiveAPI makes it easier to discover, understand, and interact with APIs in large infrastructures.


TL;DR


You don’t need Nomad to parse your docker-compose.yml. Just git clone and docker-compose up --build via raw_exec. Done.

Context


I had a small project: a Go-based app that syncs data into Meilisearch. Locally, I used docker-compose to run two services:

  • Meilisearch – the search engine
  • searchsync – a Go app that reads JSON and pushes data to Meilisearch

Now I wanted to deploy this with Nomad.

The Problem


Nomad doesn’t natively support docker-compose. So I:

  1. Tried converting the compose file to Nomad jobs
  2. Got into volume mount hell
  3. Fought with constraint errors
  4. Tried building inside Docker
  5. Realized I was wasting time

So I gave up on Docker driver and used Nomad’s raw_exec instead.

The Plan


Let the raw exec driver:

  • Clone the repo
  • Run docker-compose up --build

It just works.

Prerequisites

  1. Docker Engine is installed on the target Nomad client node
  2. Docker Compose plugin installed manually:

mkdir -p ~/.docker/cli-plugins
curl -SL

Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.

\
-o ~/.docker/cli-plugins/docker-compose
chmod +x ~/.docker/cli-plugins/docker-compose
docker compose version # ✅ should show v2.x



  1. Your Nomad client has access to Git (via SSH key or HTTPS token)
Nomad Job File


Here's the final working deploy.hcl:


job "searchsync-rawexec" {
datacenters = ["dc1"]
type = "batch"

group "searchsync" {
task "bootstrap-searchsync" {
driver = "raw_exec"

config {
command = "/bin/bash"
args = ["-c", <<EOT
cd /tmp && \
git clone git@git.apps.hexmos.com:hexmos/commons/searchsync.git && \
cd searchsync && \
docker compose up --build
EOT
]
}

constraint {
attribute = "${node.unique.id}"
value = "a02c1701-53ae-1b96-5004-3d70c1227751" # constraint to nats03 node
}

resources {
cpu = 500
memory = 512
}
}
}
}



Deploy It


nomad job run deploy.hcl




Done. No image push. No registry creds. Just clone and run.

Bonus: CI/CD Step


Here's the GitLab CI step:


deploy-searchsync:
stage: deploy-searchsync
tags:
- gcp-master
script:
- export NOMAD_ADDR="

Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.

"
- nomad job stop searchsync-rawexec || true
- nomad job run deploy.hcl



Conclusion


Don't overcomplicate things. If your app runs with docker-compose, just run it that way using Nomad's raw_exec. Let it do one job: boot up your service.

No variable mess. No volume hell. No hours lost converting YAML to HCL.



Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.

helps you get all your backend APIs documented in a few minutes.

With LiveAPI, you can generate interactive API docs that allow users to search and execute endpoints directly from the browser.


Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.



If you're tired of updating Swagger manually or syncing Postman collections, give it a shot.



Источник:

Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.

 
Вверх Снизу