Skip to content

Commit b458000

Browse files
committed
updated documentation
1 parent 364e1ff commit b458000

File tree

2 files changed

+54
-44
lines changed

2 files changed

+54
-44
lines changed

README.md

Lines changed: 53 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,16 @@ _The [Mister Handy robot][wadsworth] of automation!_
66

77
Wadsworth is a git-driven task runner to automate the application of configs.
88

9+
## Overview
10+
11+
Wadsworth is a little tool for implementing [Git-Ops][git-ops] in single-server environments. It's analogous to
12+
[kube-applier][kube-applier], [Terraform][terraform], [Ansible][ansible] but for automating lone servers that do not
13+
need cluster-level orchestration.
14+
15+
Instead, Wadsworth aims to be extremely simple. You give it some Git repositories and tell it to run commands when those
16+
Git repositories receive commits and that's about it. It also provides a way of safely passing in credentials from
17+
[Hashicorp's Vault][vault].
18+
919
## Install
1020

1121
### Linux
@@ -19,16 +29,6 @@ curl -s https://raw.githubusercontent.com/Southclaws/wadsworth/master/install.sh
1929
It's primarily a server side tool aimed at Linux servers, so there aren't any install scripts for other platforms. Most
2030
Windows/Mac usage is probably just local testing so just use `go get` for these use-cases.
2131

22-
## Overview
23-
24-
Wadsworth is a little tool for implementing [Git-Ops][git-ops] in single-server environments. It's not a cloud/cluster
25-
tool however it could easily be used as one, but you'd probably be better off using something like
26-
[kube-applier][kube-applier], [Terraform][terraform], [Ansible][ansible] or any of these more "serious" tools.
27-
28-
Instead, Wadsworth aims to be extremely simple. You give it some Git repositories and tell it to run commands when those
29-
Git repositories receive commits and that's about it. It also provides a way of safely passing in credentials from
30-
[Hashicorp's Vault][vault] so you can say goodbye to storing your MySQL password in a .env file!
31-
3232
## Usage
3333

3434
Currently, Wadsworth has a single command: `run` and it takes a single parameter: a Git URL. This Git URL defines the
@@ -37,32 +37,7 @@ Currently, Wadsworth has a single command: `run` and it takes a single parameter
3737
this way instead of just using the target repos to define what Wadsworth should do is 1. to consolidate Wadsworth config
3838
into one place, 2. separate the config of the tools from the applications and 3. keep your target repos clean.
3939

40-
## Usage as a Docker Container
41-
42-
See the `docker-compose.yml` file for an example and read below for details.
43-
44-
You can run Wadsworth as a Docker container. If you're using it to deploy Docker containers via compose, this makes the
45-
most sense. This is quite simple and is best done by writing a Docker Compose configuration for Wadsworth in order to
46-
bootstrap your deployment.
47-
48-
The Wadsworth image is built on the `docker/compose` image, since most use-cases will use Docker or Compose to deploy
49-
services. This means you must mount the Docker API socket into the container, just like Portainer or cAdvisor or any of
50-
the other Docker tools that also run inside a container.
51-
52-
The socket is located by default at `/var/run/docker.sock` and the `docker/compose` image expects this path too, so you
53-
just need to add a volume mount to your compose that specifies `/var/run/docker.sock:/var/run/docker.sock`.
54-
55-
Another minor detail you should know is that Wadsworth exposes a `HOSTNAME` variable for the configuration script.
56-
However, when in a container, this hostname is a randomised string such as `b50fa67783ad`. This means, if your
57-
configuration performs checks such as `if (HOSTNAME === 'server031')`, this won't work. To resolve this, Wadsworth will
58-
attempt to read the environment variable `HOSTNAME` and use that instead of using `/etc/hostname`.
59-
60-
This means, you can bootstrap a Wadsworth deployment with only two variables:
61-
62-
```env
63-
VAULT_TOKEN=abcxyz
64-
HOSTNAME=server012
65-
```
40+
Wadsworth also has a Docker image - see below for docker-specific information.
6641

6742
### Configuration
6843

@@ -78,19 +53,12 @@ Compose stack whenever it changes:
7853
T({
7954
name: "my_app",
8055
url: "git@github.com:username/my-docker-compose-project",
56+
branch: "prod",
8157
up: ["docker-compose", "up", "-d"],
8258
down: ["docker-compose", "down"]
8359
});
8460
```
8561

86-
You can also specify branches by suffixing the URL with a `#` followed by the branch name:
87-
88-
```js
89-
...
90-
url: "git@github.com:username/my-docker-compose-project#development",
91-
...
92-
```
93-
9462
#### The `T` Function
9563

9664
The `T` function declares a "Target" which is essentially a Git repository. In this example, the repository
@@ -160,3 +128,44 @@ have a bunch of compose configs that all mount data to some path on the machine,
160128
[ansible]: https://ansible.com
161129
[vault]: https://vaultproject.io
162130
[dnscontrol]: https://stackexchange.github.io/dnscontrol/
131+
132+
## Usage as a Docker Container
133+
134+
See the `docker-compose.yml` file for an example and read below for details.
135+
136+
You can run Wadsworth as a Docker container. If you're using it to deploy Docker containers via compose, this makes the
137+
most sense. This is quite simple and is best done by writing a Docker Compose configuration for Wadsworth in order to
138+
bootstrap your deployment.
139+
140+
The Wadsworth image is built on the `docker/compose` image, since most use-cases will use Docker or Compose to deploy
141+
services. This means you must mount the Docker API socket into the container, just like Portainer or cAdvisor or any of
142+
the other Docker tools that also run inside a container.
143+
144+
The socket is located by default at `/var/run/docker.sock` and the `docker/compose` image expects this path too, so you
145+
just need to add a volume mount to your compose that specifies `/var/run/docker.sock:/var/run/docker.sock`.
146+
147+
Another minor detail you should know is that Wadsworth exposes a `HOSTNAME` variable for the configuration script.
148+
However, when in a container, this hostname is a randomised string such as `b50fa67783ad`. This means, if your
149+
configuration performs checks such as `if (HOSTNAME === 'server031')`, this won't work. To resolve this, Wadsworth will
150+
attempt to read the environment variable `HOSTNAME` and use that instead of using `/etc/hostname`.
151+
152+
This means, you can bootstrap a Wadsworth deployment with only two variables:
153+
154+
```env
155+
VAULT_TOKEN=abcxyz
156+
HOSTNAME=server012
157+
```
158+
159+
### Docker Compose and `./` in Container Volume Mounts
160+
161+
Another caveat to running Wadsworth in a container to execute `docker-compose` is the container filesystem will not
162+
match the host filesystem paths.
163+
164+
If you mount directories from your repository - a common strategy for versioning configuration - `./` will be expanded
165+
by Docker compose running inside the container, but this path may not be valid in the context of the Docker daemon,
166+
which will be running on the host.
167+
168+
The solution to this is both `DIRECTORY: "/cache"` and `/cache:/cache`: as long as the path used in the container also
169+
exists on the host, Docker compose will expand `./` to the same path as the host and everything will work fine.
170+
171+
This also means your config and target configurations will be persisted on the host's filesystem.

docker-compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ services:
1111
VAULT_PATH: "a/subdirectory/inside/vault/"
1212
volumes:
1313
- /var/run/docker.sock:/var/run/docker.sock
14+
- /cache:/cache

0 commit comments

Comments
 (0)