Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 5e6e8b5

Browse files
authoredMay 31, 2020
Fixes #47: Added DEV_ADDR variable for custom mkdocs ip and port definition inside of container (#48)
1 parent bda83ca commit 5e6e8b5

File tree

5 files changed

+33
-21
lines changed

5 files changed

+33
-21
lines changed
 

‎.github/workflows/build_image.yml

+6-4
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,12 @@ name: Build & Test MKDocs
22

33
on:
44
push:
5-
branches: [ issue/*, feature/* ]
5+
branches: [issue/*, feature/*]
66
pull_request:
7-
branches: [ master ]
7+
branches: [master]
88

99
jobs:
10-
1110
build:
12-
1311
runs-on: ubuntu-latest
1412

1513
steps:
@@ -24,3 +22,7 @@ jobs:
2422
docker run -d --cap-add NET_ADMIN -p 8000:8000 --name mkdocs polinux/mkdocs:${RELEASE}
2523
sleep 10
2624
curl -sSLi http://127.0.0.1:8000 | grep '200 OK'
25+
# Test custom port
26+
docker run -d --cap-add NET_ADMIN -p 8001:9000 --name custom -e "DEV_ADDR=0.0.0.0:9000" polinux/mkdocs:${RELEASE}
27+
sleep 10
28+
curl -sSLi http://127.0.0.1:8001 | grep '200 OK'

‎Dockerfile

+10-9
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,18 @@ ADD container-files/ /
1515

1616
RUN \
1717
apk add --update \
18-
ca-certificates \
19-
bash \
20-
git \
21-
openssh \
22-
python3 \
23-
python3-dev \
24-
build-base && \
25-
pip3 install --upgrade pip && \
18+
ca-certificates \
19+
bash \
20+
git \
21+
openssh \
22+
python3 \
23+
python3-dev \
24+
py3-pip \
25+
build-base && \
26+
pip install --upgrade pip && \
2627
pip install mkdocs==${MKDOCS_VERSION} && \
2728
cd /bootstrap && pip install -e /bootstrap && \
2829
rm -rf /tmp/* /var/tmp/* /var/cache/apk/* /var/cache/distfiles/* && \
2930
chmod 600 /root/.ssh/config
3031

31-
CMD ["/usr/bin/bootstrap", "start"]
32+
CMD ["/usr/bin/bootstrap", "start"]

‎README.md

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
### MkDocs in a docker.
22

3-
![Docker Image MKDocs](https://github.com/pozgo/docker-mkdocs/workflows/Docker%20Image%20MKDocs/badge.svg?branch=master)
3+
[![Docker Image MKDocs](https://github.com/pozgo/docker-mkdocs/workflows/Docker%20Image%20MKDocs/badge.svg?branch=master)](https://github.com/pozgo/docker-mkdocs/actions?query=workflow%3A%22Build+%26+Test+MKDocs%22)
44
[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fpozgo%2Fdocker-mkdocs.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2Fpozgo%2Fdocker-mkdocs?ref=badge_shield)
55

66
[![GitHub Open Issues](https://img.shields.io/github/issues/pozgo/docker-mkdocs.svg)](https://github.com/pozgo/docker-mkdocs/issues)
@@ -25,7 +25,7 @@ version: '3'
2525
services:
2626
mkdocs:
2727
container_name: mkdocs
28-
image: polinux/mkdocs:1.1.0
28+
image: polinux/mkdocs:1.1.2
2929
restart: always
3030
ports:
3131
- "8000:8000"
@@ -53,6 +53,7 @@ services:
5353
|`GIT_BRANCH`|Self explanatory|`master`|
5454
|`AUTO_UPDATE`|Auto update for git repository support|`false`|
5555
|`UPDATE_INTERVAL`|Update interval in *minutes* - used only when `AUTO_UPDATE` set to `true`|every `15` minutes|
56+
|`DEV_ADDR`|Custom IP address and port to serve documentation locall|`0.0.0.0:8000`|
5657

5758
### Usage
5859

@@ -68,7 +69,7 @@ Custom config with `git` repository as source of documentation
6869
docker run \
6970
-ti \
7071
--name mkdocs \
71-
-p 80:8000 \
72+
-p 80:9000 \
7273
-e "ADD_MODULES=mkdocs-bootstrap mkdocs-gitbook mkdocs-bootstrap4" \
7374
-e "LIVE_RELOAD_SUPPORT=true" \
7475
-e "FAST_MODE=true" \
@@ -77,6 +78,7 @@ docker run \
7778
-e "GIT_BRANCH=develop" \
7879
-e "AUTO_UPDATE=true" \
7980
-e "UPDATE_INTERVAL=1" \
81+
-e "DEV_ADDR=0.0.0.0:9000" \
8082
-v ${HOME}/.ssh/id_rsa:/root/.ssh/id_rsa \
8183
polinux/mkdocs
8284
```

‎container-files/bootstrap/app/mkdocs/common.py

+11-4
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,11 @@ def start():
2424
_check_previous_installation()
2525
print('Starting MKDocs')
2626
os.chdir(docks_dir)
27-
os.system(f'mkdocs serve -a 0.0.0.0:8000 {_live_reload()} {_fast_mode()}')
27+
if "DEV_ADDR" in os.environ:
28+
_dev_addr = os.environ['DEV_ADDR']
29+
else:
30+
_dev_addr = '0.0.0.0:8000'
31+
os.system(f'mkdocs serve -a {_dev_addr} {_live_reload()} {_fast_mode()}')
2832

2933

3034
def _install_modules(modules):
@@ -45,13 +49,15 @@ def _check_previous_installation():
4549
:return:
4650
"""
4751
if not os.path.exists(docks_dir + '/mkdocs.yml'):
48-
print(colored(f'No documentation found in ({docks_dir}). Creating new one.', 'yellow'))
52+
print(colored(
53+
f'No documentation found in ({docks_dir}). Creating new one.', 'yellow'))
4954
if not os.path.exists(docks_dir):
5055
os.mkdir(docks_dir)
5156
print(colored(f'Starting fresh installation', 'green'))
5257
os.system(f'mkdocs new {docks_dir}/')
5358
else:
54-
print(colored(f'Detected previous installation in ({docks_dir}).', 'green'))
59+
print(
60+
colored(f'Detected previous installation in ({docks_dir}).', 'green'))
5561

5662

5763
def _live_reload():
@@ -111,7 +117,8 @@ def _clone_repo(repo):
111117

112118
if auto_update == 'true':
113119
print(colored(f'AUTO_UPDATE - [ ENABLED ]', 'green'))
114-
print(colored(f'UPDATE_INTERVAL set to every {interval} minute/s', 'green'))
120+
print(
121+
colored(f'UPDATE_INTERVAL set to every {interval} minute/s', 'green'))
115122
_set_auto_update(interval)
116123

117124

‎container-files/bootstrap/setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
setup(
44
name='bootstrap',
5-
version='0.0.2',
5+
version='1.0.0',
66
py_modules=['bootstrap'],
77
include_package_data=True,
88
install_requires=[

0 commit comments

Comments
 (0)