General Sphinx optimations

This commit is contained in:
2025-03-16 17:24:50 +01:00
parent 2095f16402
commit 985ed797bd
8 changed files with 62 additions and 36 deletions

View File

@@ -1,22 +1,35 @@
FROM python:{{applications[application_id].version}}
# Install required packages including 'make'
RUN apt-get update && apt-get install -y make
ARG SPHINX_SOURCE_DIR
ARG SPHINX_BUILD_DIR
ARG SPHINX_EXEC_DIR
ARG SPHINX_APP_DIR
ARG SPHINX_SOURCE_DIR_RELATIVE
# Set the environment variables so they are available during build
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
# Set the working directory
WORKDIR {{docker_app_dir}}
WORKDIR ${SPHINX_APP_DIR}
# Copy the project files into the container
COPY {{host_cymais_volume_dir_relative}} {{docker_app_dir}}
COPY ${SPHINX_SOURCE_DIR_RELATIVE} ${SPHINX_APP_DIR}
# Install Python packages via requirements.txt
RUN cd {{docker_sphinx_dir}} && pip install --upgrade pip && pip install -r requirements.txt
RUN cd ${SPHINX_EXEC_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
RUN cd ${SPHINX_EXEC_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}"]
CMD ["python", "-m", "http.server", "8000", "--directory", "${SPHINX_BUILD_DIR}"]

View File

@@ -1,6 +1,14 @@
services:
application:
build: .
build:
context: .
dockerfile: Dockerfile
args:
SPHINX_SOURCE_DIR: {{docker_source_dir}}
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}}
ports:
- "127.0.0.1:{{ports.localhost.http[application_id]}}:8000"
healthcheck:
@@ -8,6 +16,7 @@ services:
interval: 1m
timeout: 10s
retries: 3
{% include 'roles/docker-compose/templates/services/base.yml.j2' %}
{% include 'templates/docker/container/networks.yml.j2' %}
{% include 'templates/docker/compose/networks.yml.j2' %}

View File

@@ -1,2 +0,0 @@
SOURCE_DIR={{docker_source_dir}}
BUILD_DIR={{docker_output_dir}}