Skip to content

Commit 47f3769

Browse files
committedJan 9, 2024
fix README
1 parent 241685f commit 47f3769

7 files changed

+93
-20
lines changed
 

‎Dockerfile

+6-3
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,19 @@ COPY --chmod=644 files/requirements.txt /requirements.txt
77

88
RUN apt update && \
99
apt full-upgrade -y && \
10-
apt install -y python3-pip supervisor git && \
11-
apt clean
10+
apt install -y python3-pip supervisor git
1211
RUN pip3 install --disable-pip-version-check --no-compile --requirement /requirements.txt
1312
RUN git clone https://gitlab.geant.net/devops/devops-wiki.git /code
1413
RUN /usr/local/bin/mkdocs build --site-dir /usr/share/nginx/html
14+
RUN apt-get -y --purge remove python3-pip && \
15+
apt-get -y --purge autoremove && \
16+
apt-get clean
1517
RUN rm -rf /root/.cache/pip/* /var/lib/apt/lists/*
1618

19+
COPY --chmod=644 files/default.conf /etc/nginx/conf.d/default.conf
1720
COPY --chmod=644 files/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
1821
COPY --chmod=644 files/hook.py /hook/hook.py
1922
COPY --chmod=755 files/05-scripts.sh /docker-entrypoint.d/05-scripts.sh
2023
COPY --chmod=755 files/pull-updates.sh /usr/local/bin/pull-updates.sh
2124

22-
EXPOSE 8000 8080
25+
EXPOSE 8000

‎Dockerfile-local

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@ RUN pip3 install --disable-pip-version-check --no-compile --requirement /require
1212
RUN git clone https://gitlab.geant.net/devops/devops-wiki.git /code
1313
RUN /usr/local/bin/mkdocs build --site-dir /usr/share/nginx/html
1414

15+
COPY --chmod=644 files/default.conf /etc/nginx/conf.d/default.conf
1516
COPY --chmod=644 files/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
1617
COPY --chmod=644 files/hook.py /hook/hook.py
1718
COPY --chmod=755 files/05-scripts.sh /docker-entrypoint.d/05-scripts.sh
1819
COPY --chmod=755 files/pull-updates.sh /usr/local/bin/pull-updates.sh
1920

20-
EXPOSE 8000 8080
21+
EXPOSE 8000

‎README.md

+12-7
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
1-
# Terraformator
1+
# DevOps Wiki
22

3-
Terraform unchained, a django UI for Terraform, with VMware, NSX and Infoblox
3+
Documentation as a code Wiki using MkDocs-material.
44

5+
This images provides
6+
7+
1. [Preamble](#preamble)
58
1. [Docker instructions](#docker-instructions)
69
1. [Create a new release](#create-a-new-release)
710

8-
```bash
9-
cd ~terraform/terraformator
10-
./manage.py makemigrations
11-
./manage.py migrate --run-syncdb
12-
```
11+
## Preamble
12+
13+
This container provides a hook URL (`/hook`) which trigger a pull from Git and rebuild the documentation site. You'll have to create a trigger on your CI.
14+
15+
You also need to supply a URL in `Dockerfile`/`Dockerfile-local`, for the repository (publicly available on read-only) where you store your Wiki code.
16+
17+
There is also a health-check URL (`/ping`).
1318

1419
## Docker instructions
1520

‎files/default.conf

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
server {
2+
listen 80;
3+
listen [::]:80;
4+
server_name localhost;
5+
6+
#access_log /var/log/nginx/host.access.log main;
7+
8+
location / {
9+
root /usr/share/nginx/html;
10+
index index.html index.htm;
11+
}
12+
13+
#error_page 404 /404.html;
14+
15+
# redirect server error pages to the static page /50x.html
16+
#
17+
error_page 500 502 503 504 /50x.html;
18+
location = /50x.html {
19+
root /usr/share/nginx/html;
20+
}
21+
22+
location /hook {
23+
proxy_pass http://localhost:8080/hook;
24+
proxy_set_header Host $host;
25+
proxy_set_header X-Real-IP $remote_addr;
26+
}
27+
28+
location /ping {
29+
proxy_pass http://localhost:8080/ping;
30+
proxy_set_header Host $host;
31+
proxy_set_header X-Real-IP $remote_addr;
32+
}
33+
34+
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
35+
#
36+
#location ~ \.php$ {
37+
# proxy_pass http://127.0.0.1;
38+
#}
39+
40+
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
41+
#
42+
#location ~ \.php$ {
43+
# root html;
44+
# fastcgi_pass 127.0.0.1:9000;
45+
# fastcgi_index index.php;
46+
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
47+
# include fastcgi_params;
48+
#}
49+
50+
# deny access to .htaccess files, if Apache's document root
51+
# concurs with nginx's one
52+
#
53+
#location ~ /\.ht {
54+
# deny all;
55+
#}
56+
}

‎files/hook.py

+15-7
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,26 @@
44
"""
55
import subprocess
66
from flask import Flask
7+
from flask import jsonify
78

8-
hook = Flask(__name__)
9+
HOOK = Flask(__name__)
910

1011

11-
@hook.route('/hook', methods=['GET', 'POST'])
12+
@HOOK.route("/hook", methods=["GET", "POST"])
1213
def trigger_script():
1314
"""Trigger the script to pull the latest changes from MkDocs"""
1415
try:
15-
subprocess.run(['/usr/local/bin/pull-updates.sh'], check=True)
16-
return 'MkDocs updated!', 200
16+
subprocess.run(["/usr/local/bin/pull-updates.sh"], check=True)
17+
return "MkDocs updated!", 200
1718
except subprocess.CalledProcessError as e:
18-
return f'Error updating MkDocs: {e}', 500
19+
return f"Error updating MkDocs: {e}", 500
1920

20-
if __name__ == '__main__':
21-
hook.run(debug=False)
21+
22+
@HOOK.route("/ping")
23+
def health_check():
24+
"""health-check"""
25+
return jsonify(status="OK")
26+
27+
28+
if __name__ == "__main__":
29+
HOOK.run(debug=False)

‎files/pull-updates.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ PATH=/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/sbin:/usr/local/bin
33

44
echo "Hook received. Pulling updates..."
55
cd /code
6-
git pull --quiet --rebase origin main # there seems to be a problem with TTY when using git pull
6+
git pull --quiet --rebase origin main # I noticed an issue with TTY when using git pull, hence the --quiet
77
mkdocs build --site-dir /usr/share/nginx/html

‎files/supervisord.conf

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@ stdout_logfile_maxbytes=0
1616
redirect_stderr=true
1717
user=root
1818
directory=/hook
19-
command=/usr/local/bin/gunicorn -b 0.0.0.0:8080 -t 100 --worker-tmp-dir=/dev/shm -w 2 hook:hook
19+
command=/usr/local/bin/gunicorn -b 0.0.0.0:8080 -t 100 --worker-tmp-dir=/dev/shm -w 2 hook:HOOK
2020
# for debug purpose you can add: --log-level debug

0 commit comments

Comments
 (0)
Please sign in to comment.