Skip to content

Commit 3ed15e1

Browse files
committed
fix: Install folder path and update README.md
1 parent 227a648 commit 3ed15e1

File tree

8 files changed

+257
-191
lines changed

8 files changed

+257
-191
lines changed

.env.example

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,39 @@
1-
# Variables d'environnement pour Azure DevOps Agent
2-
# Copiez ce fichier vers .env et remplissez les valeurs
1+
# Environment variables for Azure DevOps Agent
2+
# Copy this file to .env and fill in the values
33

4-
# URL de votre organisation Azure DevOps
5-
AZP_URL=https://dev.azure.com/votre-organisation
4+
# Your Azure DevOps organization URL
5+
AZP_URL=https://dev.azure.com/your-organization
66

7-
# Token d'accès personnel (PAT) pour Azure DevOps
8-
# Doit avoir les permissions: Agent Pools (read, manage), Build (read), Code (read)
9-
# Alternative: utiliser AWS_REGION + AZURE_DEVOPS_TOKEN_SECRET_ARN
10-
AZP_TOKEN=votre-token-ici
7+
# Personal Access Token (PAT) for Azure DevOps
8+
# Must have permissions: Agent Pools (read, manage), Build (read), Code (read)
9+
# Alternative: use AWS_REGION + AZURE_DEVOPS_TOKEN_SECRET_ARN
10+
AZP_TOKEN=your-token-here
1111

12-
# Pool d'agents Azure DevOps
12+
# Azure DevOps agent pool
1313
AZP_POOL=Default
1414

15-
# Nom de base pour les agents (sera suffixé par -${AGENT_NUMBER}-${INSTANCE_ID})
15+
# Base name for agents (will be suffixed with -${AGENT_NUMBER}-${INSTANCE_ID})
1616
AZP_AGENT_NAME=docker-agent
1717

18-
# Numéro d'agent (1 à 7) - fourni au lancement du conteneur
18+
# Agent number (1 to 7) - provided at container startup
1919
AGENT_NUMBER=1
2020

21-
# === Variables optionnelles ===
21+
# === Optional variables ===
2222

23-
# ID de l'instance AWS (récupéré automatiquement si non fourni)
23+
# AWS instance ID (automatically retrieved if not provided)
2424
# INSTANCE_ID=i-1234567890abcdef0
2525

26-
# Configuration AWS Secrets Manager (recommandé pour la production)
26+
# AWS Secrets Manager configuration (recommended for production)
2727
# AWS_REGION=eu-west-1
2828
# AZURE_DEVOPS_TOKEN_SECRET_ARN=arn:aws:secretsmanager:eu-west-1:123456789012:secret:azure-devops-token-AbCdEf
2929

30-
# Image de conteneur par défaut (optionnel)
30+
# Default container image (optional)
3131
DEFAULT_CONTAINER_IMAGE=ubuntu:22.04
3232

33-
# Volumes par défaut (optionnel)
34-
# Pour Windows/Podman: pas de socket monté, utiliser DOCKER_HOST
35-
# Pour Docker Desktop: /var/run/docker.sock:/var/run/docker.sock
36-
DEFAULT_VOLUMES=/cache:/cache,/data:/data
33+
# Default volumes (optional)
34+
# For Windows/Podman: no socket mounted, use DOCKER_HOST
35+
# For Docker Desktop: /var/run/docker.sock:/var/run/docker.sock
36+
DEFAULT_VOLUMES=/cache:/cache,/data:/data
37+
38+
# Installation folder for the agent
39+
INSTALL_FOLDER=/opt/azagent

Dockerfile

Lines changed: 31 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Stage 1: Extraire la version de l'agent
1+
# Stage 1: Extract agent version
22
FROM ubuntu:22.04 AS temp-version
33

44
ENV DEBIAN_FRONTEND=noninteractive
@@ -11,9 +11,9 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
1111

