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)

The 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 set up 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 prepared 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 that 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 then 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:/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.1.0.tar.gz (476.2 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.1.0-py3-none-any.whl (484.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: sphinx_confluence_relay-0.1.0.tar.gz
  • Upload date:
  • Size: 476.2 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.1.0.tar.gz
Algorithm Hash digest
SHA256 799a381e0ed063c3bbd68706f9cf0f8c787c51ce98e2798986f061f9b7e202da
MD5 ad3a61fd2111f21aa0f2f36dd6824b18
BLAKE2b-256 82d693bc7b2ef24000b999a48f8c38c276dfe245f9825cce3460631ebc997478

See more details on using hashes here.

Provenance

The following attestation bundles were made for sphinx_confluence_relay-0.1.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.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for sphinx_confluence_relay-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d02a1abf19a308e97ec293c682c7e0d4b65801ffb5ee520f913b7283b940398b
MD5 dd4ff0131576231dc016e6e9e8542cdc
BLAKE2b-256 9c4d29ada37719a2a4b5bbbf1055ca6d0aa3aade89f81dc176c26b975be50ce8

See more details on using hashes here.

Provenance

The following attestation bundles were made for sphinx_confluence_relay-0.1.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

This release

0.1.0 This release

2 files

0.0.0

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