Skip to content
This repository was archived by the owner on Apr 15, 2020. It is now read-only.

Commit 441c3b1

Browse files
authored
Merge pull request #4 from ninech/tested_linux_support
Improve Linux Support
2 parents da25ab0 + 7b1e8dc commit 441c3b1

File tree

10 files changed

+247
-55
lines changed

10 files changed

+247
-55
lines changed

Makefile

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
VERSION := `cat VERSION | tr -d '\n'`
12
COMMIT := `git show -s --format=%h`
23
DATE := `date -u +%FT%T%z`
34
TAG := `git describe --abbrev=0 --tags 2>/dev/null || echo "0.0.0"`
@@ -25,10 +26,28 @@ ifndef VERBOSE
2526
.SILENT:
2627
endif
2728

28-
.PHONY: clean run release tag build dist $(SUBDIRS) get-windows-dependencies
29+
.PHONY: clean run release tag build dist $(SUBDIRS) get-windows-dependencies install uninstall as_root
2930

3031
all: build
3132

33+
as_root:
34+
test "$$(id -u)" -eq "0" || ( echo "Please run 'make $(MAKECMDGOALS)' as root."; return 1 )
35+
36+
install: as_root
37+
systemctl stop reception || true
38+
cp reception /usr/bin/
39+
cp contrib/reception.service /etc/systemd/system/
40+
systemctl daemon-reload
41+
systemctl enable reception
42+
systemctl restart reception
43+
44+
uninstall: as_root
45+
systemctl stop reception || true
46+
systemctl disable reception || true
47+
rm /usr/bin/reception || true
48+
rm /etc/systemd/system/reception.service || true
49+
systemctl daemon-reload
50+
3251
# remove the mess created by make
3352
clean:
3453
$(GOCLEAN)
@@ -85,8 +104,6 @@ $(DIST_DIR)${BINARY_NAME}_mac_x64:
85104
$(SUBDIRTARGETS): $(SUBDIRS)
86105
$(SUBDIRS): ; $(MAKE) -C $@ $(MAKECMDGOALS)
87106

88-
# only perform a release if a VERSION is defined
89-
ifdef VERSION
90107
tag:
91108
# only tag on master branch!
92109
$(BRANCH) | grep -e "^master$$" > /dev/null \
@@ -100,7 +117,3 @@ tag:
100117
echo ""
101118
echo "Don't forget to push the new tag!"
102119
echo ""
103-
else
104-
tag:
105-
$(error You have not defined a VERSION. Run "make $(MAKECMDGOALS) VERSION=1.2.3" to set a version)
106-
endif

README.md

Lines changed: 89 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ even as you fire up and shut down new _docker-compose_ projects.
1717

1818
## Requirements
1919

20-
We depend on at least Go 1.9. Also you need to have superuser privileges on your computer.
20+
You need to have superuser privileges on your computer.
2121

2222
## Installation
2323

@@ -27,13 +27,50 @@ But for resolving `*.docker` to `localhost` (i.e. `127.0.0.1` or `::1`), changes
2727

2828
### Linux
2929

30-
Fetch and build *reception*:
30+
Install *reception*:
3131

32-
go get github.com/ninech/reception
32+
git clone https://github.com/ninech/reception.git
33+
make
3334

34-
Make sure that *reception* is responsible for resolving the `.docker` TLD:
35+
Proceed according to your linux configuration:
3536

36-
sudo -s
37+
#### Ubuntu 16.04/18.04
38+
39+
Instead of `.docker` as TLD it's the easiest to just use `.localhost` because that's already built-in in the `systemd-resolver.service`.
40+
41+
Now run *reception*:
42+
43+
sudo reception -tld localhost
44+
45+
Or install *reception* as systemd service:
46+
47+
sudo make install
48+
49+
Now try to go to http://reception.localhost.
50+
51+
#### Local dnsmasq resolver
52+
53+
If you use dnsmasq as your local resolver, add this line to your dnsmasq config:
54+
55+
address=/docker/127.0.0.1
56+
57+
It tells dnsmasq to resolve `*.docker` with the dnsserver listening at `127.0.0.1:53` (which will be *reception*).
58+
Then restart dnsmasq:
59+
60+
service dnsmasq restart
61+
62+
And now run *reception*:
63+
64+
sudo reception
65+
66+
You should be able to http://reception.docker now.
67+
68+
#### Non-systemd linux
69+
70+
Check the content of `/etc/hosts`.
71+
If it doesn't contain any nameservers pointing to `127.0.0.1`, `127.0.0.53` or `::1`, then this way of installation should work for you:
72+
73+
sudo -i
3774
mkdir /etc/resolver
3875
echo "nameserver ::1" > /etc/resolver/docker
3976
echo "nameserver 127.0.0.1" >> /etc/resolver/docker
@@ -42,7 +79,7 @@ Now run *reception*:
4279

4380
sudo reception
4481

45-
Try to go to http://reception.docker.
82+
Finally, try to go to http://reception.docker.
4683

4784
### macOS
4885

@@ -71,7 +108,8 @@ Now try to go to http://reception.docker.
71108

72109
## Configuration
73110

74-
_reception_ is customizable to some extend. See `reception -h` for a complete list of configuration parameters.
111+
_reception_ is customizable to some extend.
112+
See `reception -h` for a complete list of configuration parameters.
75113

76114
$ reception -h
77115
(c) 2017 Nine Internet Solutions AG
@@ -115,43 +153,49 @@ avoid port collisions across projects.
115153

116154
**Do**
117155

118-
version: '2'
119-
services:
120-
app:
121-
image: nginx
122-
depends_on: pgsql
123-
ports:
124-
- 80 <----- like this
125-
pgsql:
126-
image: postgresql
156+
```yaml
157+
version: '2'
158+
services:
159+
app:
160+
image: nginx
161+
depends_on: pgsql
162+
ports:
163+
- 80 <----- like this
164+
pgsql:
165+
image: postgresql
166+
```
127167
128168
**Don't**
129169
130-
version: '2'
131-
services:
132-
app:
133-
image: nginx
134-
depends_on: pgsql
135-
ports:
136-
- 80:80 <----- and _not_ like this (local port)
137-
pgsql:
138-
image: postgresql
139-
ports:
140-
- 5432:5432 <----- and _not_ like this (unnecessary port)
170+
```yaml
171+
version: '2'
172+
services:
173+
app:
174+
image: nginx
175+
depends_on: pgsql
176+
ports:
177+
- 80:80 <----- and _not_ like this (local port)
178+
pgsql:
179+
image: postgresql
180+
ports:
181+
- 5432:5432 <----- and _not_ like this (unnecessary port)
182+
```
141183
142184
### HTTP Port
143185
144186
In order to detect which port of you container "the http port" is, *reception* looks for the well-known ports
145187
80, 8080 and 3000. You can override this behaviour by setting the label `reception.http-port` to a port of your choice:
146188

147-
version: '2'
148-
services:
149-
app:
150-
image: special
151-
labels:
152-
reception.http-port: '1234' <--- like this
153-
ports:
154-
- 1234
189+
```yaml
190+
version: '2'
191+
services:
192+
app:
193+
image: special
194+
labels:
195+
reception.http-port: '1234' <--- like this
196+
ports:
197+
- 1234
198+
```
155199

156200
## Troubleshooting
157201

@@ -161,23 +205,23 @@ You must run *reception* as privileged user (i.e. `root`) for it to be able to b
161205

162206
### _docker-compose_ projects can't start because of port conflicts
163207

164-
Most probably you assigned a fixed port mapping for any exposed ports. Look for something like the following:
208+
Most probably you assigned a fixed port mapping for an exposed port. Look for something like the following:
165209

166210
```yml
167211
version: 2
168212
services:
169213
app:
170214
ports:
171-
- "80:80"
215+
- "8000:80" <---- like this
172216
```
173217

174-
In the case above, you would just replace `"80:80"` with `80`.
218+
In the case above, you would just replace `"8000:80"` with `80`.
175219

176220
### `reception.docker` does not resolve
177221

178222
First, check if *reception* is actually running.
179223

180-
Then see if `nslookup reception.docker` resolves to `127.0.0.1` or `::1`.
224+
Then see if `nslookup reception.docker` resolves to `127.0.0.1` or `::1` (respectively `nslookup reception.localhost` on Ubuntu).
181225

182226
If it doesn't, please flush the DNS cache:
183227

@@ -193,8 +237,12 @@ systemctl restart nscd
193237

194238
## Development
195239

240+
We depend on at least Go 1.11.
241+
196242
There is a `Makefile` with targets for any common task.
197243

244+
**Don't just use `go build`, as it will not bundle the resources!**
245+
198246
### Build
199247

200248
To build the project, run:
@@ -209,9 +257,9 @@ To run a snapshot of the project, run:
209257

210258
### Release
211259

212-
To cut a release of the project, run:
260+
To cut a release of the project, adjust the `VERSION` file and run:
213261

214-
make release VERSION=2.3.4
262+
make release
215263

216264
### Debug the Makefile
217265

VERSION

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2.0.0

contrib/reception.service

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[Unit]
2+
Description=This program shows all docker-compose projects that are running on a handy overview page.
3+
4+
[Install]
5+
WantedBy=multi-user.target
6+
7+
[Service]
8+
Type=simple
9+
ExecStart=/usr/bin/reception -tld localhost
10+
Restart=on-success
11+
CapabilityBoundingSet=CAP_NET_BIND_SERVICE
12+
ProtectSystem=strict
13+
ProtectHome=true
14+
PrivateTmp=true

docker/client.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ func (client *Client) Launch() error {
4646
return err
4747
}
4848
}
49-
return nil
5049
}
5150

5251
// handles an event emitted by Docker

go.mod

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
module github.com/ninech/reception
2+
3+
require (
4+
github.com/GeertJohan/go.incremental v0.0.0-20161212213043-1172aab96510 // indirect
5+
github.com/GeertJohan/go.rice v0.0.0-20170420135705-c02ca9a983da
6+
github.com/akavel/rsrc v0.0.0-20170831122431-f6a15ece2cfd // indirect
7+
github.com/daaku/go.zipexe v0.0.0-20150329023125-a5fe2436ffcb // indirect
8+
github.com/fsouza/go-dockerclient v1.3.1
9+
github.com/jessevdk/go-flags v1.4.0 // indirect
10+
github.com/kardianos/osext v0.0.0-20170510131534-ae77be60afb1 // indirect
11+
github.com/miekg/dns v1.0.13
12+
github.com/tdewolff/minify v2.3.5+incompatible
13+
github.com/tdewolff/parse v2.3.3+incompatible // indirect
14+
github.com/tdewolff/test v0.0.0-20171106182207-265427085153 // indirect
15+
golang.org/x/lint v0.0.0-20181011164241-5906bd5c48cd // indirect
16+
golang.org/x/tools v0.0.0-20181013145246-13216ffa54f0 // indirect
17+
)

0 commit comments

Comments
 (0)