travix/gocd-agent

By travix

Updated over 1 year ago

Go.CD continuous delivery agent

Image
2

10K+

travix/gocd-agent

Go.CD continuous delivery agent baked with Docker in Docker

StarsPullsLicense

Usage

To run this docker container use the following command

docker run -d travix/gocd-agent:latest

Environment variables

In order to configure the agent for use in your cluster with other than default settings you can pass in the following environment variables

NameDescriptionDefault value
GO_SERVERThe host name or ip address of the server to connect tolocalhost
GO_SERVER_PORTThe http port of the go server8153
AGENT_MEMThe -Xms value for the java vm128m
AGENT_MAX_MEMThe -Xmx value for the java vm256m
AGENT_KEYThe secret key set on the server for auto-registration of the agent
AGENT_RESOURCESThe resource tags for the agent in case of auto-registration
AGENT_ENVIRONMENTSThe environments the agent is assigned to in case of auto-registration
AGENT_HOSTNAMEThe hostname used for the agent; normally it's the hosts actual hostname

To connect the agent to your server with other than default ip or hostname

docker run -d \
    -e "GO_SERVER=gocd.yourdomain.com" \
    travix/gocd-agent:latest

If you've set up your server for autoregistration of agents pass in the same value for environment variable AGENT_KEY when starting the agent

docker run -d \
    -e "GO_SERVER=gocd.yourdomain.com" \
    -e "AGENT_KEY=388b633a88de126531afa41eff9aa69e" \
    travix/gocd-agent:latest

You can also set resource tags, gocd environment and hostname for the agent when autoregistering

docker run -d \
    -e "GO_SERVER=gocd.yourdomain.com" \
    -e "AGENT_KEY=388b633a88de126531afa41eff9aa69e" \
    -e "AGENT_RESOURCES=deploy-x,deploy-z" \
    -e "AGENT_ENVIRONMENTS=Production" \
    -e "AGENT_HOSTNAME=deploy-agent-01" \
    travix/gocd-agent:latest

Mounting volumes

In order to keep working copies over a restart and use ssh keys from the host machine you can mount the following directories

DirectoryDescriptionImportance
/var/lib/go-agent/pipelinesThis directory holds the working copies for all pipelines that have run on this agentYou want to have this cleaned up regularly anyway, so no real need to mount it
/var/log/go-agentAll output logs go here, but there also written to standard out in the containerPreferably collect logs from standard out
/var/go/.sshThe ssh keys to connect to version control systems like github and bitbucketAs it's better not to embed these keys in the container you likely need to mount this

Start the container like this to mount the directories

docker run -d \
    -e "GO_SERVER=gocd.yourdomain.com" \
    -e "AGENT_KEY=388b633a88de126531afa41eff9aa69e" \
    -e "AGENT_RESOURCES=deploy-x,deploy-z" \
    -e "AGENT_ENVIRONMENTS=Production" \
    -e "AGENT_HOSTNAME=deploy-agent-01" \
    -v /mnt/persistent-disk/gocd-agent/pipelines:/var/lib/go-agent/pipelines
    -v /mnt/persistent-disk/gocd-agent/logs:/var/log/go-agent
    -v /mnt/persistent-disk/gocd-agent/ssh:/var/go/.ssh
    travix/gocd-agent:latest

To make sure the process in the container can read and write to those directories create a user and group with same gid and uid on the host machine

groupadd -r -g 998 go
useradd -r -g go -u 998 go

And then change the owner of the host directories

chown -R go:go /mnt/persistent-disk/gocd-agent/pipelines
chown -R go:go /mnt/persistent-disk/gocd-agent/ssh

Docker Pull Command

docker pull travix/gocd-agent