diff --git a/docs/.env b/docs/.env
new file mode 100644
index 00000000..c88bfa87
--- /dev/null
+++ b/docs/.env
@@ -0,0 +1 @@
+PORT=8080
\ No newline at end of file
diff --git a/docs/Dockerfile b/docs/Dockerfile
index 40add4ae..77e4f7a5 100644
--- a/docs/Dockerfile
+++ b/docs/Dockerfile
@@ -12,6 +12,7 @@ RUN /app/docs/fetch-contributors >> /contributors.html
FROM docker.io/node:22.4.0-alpine AS html
ARG ENVIRONMENT=production
+ARG PORT=${PORT}
WORKDIR /source
@@ -28,7 +29,7 @@ COPY --from=borgmatic /etc/borgmatic/options.json /source/docs/reference/configu
COPY --from=borgmatic /command-line/* /source/docs/_includes/borgmatic/command-line/
COPY --from=borgmatic /contributors.html /source/docs/_includes/borgmatic/contributors.html
COPY . /source
-RUN NODE_ENV=${ENVIRONMENT} npx eleventy --input=/source/docs --output=/output
+RUN NODE_ENV=${ENVIRONMENT} PORT=${PORT} npx eleventy --input=/source/docs --output=/output
RUN npx -y pagefind --site /output
FROM docker.io/nginx:1.26.1-alpine
diff --git a/docs/_data/borgmatic.js b/docs/_data/borgmatic.js
index 5d76ca01..27943c08 100644
--- a/docs/_data/borgmatic.js
+++ b/docs/_data/borgmatic.js
@@ -1,5 +1,6 @@
module.exports = function() {
return {
- environment: process.env.NODE_ENV || "development"
+ environment: process.env.NODE_ENV || "development",
+ port: process.env.PORT || 8080
};
};
diff --git a/docs/_includes/layouts/main.njk b/docs/_includes/layouts/main.njk
index 30af08df..bf9b529a 100644
--- a/docs/_includes/layouts/main.njk
+++ b/docs/_includes/layouts/main.njk
@@ -21,7 +21,7 @@ headerClass: elv-header-default
{% set navPages = collections.all | eleventyNavigation %}
{% macro renderNavListItem(entry) -%}
- {{ entry.title }}
+ {{ entry.title }}
{%- if entry.children.length -%}
{%- for child in entry.children %}{{ renderNavListItem(child) }}{% endfor -%}
diff --git a/docs/docker-compose.yaml b/docs/docker-compose.yaml
index 8c280a60..d2e8d685 100644
--- a/docs/docker-compose.yaml
+++ b/docs/docker-compose.yaml
@@ -2,10 +2,12 @@ services:
traefik:
image: public.ecr.aws/docker/library/traefik:3.5.3
container_name: borgmatic-docs-traefik
+ environment:
+ - PORT=${PORT:-8080}
command:
- "--global.checkNewVersion=false"
- "--global.sendAnonymousUsage=false"
- - "--entrypoints.web.address=:8080"
+ - "--entrypoints.web.address=:${PORT}"
- "--accesslog"
- "--accesslog.fields.headers.defaultmode=keep"
- "--providers.docker"
@@ -14,7 +16,7 @@ services:
- "--api.dashboard=false"
- "--log.level=WARN"
ports:
- - "127.0.0.1:8080:8080"
+ - "127.0.0.1:${PORT}:${PORT}"
volumes:
- ${CONTAINER_SOCKET_PATH:-/run/user/docker.sock}:/var/run/docker.sock:ro
docs:
@@ -37,6 +39,9 @@ services:
context: ..
args:
ENVIRONMENT: development
+ PORT: ${PORT:-8080}
+ environment:
+ - PORT=${PORT:-8080}
message:
image: alpine
container_name: borgmatic-docs-message
@@ -44,6 +49,6 @@ services:
- sh
- -c
- |
- echo; echo "You can view dev docs at http://localhost:8080/borgmatic/"; echo
+ echo; echo "You can view dev docs at http://localhost:${PORT}/borgmatic/"; echo
depends_on:
- docs
diff --git a/docs/how-to/develop-on-borgmatic.md b/docs/how-to/develop-on-borgmatic.md
index 762abc36..7c0b9077 100644
--- a/docs/how-to/develop-on-borgmatic.md
+++ b/docs/how-to/develop-on-borgmatic.md
@@ -190,8 +190,28 @@ This requires Docker (or Podman; see below) to be installed on your system.
This script assumes you have permission to run `docker`. If you don't, then
you may need to run with `sudo`.
+### How to choose a different port
+
+You can choose a different listening port in two ways:
+
+#### 1. Modify the `.env` file
+
+1. Open `docs/.env`.
+2. Change `PORT=8080` to your desired port number (e.g., `PORT=3000`).
+3. Run the development script: `scripts/dev-docs`.
+
+#### 2. Use an environment variable
+
+Alternatively, you can override the port directly from your terminal without
+modifying any files:
+
+```bash
+PORT=3000 ./scripts/dev-docs
+```
+
After you run the script, you can point your web browser at
-http://localhost:8080/borgmatic/ to view the documentation with your changes.
+http://localhost:8080/borgmatic/ (or your chosen port) 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
@@ -206,7 +226,8 @@ borgmatic's developer build for documentation optionally supports using
Setting up Podman is outside the scope of this documentation. But once you
install and configure Podman, then `scripts/dev-docs` should automatically use
-Podman instead of Docker.
+Podman instead of Docker (make sure you have
+[`podman-compose`](https://github.com/containers/podman-compose) installed).
## Use of generative AI
diff --git a/scripts/dev-docs b/scripts/dev-docs
index f1ac6139..405dc791 100755
--- a/scripts/dev-docs
+++ b/scripts/dev-docs
@@ -2,11 +2,11 @@
set -e
-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"
+if command -v podman-compose >/dev/null 2>&1; then
+ COMPOSE_CMD="podman-compose"
+ export CONTAINER_SOCKET_PATH="${XDG_RUNTIME_DIR:-/run/user/$UID}/podman/podman.sock"
+else
+ COMPOSE_CMD="docker-compose"
fi
-BUILDKIT_PROGRESS=plain docker-compose --file docs/docker-compose.yaml up --build --force-recreate
+BUILDKIT_PROGRESS=plain $COMPOSE_CMD --file docs/docker-compose.yaml up --build --force-recreate