mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2025-08-29 15:06:26 +02:00
Added sphinx docker role draft
This commit is contained in:
21
roles/docker-sphinx/README.md
Normal file
21
roles/docker-sphinx/README.md
Normal file
@@ -0,0 +1,21 @@
|
||||
# Sphinx Documentation Role
|
||||
|
||||
## Description
|
||||
|
||||
This Ansible role automates the building and deployment of Sphinx documentation using Docker. It pulls the CyMaIS repository, builds the documentation with Sphinx, and serves the generated HTML files via a lightweight HTTP server.
|
||||
|
||||
## 📌 Overview
|
||||
|
||||
Optimized for containerized environments, this role ensures that your documentation is consistently built and deployed with minimal manual intervention. It leverages Docker and Docker Compose for reproducible builds, enabling dynamic configuration of source and output directories.
|
||||
|
||||
## Purpose
|
||||
|
||||
The primary purpose of this role is to streamline the documentation workflow for your project. By automating the Sphinx build process and containerizing the deployment, the role reduces manual overhead and ensures that the latest documentation is always available for review and distribution.
|
||||
|
||||
## Features
|
||||
|
||||
- **Automated Build:** Triggers the Sphinx build process automatically via a Makefile.
|
||||
- **Docker Integration:** Uses Docker and Docker Compose to containerize the documentation build and serve process.
|
||||
- **Dynamic Configuration:** Allows customizable source and output directories through variables.
|
||||
- **Consistent Deployment:** Ensures that the generated documentation is served reliably with minimal configuration.
|
||||
- **Easy Updates:** Pulls the latest version of the project repository and rebuilds the documentation seamlessly.
|
28
roles/docker-sphinx/meta/main.yml
Normal file
28
roles/docker-sphinx/meta/main.yml
Normal file
@@ -0,0 +1,28 @@
|
||||
---
|
||||
galaxy_info:
|
||||
author: "Marko Pjevac, Kevin Veen-Birkenbach"
|
||||
description: "Automates building and serving Sphinx documentation. Ideal for any project, it pulls your repository, builds the docs, and serves them with ease."
|
||||
license: "CyMaIS NonCommercial License (CNCL)"
|
||||
license_url: "https://s.veen.world/cncl"
|
||||
company: |
|
||||
Kevin Veen-Birkenbach
|
||||
Consulting & Coaching Solutions
|
||||
https://www.veen.world
|
||||
min_ansible_version: "2.9"
|
||||
platforms:
|
||||
- name: Docker
|
||||
versions:
|
||||
- all
|
||||
- name: Linux
|
||||
versions:
|
||||
- all
|
||||
galaxy_tags:
|
||||
- documentation
|
||||
- sphinx
|
||||
- docker
|
||||
- automation
|
||||
- deployment
|
||||
repository: "https://s.veen.world/cymais"
|
||||
issue_tracker_url: "https://s.veen.world/cymaisissues"
|
||||
documentation: "https://s.veen.world/cymais"
|
||||
dependencies: []
|
31
roles/docker-sphinx/tasks/main.yml
Normal file
31
roles/docker-sphinx/tasks/main.yml
Normal file
@@ -0,0 +1,31 @@
|
||||
---
|
||||
# Docker Routines
|
||||
- name: "include docker-compose role"
|
||||
include_role:
|
||||
name: docker-compose
|
||||
|
||||
- name: pull cymais repository
|
||||
git:
|
||||
repo: "{{ repository_address_cymais }}"
|
||||
dest: "{{ host_cymais_volume_dir_absolute }}"
|
||||
update: yes
|
||||
notify: docker compose project setup
|
||||
become: true
|
||||
|
||||
- name: "include role nginx-domain-setup for {{application_id}}"
|
||||
include_role:
|
||||
name: nginx-domain-setup
|
||||
vars:
|
||||
domain: "{{ domains[application_id] }}"
|
||||
http_port: "{{ ports.localhost.http[application_id] }}"
|
||||
|
||||
- name: "create {{ sphinx_docker_file }}"
|
||||
template:
|
||||
src: "Dockerfile.j2"
|
||||
dest: "{{ sphinx_docker_file }}"
|
||||
mode: '770'
|
||||
force: yes
|
||||
notify: docker compose project setup
|
||||
|
||||
- name: "copy docker-compose.yml and env file"
|
||||
include_tasks: copy-docker-compose-and-env.yml
|
22
roles/docker-sphinx/templates/Dockerfile.j2
Normal file
22
roles/docker-sphinx/templates/Dockerfile.j2
Normal file
@@ -0,0 +1,22 @@
|
||||
FROM python:{{applications[application_id].version}}
|
||||
|
||||
# Install required packages including 'make'
|
||||
RUN apt-get update && apt-get install -y make
|
||||
|
||||
# Set the working directory
|
||||
WORKDIR {{docker_app_dir}}
|
||||
|
||||
# Copy the project files into the container
|
||||
COPY {{host_cymais_volume_dir_relative}} {{docker_app_dir}}
|
||||
|
||||
# Install Python packages via requirements.txt
|
||||
RUN cd {{docker_sphinx_dir}} && pip install --upgrade pip && pip install -r requirements.txt
|
||||
|
||||
# Build the HTML documentation using Sphinx with the defined directories
|
||||
RUN cd {{docker_sphinx_dir}} && make html
|
||||
|
||||
# Expose port 8000 where the HTTP server will run
|
||||
EXPOSE 8000
|
||||
|
||||
# Start a simple HTTP server to serve the built documentation
|
||||
CMD ["python", "-m", "http.server", "8000", "--directory", "${BUILD_DIR}"]
|
13
roles/docker-sphinx/templates/docker-compose.yml.j2
Normal file
13
roles/docker-sphinx/templates/docker-compose.yml.j2
Normal file
@@ -0,0 +1,13 @@
|
||||
services:
|
||||
application:
|
||||
build: .
|
||||
ports:
|
||||
- "127.0.0.1:{{ports.localhost.http[application_id]}}:8000"
|
||||
healthcheck:
|
||||
test: ["CMD", "curl", "-f", "http://127.0.0.1:8000"]
|
||||
interval: 1m
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
{% include 'templates/docker/container/networks.yml.j2' %}
|
||||
|
||||
{% include 'templates/docker/compose/networks.yml.j2' %}
|
2
roles/docker-sphinx/templates/env.j2
Normal file
2
roles/docker-sphinx/templates/env.j2
Normal file
@@ -0,0 +1,2 @@
|
||||
SOURCE_DIR={{docker_source_dir}}
|
||||
BUILD_DIR={{docker_output_dir}}
|
13
roles/docker-sphinx/vars/main.yml
Normal file
13
roles/docker-sphinx/vars/main.yml
Normal file
@@ -0,0 +1,13 @@
|
||||
application_id: "sphinx"
|
||||
|
||||
repository_address_cymais: "https://github.com/kevinveenbirkenbach/cymais.git" # Repository address to pull cymais from
|
||||
|
||||
host_cymais_volume_dir_absolute: "{{docker_compose.directories.volumes}}cymais/" # Place where the cymais repository is stored on the host
|
||||
host_cymais_volume_dir_relative: "volumes/cymais/" # Place where the cymais repository is stored on the host
|
||||
|
||||
docker_app_dir: "/app/" # Folder in which the application is running
|
||||
docker_source_dir: "{{docker_app_dir}}" # Folder which is used to be screened
|
||||
docker_output_dir: "/docs/" # Folder to which the output is fuuuucking putted!
|
||||
docker_sphinx_dir: "{{docker_app_dir}}/sphinx/" # Folder which contains the sphinxs makefile and logic
|
||||
|
||||
sphinx_docker_file: "{{ docker_compose.directories.instance }}/Dockerfile"
|
Reference in New Issue
Block a user