Skip to content

About

A dockerized Azure Devops Agent

Resources

Stars

0 stars

Watchers

1 watching

Forks

Repository files navigation

Docker-based build Agent for Azure Devops

This repository contains a Dockerfile that can be used to run a dockerized Azure Devops Agent.

Included Tools

The following tools are included to cover many needs in a typical Azure and Microsoft based build environment.

  • Azure CLI - Access many features of Azure Resource Manager from bash
  • Terraform - Setup your Azure infrastructure as Code
  • helm - useful for AKS, apply helm charts to make deployment to Kubernetes easier
  • kubectl - useful for AKS, apply kubernetes YAML based spec files to Kubernetes
  • jq - Process JSON files from bash
  • java-openjdk - to build Java projects or use tools like OpenAPI Generator for NodeJS
  • docker - access to the docker host allows the agent to build, run and push images as needed

Some installed standard tools are

  • git
  • awk
  • wget
  • zip
  • unzip

Make sure to change the Dockerfile to match your needs if your agent requires additional tools!

Things that are not explicitly installed, but still work

  • Build Node.JS Applications, by using the NodeTool task
  • Build dotnet Applications, by using the UseDotnet task

How it works

  • On build-time: the image installs needed tools and dependencies as normal. The start script that will run on runtime can be found at scripts/start.sh and gets copied into the container.

  • on run-time (scripts/start.sh): the specified version of the vstsagentpackage gets downloaded, untared, configured and executed. This is done so that

    a) Upgrades of the agent versions are easy and do not require a container image rebuild.

    b) Configuration can be changed as needed without container rebuild.

Building

  • build the Dockerfile using this command, or by using build.sh.
docker build -t bastisk/vsts-agent:latest .

Using the image

Configuration

Copy the .env.sample file to .env.

AGENT_PAT=<pat>
AGENT_ENDPOINT=https://<server>/<org>
AGENT_POOL=<agent_pool_name>
AGENT_VERSION=3.238.0
AGENT_WORKFOLDER=_work

Edit the .env file to match your environment.

  • AGENT_PAT: In Azure Devops, create a new personal access token with the permission "Agent Pools" "Read&Manage". The agent will register itself using this PAT at your Azure Devops instance.
  • AGENT_ENDPOINT: enter your Azure Devops Server URL and Organization
  • AGENT_POOL: this is the name of your agent pool at Azure Devops. In case you are unsure, please follow the official documentation on how to create a new agent pool or how to configure an existing one.
  • AGENT_VERSION: the Azure Devops Agent version that should be downloaded on container startup.
  • AGENT_WORKFOLDER: the directory within the container where build artifacts are stored. This can be changed to any value you like, even volumes would be possible.

If you don't feel happy putting your PAT into a text file, you can also choose to expose any of those variables as environment variables.

Starting the image

Hints about the EULA

The start scripts calls the configure command of the vsts-agent using the -acceptTeeEula parameter. This means that you agree to it! Make sure to read the EULA of the VSTS Agent before running it.

Starting with Docker support

If you plan on running docker container on your agent, you should use the start.sh file to start the image. This allows the container to execute docker commands on the host. Because this can expose your host to significant security risks (any user that can create a pipeline and use your agent can run pretty much any docker container on it), you should make sure to do this only in a trusted environment and in agreement with your development policies.

Starting without Docker support

If you want to use the image without Docker support, you can start it using the docker-compose-no-docker.yml file directly.

docker-compose -f docker-compose-no-docker.yml up -d

Maintenance

As with any Software or deployment you should take care about updates. The versions in the Dockerfile presented here are getting updated by their respective authors over time. I cannot guarantee that I will always be able to update the versions here to the latest versions. So please regularly check the versions if you chose to use this repository in a productive scenario!

About

A dockerized Azure Devops Agent

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages