Browse Source

Merge branch 'main' into reference-docs

Dan Helfman 3 weeks ago
parent
commit
5e6ceea7e2
7 changed files with 40 additions and 9 deletions
  1. 1 1
      .eleventy.js
  2. 1 0
      NEWS
  3. 2 2
      docs/_includes/layouts/main.njk
  4. 32 3
      docs/docker-compose.yaml
  5. 1 1
      docs/how-to/develop-on-borgmatic.md
  6. 2 2
      docs/search.md
  7. 1 0
      scripts/dev-docs

+ 1 - 1
.eleventy.js

@@ -21,7 +21,7 @@ module.exports = function(eleventyConfig) {
             if (process.env.NODE_ENV == "production") {
                 return link;
             }
-            return link.replace('https://torsion.org/borgmatic/', 'http://localhost:8080/');
+            return link.replace('https://torsion.org/', 'http://localhost:8080/');
         }
     };
     let markdownItAnchorOptions = {

+ 1 - 0
NEWS

@@ -4,6 +4,7 @@
    https://torsion.org/borgmatic/
  * #1161: Fix a traceback (TypeError) in the "check" action with Python 3.14.
  * Add documentation search.
+ * Change the URL of the local documentation development server to be more like the production URL.
 
 2.0.9
  * #1105: More accurately collect Btrfs subvolumes to snapshot. As part of this, the Btrfs hook no

+ 2 - 2
docs/_includes/layouts/main.njk

@@ -10,7 +10,7 @@ headerClass: elv-header-default
         {% if page.url != '/search/' %}
         <div id="search-entrance">
             🔍
-            <form action="/search/">
+            <form action="/borgmatic/search/">
                 <label>
                     <input type="search" name="query" placeholder="Search">
                 </label>
@@ -21,7 +21,7 @@ headerClass: elv-header-default
             {% set navPages = collections.all | eleventyNavigation %}
             {% macro renderNavListItem(entry) -%}
             <li{% if entry.url == page.url %} class="elv-toc-active"{% endif %}>
-              <a {% if entry.url %}href="{% if borgmatic.environment == "production" %}https://torsion.org/borgmatic{% else %}http://localhost:8080{% endif %}{{ entry.url | url }}"{% endif %}>{{ entry.title }}</a>
+              <a {% if entry.url %}href="{% if borgmatic.environment == "production" %}https://torsion.org/borgmatic{% else %}http://localhost:8080/borgmatic{% endif %}{{ entry.url | url }}"{% endif %}>{{ entry.title }}</a>
             {%- if entry.children.length -%}
               <ul>
                 {%- for child in entry.children %}{{ renderNavListItem(child) }}{% endfor -%}

+ 32 - 3
docs/docker-compose.yaml

@@ -1,9 +1,38 @@
 services:
+  traefik:
+    image: public.ecr.aws/docker/library/traefik:3.5.3
+    container_name: borgmatic-docs-traefik
+    command:
+      - "--global.checkNewVersion=false"
+      - "--global.sendAnonymousUsage=false"
+      - "--entrypoints.web.address=:8080"
+      - "--accesslog"
+      - "--accesslog.fields.headers.defaultmode=keep"
+      - "--providers.docker"
+      - "--providers.docker.exposedbydefault=false"
+      - "--api.insecure=false"
+      - "--api.dashboard=false"
+      - "--log.level=WARN"
+    ports:
+      - "127.0.0.1:8080:8080"
+    volumes:
+      - ${CONTAINER_SOCKET_PATH:-/run/user/docker.sock}:/var/run/docker.sock:ro
   docs:
     image: borgmatic-docs
     container_name: borgmatic-docs
-    ports:
-      - 8080:80
+    labels:
+      - "traefik.enable=true"
+      - "traefik.http.routers.borgmatic-docs.rule=PathPrefix(`/borgmatic`)"
+#      - "traefik.http.routers.borgmatic-docs.middlewares=borgmatic-trailing-slash-redirectregex,borgmatic-docs-redirectregex,borgmatic-stripprefix"
+      - "traefik.http.routers.borgmatic-docs.middlewares=borgmatic-trailing-slash-redirectregex,borgmatic-stripprefix"
+      - "traefik.http.middlewares.borgmatic-trailing-slash-redirectregex.redirectregex.regex=^(.*)/borgmatic$$"
+      - "traefik.http.middlewares.borgmatic-trailing-slash-redirectregex.redirectregex.replacement=$${1}/borgmatic/"
+      - "traefik.http.middlewares.borgmatic-trailing-slash-redirectregex.redirectregex.permanent=true"
+#      - "traefik.http.middlewares.borgmatic-docs-redirectregex.redirectregex.regex=^(.*)/borgmatic/docs/(.*)$$"
+#      - "traefik.http.middlewares.borgmatic-docs-redirectregex.redirectregex.replacement=$${1}/borgmatic/$${2}"
+#      - "traefik.http.middlewares.borgmatic-docs-redirectregex.redirectregex.permanent=true"
+      - "traefik.http.middlewares.borgmatic-stripprefix.stripprefix.prefixes=/borgmatic"
+      - "traefik.http.routers.borgmatic-docs.entrypoints=web"
     build:
       dockerfile: docs/Dockerfile
       context: ..
@@ -16,6 +45,6 @@ services:
       - sh
       - -c
       - |
-        echo; echo "You can view dev docs at http://localhost:8080"; echo
+        echo; echo "You can view dev docs at http://localhost:8080/borgmatic/"; echo
     depends_on:
       - docs

+ 1 - 1
docs/how-to/develop-on-borgmatic.md

@@ -215,7 +215,7 @@ This script assumes you have permission to run `docker`. If you don't, then
 you may need to run with `sudo`.
 
 After you run the script, you can point your web browser at
-http://localhost:8080 to view the documentation with your changes.
+http://localhost:8080/borgmatic/ to view the documentation with your changes.
 
 To close the documentation server, ctrl-C the script. Note that it does not
 currently auto-reload, so you'll need to stop it and re-run it for any

+ 2 - 2
docs/search.md

@@ -2,8 +2,8 @@
 title: Search documentation
 eleventyExcludeFromCollections: true
 ---
-<link href="/pagefind/pagefind-ui.css" rel="stylesheet">
-<script src="/pagefind/pagefind-ui.js"></script>
+<link href="/borgmatic/pagefind/pagefind-ui.css" rel="stylesheet">
+<script src="/borgmatic/pagefind/pagefind-ui.js"></script>
 <div id="search"></div>
 <script>
     window.addEventListener('DOMContentLoaded', (event) => {

+ 1 - 0
scripts/dev-docs

@@ -6,6 +6,7 @@ USER_PODMAN_SOCKET_PATH=/run/user/$UID/podman/podman.sock
 
 if [ -e "$USER_PODMAN_SOCKET_PATH" ]; then
     export DOCKER_HOST="unix://$USER_PODMAN_SOCKET_PATH"
+    export CONTAINER_SOCKET_PATH="$USER_PODMAN_SOCKET_PATH"
 fi
 
 BUILDKIT_PROGRESS=plain docker-compose --file docs/docker-compose.yaml up --build --force-recreate