forked from gocd/docker-gocd-agent
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.md.erb
113 lines (72 loc) · 4.93 KB
/
README.md.erb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# GoCD Agent Docker image
[GoCD agent](https://www.gocd.io) docker image based on <%= distro %> <%= version %>.
# Issues, feedback?
Please make sure to log them at https://github.com/gocd/docker-gocd-agent.
# Changelog
Please checkout the changes made every release to the agent images at https://github.com/gocd/docker-gocd-agent/blob/master/CHANGELOG.md
# Usage
Start the container with this:
```
docker run -d -e GO_SERVER_URL=... gocd/<%= image_name %>:<%= image_tag %>
```
**Note:** Please make sure to *always* provide the version. We do not publish the `latest` tag. And we don't intend to.
This will start the GoCD agent and connect it the GoCD server specified by `GO_SERVER_URL`.
> **Note**: The `GO_SERVER_URL` must be an HTTPS url and end with `/go`, for e.g. `https://ip.add.re.ss:8154/go`
## Usage with docker GoCD server
If you have a [gocd-server container](https://hub.docker.com/r/gocd/gocd-server/) running and it's named `angry_feynman`, you can connect a gocd-agent container to it by doing:
```
docker run -itd -e GO_SERVER_URL=https://$(docker inspect --format='{{(index (index .NetworkSettings.IPAddress))}}' angry_feynman):$(docker inspect --format='{{(index (index .NetworkSettings.Ports "8154/tcp") 0).HostPort}}' angry_feynman)/go gocd/<%= image_name %>:<%= image_tag %>
```
# Available configuration options
## Auto-registering the agents
```
docker run -d \
-e AGENT_AUTO_REGISTER_KEY=... \
-e AGENT_AUTO_REGISTER_RESOURCES=... \
-e AGENT_AUTO_REGISTER_ENVIRONMENTS=... \
-e AGENT_AUTO_REGISTER_HOSTNAME=... \
gocd/<%= image_name %>:<%= image_tag %>
```
If the `AGENT_AUTO_REGISTER_*` variables are provided (we recommend that you do), then the agent will be automatically approved by the server. See the [auto registration docs](https://docs.gocd.io/current/advanced_usage/agent_auto_register.html) on the GoCD website.
## Usage with docker and swarm elastic agent plugins
This image will work well with the [docker elastic agent plugin](https://github.com/gocd-contrib/docker-elastic-agents) and the [docker swarm elastic agent plugin](https://github.com/gocd-contrib/docker-swarm-elastic-agents). No special configuration would be needed.
## Mounting volumes
The GoCD agent will store all configuration, logs and perform builds in `/godata`. If you'd like to provide secure credentials like SSH private keys among other things, you can mount `/home/go`.
```
docker run -v /path/to/godata:/godata -v /path/to/home-dir:/home/go gocd/<%= image_name %>:<%= image_tag %>
```
> **Note:** Ensure that `/path/to/home-dir` and `/path/to/godata` is accessible by the `go` user in container (`go` user - uid 1000).
## Tweaking JVM options (memory, heap etc)
JVM options can be tweaked using the environment variable `GO_AGENT_SYSTEM_PROPERTIES`.
```
docker run -e GO_AGENT_SYSTEM_PROPERTIES="-Dfoo=bar" gocd/<%= image_name %>:<%= image_tag %>
```
# Under the hood
The GoCD server runs as the `go` user, the location of the various directories is:
| Directory | Description |
|---------------------|----------------------------------------------------------------------------------|
| `/godata/config` | the directory where the GoCD configuration is store |
| `/godata/pipelines` | the directory where the agent will run builds |
| `/godata/logs` | the directory where GoCD logs will be written out to |
| `/home/go` | the home directory for the GoCD server |
# Troubleshooting
## The GoCD agent does not connect to the server
- Check if the docker container is running `docker ps -a`
- Check the STDOUT to see if there is any output that indicates failures `docker logs CONTAINER_ID`
- Check the agent logs `docker exec -it CONTAINER_ID /bin/bash`, then run `less /godata/logs/*.log` inside the container.
# Bugs with Docker Agent Images 17.3.0
* Anyone using our docker agent image as the base image for your customized image, and writing to `/home/go` as part of your Dockerfile, these changes in `/home/go` don't persist while you start the container with your custom image.
A fix has been applied [here](https://github.com/gocd/docker-gocd-agent/commit/27b8772) and will be available for subsequent releases of the docker images.
# License
```plain
Copyright 2017 ThoughtWorks, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
```