Skip to main content

Sphinx Confluence Relay

pip Version Build Status

Overview

The project provides the ability to create a "relay" service that accepts generated manifest files from Atlassian Confluence Builder for Sphinx and publish them to a pre-configured Confluence Data Center instance (Confluence Cloud is not supported). Using such a service allows system administrators to setup publish relaying where users do not need to expose their Confluence tokens.

Requirements

Usage

Users of a running service will publish using at least three key components:

  • A data-embedded manifest generated from Atlassian Confluence Builder for Sphinx.
  • The key of a space to publish into.
  • The parent page name/identifier to publish documentation under.

A publish event will take a manifest and upload all pages/attachments into a given target space. After pages/attachments are uploaded, any legacy content hosted on Confluence will be removed. Publication and removals are contained to the descendants of the configured parent page. Requests that would require moving pages in a space into the parent page's descendants will be ignored.

Publish events are queued. The service can accept multiple requests and will process them in a first-in-first-out (FIFO) order. Pages/attachments are only uploaded if required (i.e. changed).

Users may use the REST interface of a hosted service utilizing any common tools (e.g. curl). Alternatively, if this package is installed on a client system, users may utilize the publish helper tool:

sphinx-confluence-relay-publish --help
 (or)
python -m sphinx_confluence_relay --help

For example:

sphinx-confluence-relay-publish http://upload.wiki.example.com/ --space-key MYSPACE --parent-page Documentation

If a manifest file is not provided via the --manifest argument, the default paths searched for will be:

scb-manifest.json
 (or)
_build/confluence/scb-manifest.json
 (or)
_build/singleconfluence/scb-manifest.json

If a system administrator has configured authentication requirements, a token can be passed a couple of ways. The utility accepts a token value from the environment:

SPHINX_CONFLUENCE_RELAY_PUBLISH_TOKEN

Passed in using the standard input stream with --password-stdin:

cat ~/.token | sphinx-confluence-relay-publish ... --password-stdin

Or passed in using the --token argument:

sphinx-confluence-relay-publish ... --token <TOKEN>

Service Installation

Configuration

The relay service relies on a TOML configuration file. A template of this configuration can be found in the root of this repository:

sphinx-confluence-relay.toml.default

A system administrator will typically prepare a sphinx-confluence-relay.toml file on a host. sphinx-confluence-relay will search for configurations found in the following paths:

sphinx-confluence-relay.toml
 (or)
/etc/sphinx-confluence-relay.toml  (non-Windows)

A bare minimum configuration required is the configuration of the Confluence Data Center API URL and the token that will be used for REST interaction:

[sphinx-confluence-relay]
confluence-url = 'https://wiki.example.com/rest/api/'
confluence-token = ''

If a system administrator wishes to require tokens for publish requests, they can register one or more tokens in a publish-tokens option:

publish-tokens = [
    'SOME_TOKEN',
]

By default, all spaces the Confluence token can access could be published to. If an environment is looking to restrict only publishing to specific pages, individual spaces can be populated in a spaces option:

spaces = [
    'MYSPACE',
]

For additional advanced options, refer to the template configuration.

Manual Service Setup

System administrators may manually setup using the following instructions. Adjusts paths to desired preferences.

Build a path to hold packages:

mkdir /opt/sphinx-confluence-relay
cd /opt/sphinx-confluence-relay

Create a virtual environment:

python -m venv .venv
source .venv/bin/activate

Install this service using pip:

pip install sphinx-confluence-relay

Place the prepare configuration file in the local directory with the name:

sphinx-confluence-relay.toml

Run this service:

uvicorn sphinx_confluence_relay.main:app --host 0.0.0.0 --port 8080

Docker

This project supports multiple ways to use this utility inside a Docker environment. A recommended choice is to use a pre-built image available from GitHub's container registry.

Pre-built image

A pre-built image can be acquired using the following command:

docker pull ghcr.io/jdknight/sphinx-confluence-relay

On the host what will run Docker, copy the configuration file into this path:

/etc/sphinx-confluence-relay.toml

Ensure the path is available for holding a database of queued requests and status information:

/var/lib/sphinx-confluence-relay/

The container than can be run using the following command:

docker run --name sphinx-confluence-relay --detach --restart unless-stopped \
    -p 8080:8080 \
    -v /etc/sphinx-confluence-relay.toml:/etc/sphinx-confluence-relay.toml:ro \
    -v /var/lib/sphinx-confluence-relay/:/database.db \
    ghcr.io/jdknight/sphinx-confluence-relay

Self-built image

Users who wish to manage their own image can do so with the Docker definitions found inside this repository. This can be done by cloning this repository on the host wanting to run the container. A Docker build can be run using:

docker build -t ghcr.io/jdknight/sphinx-confluence-relay \
    --detach -f docker/Dockerfile .

Then running the same docker run call mentioned above.

Self-managed Docker Compose

Users can also take advantage of the Docker compose definition. For a working directory to hold Docker Compose content, ensure a settings file is setup:

sphinx-confluence-relay.toml

Next, load up the container using docker compose:

docker compose build
docker compose up --detach

Both Docker build calls will by default load a container with the PyPI version of sphinx-confluence-relay. Users wanting to use the local implementation in their container can do so by performing a Docker build with the --build-arg local argument.

For example:

docker compose build --build-arg BUILD_MODE=local
docker compose up --detach

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sphinx_confluence_relay-0.0.0.tar.gz (476.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sphinx_confluence_relay-0.0.0-py3-none-any.whl (484.1 kB view details)

Uploaded Python 3

File details

Details for the file sphinx_confluence_relay-0.0.0.tar.gz.

File metadata

  • Download URL: sphinx_confluence_relay-0.0.0.tar.gz
  • Upload date:
  • Size: 476.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for sphinx_confluence_relay-0.0.0.tar.gz
Algorithm Hash digest
SHA256 681fe681220058979b4c94e851f7b87c5d32c18fe4fe13ee73be20cba7f71be9
MD5 69b38730405432b7a7a87e5263a4e258
BLAKE2b-256 fa0ca2e9227d35f38756a79d655de9b6cf6594d782941e2f7fc33218aa9bd660

See more details on using hashes here.

Provenance

The following attestation bundles were made for sphinx_confluence_relay-0.0.0.tar.gz:

Publisher: publish-pypi.yml on jdknight/sphinx-confluence-relay

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file sphinx_confluence_relay-0.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for sphinx_confluence_relay-0.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6f2fc9e5e50143d68aaf38fefc6a18293a220e730e11525cc130f7bce4386fb0
MD5 2b5229cb4fbccd213aaf765c3a1d9a9b
BLAKE2b-256 f81f03764ef6cd65c40ac04a2b8fe409b65493b48ac4b54ae10efb253a9f9e8e

See more details on using hashes here.

Provenance

The following attestation bundles were made for sphinx_confluence_relay-0.0.0-py3-none-any.whl:

Publisher: publish-pypi.yml on jdknight/sphinx-confluence-relay

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.2.0

2 files

0.1.0

2 files

This release

0.0.0 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page