travix/gocd-server

By travix

Updated over 3 years ago

Go.CD continuous delivery server

Image
7

500K+

travix/gocd-server

Go.CD continuous delivery server

StarsPullsLicense

Usage

To run this docker container use the following command

docker run -d \
    -p 8153:8153 \
    -p 8154:8154 \
    travix/gocd-server:latest

Environment variables

In order to configure the server with other than default settings you can pass in the following environment variables

NameDescriptionDefault value
AGENT_KEYThe secret key to set on the server for auto-registration of agents
GC_LOGGC Log
JVM_DEBUGJVM Debug
SERVER_MEMThe -Xms value for the java vm512m
SERVER_MAX_MEMThe -Xmx value for the java vm1024m
SERVER_MIN_PERM_GENThe -XX:PermSize value for the java vm128m
SERVER_MAX_PERM_GENThe -XX:MaxPermSize value for the java vm256m
USER_AUTHSpace separated list of user:password

For setting up autoregistration for agents pass in the AGENT_KEY environment variable with a secret value

docker run -d \
    -p 8153:8153 \
    -p 8154:8154 \
    -e "AGENT_KEY=388b633a88de126531afa41eff9aa69e" \
    travix/gocd-server:latest

Mounting volumes

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

DirectoryDescriptionImportance
/var/lib/go-server/artifactsThe build and test artifacts are stored hereAlthough you can recreate artifacts by re-running pipelines, this is very time-consuming, so better to persist
/var/lib/go-server/db/h2dbThe file-based database is stored here; make sure it's mapped to a fast driveAbsolutely keep this backed up!
/var/lib/go-server/plugins/externalAny plugins from http://www.go.cd/community/plugins.html you want to runCan be downloaded from http://www.go.cd/community/plugins.html
/var/lib/go-server/pipelines/flyweightVersion control repositories are checked out here to scan for changes; sees a lot of i/oIs checked out automatically, but costs quite some time
/etc/goThe configuration of all pipelines, templates, environments and agentsKeep this backed up!
/var/log/go-serverAll 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 volumes

docker run -d \
    -p 8153:8153 \
    -p 8154:8154 \
    -e "AGENT_KEY=388b633a88de126531afa41eff9aa69e" \
    -v /mnt/persistent-disk/gocd-server/artifacts:/var/lib/go-server/artifacts \
    -v /mnt/persistent-disk/gocd-server/db:/var/lib/go-server/db/h2db \
    -v /mnt/persistent-disk/gocd-server/plugins:/var/lib/go-server/plugins/external \
    -v /mnt/persistent-disk/gocd-server/flyweight:/var/lib/go-server/pipelines/flyweight \
    -v /mnt/persistent-disk/gocd-server/config:/etc/go \
    -v /mnt/persistent-disk/gocd-server/logs:/var/log/go-server \
    -v /mnt/persistent-disk/gocd-server/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 999 go
useradd -r -g go -u 999 go

And then change the owner of the host directories

chown -R go:go /mnt/persistent-disk/gocd-server/artifacts
chown -R go:go /mnt/persistent-disk/gocd-server/db
chown -R go:go /mnt/persistent-disk/gocd-server/plugins
chown -R go:go /mnt/persistent-disk/gocd-server/flyweight
chown -R go:go /mnt/persistent-disk/gocd-server/config
chown -R go:go /mnt/persistent-disk/gocd-server/logs
chown -R go:go /mnt/persistent-disk/gocd-server/ssh

Port offloading

Running gocd server on port 80 and 443 causes the agent to fail connecting to the server, see https://github.com/gocd/gocd/issues/1459. So for serving gocd server on port 80 and 443 it's best to use a proxy in front of it, see http://www.go.cd/documentation/user/current/installation/configure_proxy.html.

Setup authentication

The simplest way to authenticate people is to create a password file for Go to use. Set USER_AUTH environment variable with a list of user:password variable, it will create a htpasswd file located in /etc/gocd-auth, then in the GoCD Server configuration page, enter the path /etc/gocd-auth in the "Password File Path" field.

docker run -d \
    -p 8153:8153 \
    -p 8154:8154 \
    -e "AGENT_KEY=388b633a88de126531afa41eff9aa69e" \
    -e "USER_AUTH=user1:pass1 user2:pass2 user3:pass3" \
    travix/gocd-server:latest

Docker Pull Command

docker pull travix/gocd-server