1212
RUN AGENT_VERSION=$(curl -s https://api.github.com/repos/microsoft/azure-pipelines-agent/releases/latest | grep -oP '"tag_name": "v\K(.*)(?=")') && \
1313
echo "$AGENT_VERSION" > /tmp/agent_version.txt && \
14-
echo "Version détectée: $AGENT_VERSION"
14+
echo "Detected version: $AGENT_VERSION"
1515

16-
# Stage 2: Télécharger l'agent Azure DevOps
16+
# Stage 2: Download Azure DevOps agent
1717
FROM ubuntu:22.04 AS agent-downloader
1818

1919
ENV DEBIAN_FRONTEND=noninteractive
@@ -27,25 +27,25 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
2727
COPY --from=temp-version /tmp/agent_version.txt /tmp/agent_version.txt
2828

2929
RUN AGENT_VERSION=$(cat /tmp/agent_version.txt) && \
30-
echo "Téléchargement de l'agent Azure DevOps..." && \
31-
echo "Version détectée: $AGENT_VERSION" && \
30+
echo "Downloading Azure DevOps agent..." && \
31+
echo "Detected version: $AGENT_VERSION" && \
3232
\
33-
# Détecter l'architecture pour choisir le bon agent
33+
# Detect architecture to choose the right agent
3434
ARCH=$(dpkg --print-architecture 2>/dev/null || uname -m) && \
3535
case "$ARCH" in \
3636
amd64|x86_64) AGENT_ARCH="x64" ;; \
3737
arm64|aarch64) AGENT_ARCH="arm64" ;; \
3838
armhf|armv7l|armv7) AGENT_ARCH="arm" ;; \
39-
*) echo "⚠️ Architecture non supportée: $ARCH, utilisation de x64 par défaut" && AGENT_ARCH="x64" ;; \
39+
*) echo "⚠️ Unsupported architecture: $ARCH, using x64 by default" && AGENT_ARCH="x64" ;; \
4040
esac && \
4141
\
42-
echo "Architecture détectée: $ARCH -> Agent: linux-$AGENT_ARCH" && \
43-
mkdir -p /opt/azagent/agent && \
42+
echo "Detected architecture: $ARCH -> Agent: linux-$AGENT_ARCH" && \
43+
mkdir -p /opt/dl && \
4444
curl -fsSL "https://download.agent.dev.azure.com/agent/$AGENT_VERSION/vsts-agent-linux-$AGENT_ARCH-$AGENT_VERSION.tar.gz" -o "/tmp/agent.tar.gz" && \
45-
tar xzf "/tmp/agent.tar.gz" -C /opt/azagent/agent && \
45+
tar xzf "/tmp/agent.tar.gz" -C /opt/dl && \
4646
rm "/tmp/agent.tar.gz"
4747

48-
# Stage 3: Télécharger aws-ssm
48+
# Stage 3: Download aws-ssm
4949
FROM ubuntu:22.04 AS aws-ssm-downloader
5050

5151
ENV DEBIAN_FRONTEND=noninteractive
@@ -63,7 +63,7 @@ COPY download-github-binary.sh /tmp/
6363
RUN chmod +x /tmp/download-github-binary.sh && \
6464
/tmp/download-github-binary.sh "hypolas/aws-ssm-light" "aws-ssm"
6565

66-
# Stage 4: Télécharger Docker CLI
66+
# Stage 4: Download Docker CLI
6767
FROM ubuntu:22.04 AS docker-downloader
6868

