Aller au contenu

Mkdocs

Mkdocs

Prérequis

Ajouter une source

Bash
nano /etc/apk/repositories

Changer la version pour edge

Mettre à jour

Bash
apk update
apk -U upgrade

Création d'un utilisateur

Bash
addgroup -S mkdocs 2>/dev/null
adduser -S -D -H -h /var/lib/mkdocs -g "mkdocs user" -s /bin/sh -G mkdocs mkdocs 2>/dev/null

Installation

Bash
apk --update add mkdocs-material py3-jinja2 py3-markdown py3-pygments py3-pymdown-extensions py3-babel py3-colorama py3-regex py3-requests py3-pathspec

Configuration - MODE LIVE (HORS PROD)

Créer le service

Bash
nano /etc/init.d/mkdocs-grid_01
Text Only
#!/sbin/openrc-run

name="mkdocs-grid_01"
command="/usr/bin/mkdocs serve"
command_args="-a 0.0.0.0:10800"
command_background="true"
pidfile="/var/run/${name}.pid"
: ${directory:=/mkdocs/grid_01}
: ${command_user:=mkdocs:mkdocs}
: ${umask:=0022}

depend() {
  need net
}

Rendre exécutable le service

Bash
chmod +x /etc/init.d/mkdocs-grid_01

Lancer au démarrage

Bash
rc-service mkdocs-grid_01 start
rc-update add mkdocs-grid_01

Nginx

Installation

Bash
apk add --update nginx

Configuration

nginx.conf

Bash
mv /etc/nginx/nginx.conf /etc/nginx/[old]-nginx.conf
nano /etc/nginx/nginx.conf
Text Only
user nginx;
worker_processes auto;

# Configures default error logger.
error_log /var/log/nginx/error.log warn; # Log warn, error, crit, alert, emerg

events {
    # The maximum number of simultaneous connections that can be opened by a worker process.
    worker_connections 1024; # increase if you need more connections
}

http {
    # server_names_hash_bucket_size controls the maximum length
    # of a virtual host entry (ie the length of the domain name).
    server_names_hash_bucket_size   64; # controls the maximum length of a virtual host entry (ie domain name)
    server_tokens                   off; # hide who we are, don't show nginx version to clients
    sendfile                        off; # can cause issues

    # nginx will find this file in the config directory set at nginx build time
    # Includes mapping of file name extensions to MIME types of responses
    include mime.types;

    # fallback in case we can't determine a type
    default_type application/octet-stream;

    # buffering causes issues, disable it
    # increase buffer size. still useful even when buffering is off
    proxy_buffering off;
    proxy_buffer_size 4k;

    # allow the server to close the connection after a client stops responding. Frees up socket-associated memory.
    reset_timedout_connection on;

    # Specifies the main log format.
    log_format main '$remote_addr - $remote_user [$time_local] "$request" '
            '$status $body_bytes_sent "$http_referer" '
            '"$http_user_agent" "$http_x_forwarded_for"';

    # Sets the path, format, and configuration for a buffered log write.
    # Buffer log writes to speed up IO, or disable them altogether
    access_log /var/log/nginx/access.log main buffer=16k;
    #access_log off;

    # Include files with config snippets into the root context.
    include conf.d/*.conf;

    # Includes virtual hosts configs.
    include http.d/*.conf;
}

mkdocs-grid_01.conf

Bash
mv /etc/nginx/http.d/default.conf /etc/nginx/http.d/default.conf.old
nano /etc/nginx/http.d/mkdocs-grid_01.conf
Text Only
1
2
3
4
5
6
7
8
server {
    listen 80;
    listen [::]:80;

    server_name localhost;

    root /mkdocs/mkdocs-grid_01/site;
}

Démarrer le service

Bash
rc-service nginx start
rc-update add nginx