From 3e1a9e9dde1355f6fa80b154bda68af4fd2b33b6 Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Sun, 16 Mar 2025 18:09:37 +0100 Subject: [PATCH] Solved Sphinx Role bugs --- .../{templates/Dockerfile.j2 => files/Dockerfile} | 10 ++++------ roles/docker-sphinx/tasks/main.yml | 4 ++-- .../docker-sphinx/templates/docker-compose.yml.j2 | 3 ++- roles/docker-sphinx/vars/main.yml | 15 +++++++-------- 4 files changed, 15 insertions(+), 17 deletions(-) rename roles/docker-sphinx/{templates/Dockerfile.j2 => files/Dockerfile} (76%) diff --git a/roles/docker-sphinx/templates/Dockerfile.j2 b/roles/docker-sphinx/files/Dockerfile similarity index 76% rename from roles/docker-sphinx/templates/Dockerfile.j2 rename to roles/docker-sphinx/files/Dockerfile index cf3a9e55..b79265a3 100644 --- a/roles/docker-sphinx/templates/Dockerfile.j2 +++ b/roles/docker-sphinx/files/Dockerfile @@ -1,4 +1,5 @@ -FROM python:{{applications[application_id].version}} +ARG DOCKER_PYTHON_VERSION +FROM python:${DOCKER_PYTHON_VERSION} ARG SPHINX_SOURCE_DIR ARG SPHINX_BUILD_DIR @@ -6,12 +7,9 @@ ARG SPHINX_EXEC_DIR ARG SPHINX_APP_DIR ARG SPHINX_SOURCE_DIR_RELATIVE -# Set the environment variables so they are available during build +# Set the environment variables so they are available during build for Makefile ENV SPHINX_SOURCE_DIR=${SPHINX_SOURCE_DIR} -ENV SPHINX_SOURCE_DIR_RELATIVE=${SPHINX_SOURCE_DIR_RELATIVE} ENV SPHINX_BUILD_DIR=${SPHINX_BUILD_DIR} -ENV SPHINX_EXEC_DIR=${SPHINX_EXEC_DIR} -ENV SPHINX_APP_DIR=${SPHINX_APP_DIR} # Install required packages RUN apt-get update && apt-get install -y make curl @@ -32,4 +30,4 @@ RUN cd ${SPHINX_EXEC_DIR} && make html EXPOSE 8000 # Start a simple HTTP server to serve the built documentation -CMD ["python", "-m", "http.server", "8000", "--directory", "${SPHINX_BUILD_DIR}"] +CMD python -m http.server 8000 --directory "${SPHINX_BUILD_DIR}html/" diff --git a/roles/docker-sphinx/tasks/main.yml b/roles/docker-sphinx/tasks/main.yml index fd99fd1b..57e6985a 100644 --- a/roles/docker-sphinx/tasks/main.yml +++ b/roles/docker-sphinx/tasks/main.yml @@ -27,8 +27,8 @@ http_port: "{{ ports.localhost.http[application_id] }}" - name: "create {{ sphinx_docker_file }}" - template: - src: "Dockerfile.j2" + copy: + src: "Dockerfile" dest: "{{ sphinx_docker_file }}" mode: '770' force: yes diff --git a/roles/docker-sphinx/templates/docker-compose.yml.j2 b/roles/docker-sphinx/templates/docker-compose.yml.j2 index c257f557..80aa411d 100644 --- a/roles/docker-sphinx/templates/docker-compose.yml.j2 +++ b/roles/docker-sphinx/templates/docker-compose.yml.j2 @@ -8,7 +8,8 @@ services: SPHINX_BUILD_DIR: {{docker_output_dir}} SPHINX_EXEC_DIR: {{docker_exec_dir}} SPHINX_APP_DIR: {{docker_app_dir}} - SPINX_SOURCE_DIR_RELATIVE: {{host_sphinx_source_dir_relative}} + SPHINX_SOURCE_DIR_RELATIVE: {{host_sphinx_source_dir_relative}} + DOCKER_PYTHON_VERSION: {{applications[application_id].version}} ports: - "127.0.0.1:{{ports.localhost.http[application_id]}}:8000" healthcheck: diff --git a/roles/docker-sphinx/vars/main.yml b/roles/docker-sphinx/vars/main.yml index 1848eac2..a87c7733 100644 --- a/roles/docker-sphinx/vars/main.yml +++ b/roles/docker-sphinx/vars/main.yml @@ -1,12 +1,11 @@ application_id: "sphinx" -host_sphinx_source_dir_relative: "volumes/source/" # Place where the sphinx source repository is stored on the host -host_sphinx_source_dir_absolute: "{{docker_compose.directories.instance}}{{host_sphinx_source_dir_relative}}" # Place where the sphinx source repository is stored on the host +host_sphinx_source_dir_relative: "volumes/source/" # Place where the sphinx source repository is stored on the host +host_sphinx_source_dir_absolute: "{{docker_compose.directories.instance}}{{host_sphinx_source_dir_relative}}" # Place where the sphinx source 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/" -docker_html_output_dir: "{{docker_output_dir}}html/" # Folder to which the output is fuuuucking putted! -docker_exec_dir: "{{docker_app_dir}}{{applications.sphinx.sphinx_exec_dir_relative}}" # Folder which contains the sphinxs makefile and logic +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_exec_dir: "{{docker_app_dir}}{{applications.sphinx.sphinx_exec_dir_relative}}" # Folder which contains the sphinxs makefile and logic -sphinx_docker_file: "{{ docker_compose.directories.instance }}Dockerfile" # Path to the Dockerfile to build sphinx \ No newline at end of file +sphinx_docker_file: "{{ docker_compose.directories.instance }}Dockerfile" # Path to the Dockerfile to build sphinx \ No newline at end of file