6969
ENV DEBIAN_FRONTEND=noninteractive
@@ -81,63 +81,63 @@ RUN curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o /
8181
&& apt-get install -y --no-install-recommends docker-ce-cli docker-compose-plugin \
8282
&& rm -rf /var/lib/apt/lists/*
8383

84-
# Stage final: Image runtime minimale
84+
# Final stage: Minimal runtime image
8585
FROM ubuntu:22.04
8686

87-
# Éviter les questions interactives pendant l'installation
87+
# Avoid interactive prompts during installation
8888
ENV DEBIAN_FRONTEND=noninteractive
89-
# Installer seulement les dépendances runtime nécessaires
89+
# Install only necessary runtime dependencies
9090
RUN apt-get update && apt-get install -y --no-install-recommends \
9191
sudo \
9292
jq \
9393
git \
94-
# Dépendances .NET runtime pour l'agent Azure DevOps
94+
# .NET runtime dependencies for Azure DevOps agent
9595
libicu70 \
9696
liblttng-ust1 \
9797
libssl3 \
9898
&& rm -rf /var/lib/apt/lists/*
9999

100-
# Copier les binaires depuis les stages de build
100+
# Copy binaries from build stages
101101
COPY --from=temp-version /tmp/agent_version.txt /tmp/agent_version.txt
102-
COPY --from=agent-downloader /opt/azagent/ /opt/azagent/
103-
COPY --from=agent-downloader /opt/azagent/agent/ /opt/azagent/agent/
102+
COPY --from=agent-downloader /opt/dl /opt/dl
103+
# COPY --from=agent-downloader /opt/azagent/agent/ /opt/azagent/agent/
104104
COPY --from=aws-ssm-downloader /usr/local/bin/aws-ssm /usr/local/bin/aws-ssm
105105
COPY --from=docker-downloader /usr/bin/docker /usr/bin/docker
106106
COPY --from=docker-downloader /usr/libexec/docker/cli-plugins/docker-compose /usr/libexec/docker/cli-plugins/docker-compose
107107

108-
# Créer l'utilisateur azureagent
108+
# Create azureagent user
109109
RUN useradd -m -s /bin/bash azureagent \
110110
&& usermod -aG sudo azureagent \
111111
&& echo "azureagent ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
112112

113113
RUN apt-get update && apt-get install -y --no-install-recommends \
114114
ca-certificates
115115

116-
# Créer les répertoires nécessaires et ajuster les permissions
116+
# Create necessary directories and adjust permissions
117117
RUN mkdir -p /opt/setup-scripts \
118118
&& mkdir -p /cache \
119119
&& mkdir -p /data \
120120
&& mkdir -p /usr/libexec/docker/cli-plugins \
121-
&& chown -R azureagent:azureagent /opt/azagent \
121+
&& chown -R azureagent:azureagent /opt/dl \
122122
&& chown -R azureagent:azureagent /opt/setup-scripts \
123123
&& chmod +x /usr/local/bin/aws-ssm \
124124
&& chmod +x /usr/bin/docker \
125125
&& chmod +x /usr/libexec/docker/cli-plugins/docker-compose
126126

127-
# Installer les dépendances .NET de l'agent Azure DevOps au build
127+
# Install .NET dependencies for Azure DevOps agent at build time
128128
WORKDIR /opt/azagent
129129
RUN if [ -f "./bin/installdependencies.sh" ]; then \
130-
echo "Installation des dépendances .NET de l'agent Azure DevOps..." && \
130+
echo "Installing .NET dependencies for Azure DevOps agent..." && \
131131
./bin/installdependencies.sh; \
132132
fi && \
133133
chown -R azureagent:azureagent /opt/azagent
134134

135-
# Copier les scripts de configuration
135+
# Copy configuration scripts
136136
COPY scripts/ /opt/setup-scripts/
137137
RUN chmod +x /opt/setup-scripts/*.sh \
138138
&& chown -R azureagent:azureagent /opt/setup-scripts
139139

140-
# Variables d'environnement par défaut
140+
# Default environment variables
141141
ENV INSTALL_FOLDER="/opt/azagent"
142142
ENV AZP_URL=""
143143
ENV AZP_TOKEN=""
@@ -150,24 +150,20 @@ ENV AZURE_DEVOPS_TOKEN_SECRET_ARN=""
150150
ENV DEFAULT_CONTAINER_IMAGE="ubuntu:22.04"
151151
ENV DEFAULT_VOLUMES="/var/run/docker.sock:/var/run/docker.sock,/cache:/cache,/data:/data"
152152

153-
# Exposer le répertoire de travail
154-
VOLUME ["/cache", "/data"]
155-
156-
# Script d'entrée
153+
# Entrypoint script
157154
COPY entrypoint.sh /entrypoint.sh
158155
RUN chmod +x /entrypoint.sh \
159156
&& chown -R azureagent:azureagent /opt/azagent
160157

161-
# Ajouter des labels avec la version de l'agent
158+
# Add labels with agent version
162159
RUN AGENT_VERSION=$(cat /tmp/agent_version.txt 2>/dev/null || echo "unknown") && \
163160
echo "LABEL agent.version=$AGENT_VERSION" >> /tmp/labels.txt
164161

165-
# Labels pour métadonnées
166-
LABEL maintainer="hypolas" \
167-
description="Azure DevOps Agent avec intégration AWS Secrets Manager" \
162+
# Metadata labels
163+
LABEL maintainer="Nicolas HYPOLITE" \
164+
description="Azure DevOps Agent with AWS Secrets Manager integration" \
168165
org.opencontainers.image.source="https://github.com/hypolas/azure-agent"
169166

170167
USER azureagent
171-
WORKDIR /opt/azagent
172168

173169
ENTRYPOINT ["/entrypoint.sh"]

README.md

Lines changed: 79 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,9 @@ This Docker image configures and runs an Azure DevOps agent with container suppo
1717
- `AZP_POOL`: Agent pool name
1818
- `AZP_AGENT_NAME`: Base agent name (will be suffixed with -${AGENT_NUMBER})
1919
- `AGENT_NUMBER`: **Mandatory** - Unique identifier for each agent instance. Required to avoid configuration conflicts when mounting Docker volumes on disk.
20+
- `INSTALL_FOLDER`: **Mandatory** - Agent installation directory. Must be identical in both environment variable and volume mount path.
2021

2122
## Optional Environment Variables
22-
23-
- `INSTALL_FOLDER`: Agent installation directory (default: /opt/azagent)
2423
- `INSTANCE_ID`: AWS instance ID (automatically retrieved with IMDSv2 if not provided)
2524
- `AWS_REGION`: AWS region for Secrets Manager (ex: eu-west-1)
2625
- `AZURE_DEVOPS_TOKEN_SECRET_ARN`: ARN of AWS secret containing Azure DevOps token
@@ -78,7 +77,84 @@ docker run -d \
7877

7978
### With Docker Compose (Recommended)
8079

81-
The provided `docker-compose.yml` file automatically configures 7 agents (instances 1 to 7):
80+
Use the provided `docker-compose.yml` file (using environment variables):
81+
82+
```yaml
83+
version: '3.8'
84+
85+
services:
86+
azure-agent:
87+
build:
88+
context: .
89+
args:
90+
# aws-ssm installed by default (hypolas/aws-ssm-light)
91+
INSTALL_AWS_SSM: "true"
92+
93+
container_name: azure-devops-agent
94+
hostname: azure-agent
95+
96+
environment:
97+
# Azure DevOps configuration (required)
98+
- AZP_URL=${AZP_URL}
99+
- AZP_POOL=${AZP_POOL}
100+
- AZP_AGENT_NAME=${AZP_AGENT_NAME:-azure-agent}
101+
- AGENT_NUMBER=${AGENT_NUMBER:-1}
102+
- INSTALL_FOLDER=${INSTALL_FOLDER}
103+
104+
# AWS for token retrieval (if AZP_TOKEN not provided)
105+
- AWS_REGION=${AWS_REGION}
106+
- AZURE_DEVOPS_TOKEN_SECRET_ARN=${AZURE_DEVOPS_TOKEN_SECRET_ARN}
107+
108+
# Direct token (optional, takes priority over AWS)
109+
- AZP_TOKEN=${AZP_TOKEN}
110+
111+
# Container configuration
112+
- DEFAULT_CONTAINER_IMAGE=ubuntu:22.04
113+
- DEFAULT_VOLUMES=/var/run/docker.sock:/var/run/docker.sock,/cache:/cache,/data:/data
114+
115+
volumes:
116+
# Docker socket for builds
117+
- /var/run/docker.sock:/var/run/docker.sock
118+
- ${INSTALL_FOLDER}:${INSTALL_FOLDER}
119+
restart: unless-stopped
120+
121+
# Healthcheck to verify agent is running
122+
healthcheck:
123+
test: ["CMD-SHELL", "pgrep -f 'Agent.Listener' || exit 1"]
124+
interval: 30s
125+
timeout: 10s
126+
retries: 3
127+
start_period: 60s
128+
```
129+
130+
#### ⚠️ Critical: INSTALL_FOLDER Consistency
131+
132+
**The `INSTALL_FOLDER` value MUST be identical in both the environment variable and the volume mount path. This is MANDATORY for the agent to function properly.**
133+
134+
```yaml
135+
# ✅ CORRECT - Same path in both places (using variable)
136+
environment:
137+
- INSTALL_FOLDER=${INSTALL_FOLDER}
138+
volumes:
139+
- ${INSTALL_FOLDER}:${INSTALL_FOLDER}
140+
141+
# Example with .env file:
142+
# INSTALL_FOLDER=/opt/azagent
143+
144+
# ❌ WRONG - Different paths will cause FAILURE
145+
environment:
146+
- INSTALL_FOLDER=/opt/azagent
147+
volumes:
148+
- /opt/agent:/opt/azagent # ← Different path, agent will NOT work
149+
```
150+
151+
**Why this matters:**
152+
- The agent creates its configuration inside `${INSTALL_FOLDER}/${AGENT_NUMBER}/`
153+
- The volume mount must map to the exact same path
154+
- Mismatched paths will prevent the agent from finding its configuration files
155+
- **The service will FAIL to start if paths don't match**
156+
157+
**Deployment:**
82158

83159
```bash
84160
# Copy the example file

0 commit comments

Comments
 (0)