fix: feat: configurable agent roles per container via DISINTO_AGENTS env var (#197)
This commit is contained in:
parent
81975501d8
commit
09a47e613c
3 changed files with 113 additions and 8 deletions
59
docker-compose.yml
Normal file
59
docker-compose.yml
Normal file
|
|
@ -0,0 +1,59 @@
|
||||||
|
version: "3.8"
|
||||||
|
|
||||||
|
services:
|
||||||
|
agents:
|
||||||
|
build:
|
||||||
|
context: ../
|
||||||
|
dockerfile: docker/agents/Dockerfile
|
||||||
|
image: disinto/agents:latest
|
||||||
|
container_name: disinto-agents
|
||||||
|
volumes:
|
||||||
|
- ./data/agents:/home/agent/data
|
||||||
|
- ./disinto:/home/agent/disinto:ro
|
||||||
|
- /usr/local/bin/claude:/usr/local/bin/claude:ro
|
||||||
|
environment:
|
||||||
|
- DISINTO_AGENTS=review,gardener
|
||||||
|
- ANTHROPIC_API_KEY=${ANTHROPIC_API_KEY:-}
|
||||||
|
- FORGE_TOKEN=${FORGE_TOKEN:-}
|
||||||
|
- FORGE_URL=http://forgejo:3000
|
||||||
|
depends_on:
|
||||||
|
- forgejo
|
||||||
|
|
||||||
|
agents-llama:
|
||||||
|
build:
|
||||||
|
context: ../
|
||||||
|
dockerfile: docker/agents/Dockerfile
|
||||||
|
image: disinto/agents-llama:latest
|
||||||
|
container_name: disinto-agents-llama
|
||||||
|
volumes:
|
||||||
|
- ./data/llama:/home/agent/data
|
||||||
|
- ./disinto:/home/agent/disinto:ro
|
||||||
|
- /usr/local/bin/claude:/usr/local/bin/claude:ro
|
||||||
|
environment:
|
||||||
|
- DISINTO_AGENTS=dev
|
||||||
|
- ANTHROPIC_API_KEY=${ANTHROPIC_API_KEY:-}
|
||||||
|
- FORGE_TOKEN=${FORGE_TOKEN:-}
|
||||||
|
- FORGE_URL=http://forgejo:3000
|
||||||
|
- PROJECT_TOML=projects/disinto.toml
|
||||||
|
- FORGE_REPO=johba/disinto
|
||||||
|
depends_on:
|
||||||
|
- forgejo
|
||||||
|
|
||||||
|
forgejo:
|
||||||
|
image: codeberg.org/forgejo/forgejo:1
|
||||||
|
container_name: disinto-forgejo
|
||||||
|
volumes:
|
||||||
|
- ./data/forgejo:/var/lib/forgejo
|
||||||
|
environment:
|
||||||
|
- FORGEJO__database__DB_TYPE=sqlite3
|
||||||
|
- FORGEJO__service__REGISTER_EMAIL_CONFIRMATION=false
|
||||||
|
- FORGEJO__service__ENABLE_NOTIFY_MAIL=false
|
||||||
|
- FORGEJO__service__DISABLE_REGISTRATION=true
|
||||||
|
- FORGEJO__service__REQUIRE_SIGNIN_VIEW=true
|
||||||
|
ports:
|
||||||
|
- "3000:3000"
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
data-agents:
|
||||||
|
data-llama:
|
||||||
|
data-forgejo:
|
||||||
|
|
@ -33,6 +33,14 @@ install_project_crons() {
|
||||||
local cron_lines="DISINTO_CONTAINER=1
|
local cron_lines="DISINTO_CONTAINER=1
|
||||||
USER=agent
|
USER=agent
|
||||||
FORGE_URL=http://forgejo:3000"
|
FORGE_URL=http://forgejo:3000"
|
||||||
|
|
||||||
|
# Parse DISINTO_AGENTS env var (default: all agents)
|
||||||
|
# Expected format: comma-separated list like "review,gardener" or "dev"
|
||||||
|
local agents_to_run="review,dev,gardener"
|
||||||
|
if [ -n "${DISINTO_AGENTS:-}" ]; then
|
||||||
|
agents_to_run="$DISINTO_AGENTS"
|
||||||
|
fi
|
||||||
|
|
||||||
for toml in "${DISINTO_DIR}"/projects/*.toml; do
|
for toml in "${DISINTO_DIR}"/projects/*.toml; do
|
||||||
[ -f "$toml" ] || continue
|
[ -f "$toml" ] || continue
|
||||||
local pname
|
local pname
|
||||||
|
|
@ -44,15 +52,30 @@ with open(sys.argv[1], 'rb') as f:
|
||||||
|
|
||||||
cron_lines="${cron_lines}
|
cron_lines="${cron_lines}
|
||||||
PROJECT_REPO_ROOT=/home/agent/repos/${pname}
|
PROJECT_REPO_ROOT=/home/agent/repos/${pname}
|
||||||
# disinto: ${pname}
|
# disinto: ${pname}"
|
||||||
2,7,12,17,22,27,32,37,42,47,52,57 * * * * ${DISINTO_DIR}/review/review-poll.sh ${toml} >>/home/agent/data/logs/cron.log 2>&1
|
|
||||||
4,9,14,19,24,29,34,39,44,49,54,59 * * * * ${DISINTO_DIR}/dev/dev-poll.sh ${toml} >>/home/agent/data/logs/cron.log 2>&1
|
# Add review-poll only if review agent is configured
|
||||||
|
if echo "$agents_to_run" | grep -qw "review"; then
|
||||||
|
cron_lines="${cron_lines}
|
||||||
|
2,7,12,17,22,27,32,37,42,47,52,57 * * * * ${DISINTO_DIR}/review/review-poll.sh ${toml} >>/home/agent/data/logs/cron.log 2>&1"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Add dev-poll only if dev agent is configured
|
||||||
|
if echo "$agents_to_run" | grep -qw "dev"; then
|
||||||
|
cron_lines="${cron_lines}
|
||||||
|
4,9,14,19,24,29,34,39,44,49,54,59 * * * * ${DISINTO_DIR}/dev/dev-poll.sh ${toml} >>/home/agent/data/logs/cron.log 2>&1"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Add gardener-run only if gardener agent is configured
|
||||||
|
if echo "$agents_to_run" | grep -qw "gardener"; then
|
||||||
|
cron_lines="${cron_lines}
|
||||||
0 0,6,12,18 * * * cd ${DISINTO_DIR} && bash gardener/gardener-run.sh ${toml} >>/home/agent/data/logs/cron.log 2>&1"
|
0 0,6,12,18 * * * cd ${DISINTO_DIR} && bash gardener/gardener-run.sh ${toml} >>/home/agent/data/logs/cron.log 2>&1"
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ -n "$cron_lines" ]; then
|
if [ -n "$cron_lines" ]; then
|
||||||
printf '%s\n' "$cron_lines" | crontab -u agent -
|
printf '%s\n' "$cron_lines" | crontab -u agent -
|
||||||
log "Installed crontab for agent user"
|
log "Installed crontab for agent user (agents: ${agents_to_run})"
|
||||||
else
|
else
|
||||||
log "No project TOMLs found — crontab empty"
|
log "No project TOMLs found — crontab empty"
|
||||||
fi
|
fi
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,14 @@ install_project_crons() {
|
||||||
local cron_lines="DISINTO_CONTAINER=1
|
local cron_lines="DISINTO_CONTAINER=1
|
||||||
USER=agent
|
USER=agent
|
||||||
FORGE_URL=http://forgejo:3000"
|
FORGE_URL=http://forgejo:3000"
|
||||||
|
|
||||||
|
# Parse DISINTO_AGENTS env var (default: all agents)
|
||||||
|
# Expected format: comma-separated list like "review,gardener" or "dev"
|
||||||
|
local agents_to_run="review,dev,gardener"
|
||||||
|
if [ -n "${DISINTO_AGENTS:-}" ]; then
|
||||||
|
agents_to_run="$DISINTO_AGENTS"
|
||||||
|
fi
|
||||||
|
|
||||||
for toml in "${DISINTO_DIR}"/projects/*.toml; do
|
for toml in "${DISINTO_DIR}"/projects/*.toml; do
|
||||||
[ -f "$toml" ] || continue
|
[ -f "$toml" ] || continue
|
||||||
local pname
|
local pname
|
||||||
|
|
@ -32,15 +40,30 @@ with open(sys.argv[1], 'rb') as f:
|
||||||
|
|
||||||
cron_lines="${cron_lines}
|
cron_lines="${cron_lines}
|
||||||
PROJECT_REPO_ROOT=/home/agent/repos/${pname}
|
PROJECT_REPO_ROOT=/home/agent/repos/${pname}
|
||||||
# disinto: ${pname}
|
# disinto: ${pname}"
|
||||||
2,7,12,17,22,27,32,37,42,47,52,57 * * * * ${DISINTO_DIR}/review/review-poll.sh ${toml} >>/home/agent/data/logs/cron.log 2>&1
|
|
||||||
4,9,14,19,24,29,34,39,44,49,54,59 * * * * ${DISINTO_DIR}/dev/dev-poll.sh ${toml} >>/home/agent/data/logs/cron.log 2>&1
|
# Add review-poll only if review agent is configured
|
||||||
|
if echo "$agents_to_run" | grep -qw "review"; then
|
||||||
|
cron_lines="${cron_lines}
|
||||||
|
2,7,12,17,22,27,32,37,42,47,52,57 * * * * ${DISINTO_DIR}/review/review-poll.sh ${toml} >>/home/agent/data/logs/cron.log 2>&1"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Add dev-poll only if dev agent is configured
|
||||||
|
if echo "$agents_to_run" | grep -qw "dev"; then
|
||||||
|
cron_lines="${cron_lines}
|
||||||
|
4,9,14,19,24,29,34,39,44,49,54,59 * * * * ${DISINTO_DIR}/dev/dev-poll.sh ${toml} >>/home/agent/data/logs/cron.log 2>&1"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Add gardener-run only if gardener agent is configured
|
||||||
|
if echo "$agents_to_run" | grep -qw "gardener"; then
|
||||||
|
cron_lines="${cron_lines}
|
||||||
0 0,6,12,18 * * * cd ${DISINTO_DIR} && bash gardener/gardener-run.sh ${toml} >>/home/agent/data/logs/cron.log 2>&1"
|
0 0,6,12,18 * * * cd ${DISINTO_DIR} && bash gardener/gardener-run.sh ${toml} >>/home/agent/data/logs/cron.log 2>&1"
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ -n "$cron_lines" ]; then
|
if [ -n "$cron_lines" ]; then
|
||||||
printf '%s\n' "$cron_lines" | crontab -u agent -
|
printf '%s\n' "$cron_lines" | crontab -u agent -
|
||||||
log "Installed crontab for agent user"
|
log "Installed crontab for agent user (agents: ${agents_to_run})"
|
||||||
else
|
else
|
||||||
log "No project TOMLs found — crontab empty"
|
log "No project TOMLs found — crontab empty"
|
||||||
fi
|
fi
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue