Skip to content

Commit ef4a87b

Browse files
committed
Add Makefile for task automation
1 parent b7fad6a commit ef4a87b

File tree

3 files changed

+30
-18
lines changed

3 files changed

+30
-18
lines changed

Makefile

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
### HELP
2+
3+
.PHONY: help
4+
help: ## Print help
5+
@egrep "(^### |^\S+:.*##\s)" Makefile | sed 's/^###\s*//' | sed 's/^\(\S*\)\:.*##\s*\(.*\)/ \1 - \2/'
6+
7+
### DOCKER
8+
9+
.PHONY: run
10+
run: image ## docker run ...
11+
(docker stop linux-insides-book 2>&1) > /dev/null || true
12+
docker run --detach --rm -p 4000:4000 --name linux-insides-book --hostname linux-insides-book linux-insides-book
13+
14+
.PHONY: image
15+
image: ## docker image build ...
16+
docker image build --rm --squash --label linux-insides --tag linux-insides-book:latest -f Dockerfile . 2> /dev/null || \
17+
docker image build --rm --label linux-insides --tag linux-insides-book:latest -f Dockerfile .
18+
19+
### LAUNCH BROWSER
20+
21+
.PHONY: browse
22+
browse: ## Launch broweser
23+
@timeout 60 sh -c 'until nc -z 127.0.0.1 4000; do sleep 1; done' || true
24+
@(uname | grep Darwin > /dev/null) && open http://127.0.0.1:4000 || true
25+
@(uname | grep Linux > /dev/null) && xdg-open http://127.0.0.1:4000 || true

README.md

+4-18
Original file line numberDiff line numberDiff line change
@@ -63,28 +63,14 @@ In order to run your own copy of the book with gitbook within a local container:
6363
systemctl restart docker.service
6464
```
6565

66-
2. Build container image
66+
2. Run docker image
6767
```bash
68-
docker image build \
69-
--rm --squash \
70-
--label linux-insides \
71-
--tag linux-insides-book:latest \
72-
-f Dockerfile .
68+
make run
7369
```
7470

75-
3. Create and run book in local container
76-
```bash
77-
docker run \
78-
--detach \
79-
--rm \
80-
-p 4000:4000 \
81-
--name linux-insides-book \
82-
--hostname linux-insides-book \
83-
linux-insides-book
84-
```
71+
3. Open your local copy of linux insides book under this url
72+
http://localhost:4000 or run `make browse`
8573

86-
4. Open your local copy of linux insides book under this url
87-
http://localhost:4000
8874

8975
Contributions
9076
--------------

contributors.md

+1
Original file line numberDiff line numberDiff line change
@@ -134,3 +134,4 @@ Thank you to all contributors:
134134
* [Yuxin Wu](https://github.com/chaffz)
135135
* [Biao Ding](https://github.com/SmallPond)
136136
* [Arfy slowy](https://github.com/slowy07)
137+
* [Dexter Plameras](https://github.com/dexterp)

0 commit comments

Comments
 (0)