From 31a2ac914aa87d7d00c7b18ea04ec797bc96a261 Mon Sep 17 00:00:00 2001 From: Dan Helfman Date: Mon, 10 Apr 2023 14:26:54 -0700 Subject: [PATCH] Add optional support for running end-to-end tests and building documentation with rootless Podman instead of Docker. --- NEWS | 2 ++ docs/Dockerfile | 6 ++--- docs/how-to/develop-on-borgmatic.md | 36 ++++++++++++++++++++++++++++ scripts/run-end-to-end-dev-tests | 6 +++++ tests/end-to-end/docker-compose.yaml | 8 +++---- 5 files changed, 51 insertions(+), 7 deletions(-) diff --git a/NEWS b/NEWS index cd85182..81ebcf3 100644 --- a/NEWS +++ b/NEWS @@ -7,6 +7,8 @@ "match_archives" configuration option for the "transfer", "list", "rlist", and "info" actions. * #668: Fix error when running the "prune" action with both "archive_name_format" and "prefix" options set. + * Add optional support for running end-to-end tests and building documentation with rootless Podman + instead of Docker. 1.7.11 * #479, #588: BREAKING: Automatically use the "archive_name_format" option to filter which archives diff --git a/docs/Dockerfile b/docs/Dockerfile index dcda44f..b612596 100644 --- a/docs/Dockerfile +++ b/docs/Dockerfile @@ -1,4 +1,4 @@ -FROM alpine:3.17.1 as borgmatic +FROM docker.io/alpine:3.17.1 as borgmatic COPY . /app RUN apk add --no-cache py3-pip py3-ruamel.yaml py3-ruamel.yaml.clib @@ -8,7 +8,7 @@ RUN borgmatic --help > /command-line.txt \ echo -e "\n--------------------------------------------------------------------------------\n" >> /command-line.txt \ && borgmatic "$action" --help >> /command-line.txt; done -FROM node:19.5.0-alpine as html +FROM docker.io/node:19.5.0-alpine as html ARG ENVIRONMENT=production @@ -28,7 +28,7 @@ COPY . /source RUN NODE_ENV=${ENVIRONMENT} npx eleventy --input=/source/docs --output=/output/docs \ && mv /output/docs/index.html /output/index.html -FROM nginx:1.22.1-alpine +FROM docker.io/nginx:1.22.1-alpine COPY --from=html /output /usr/share/nginx/html COPY --from=borgmatic /etc/borgmatic/config.yaml /usr/share/nginx/html/docs/reference/config.yaml diff --git a/docs/how-to/develop-on-borgmatic.md b/docs/how-to/develop-on-borgmatic.md index 6699bdf..027a814 100644 --- a/docs/how-to/develop-on-borgmatic.md +++ b/docs/how-to/develop-on-borgmatic.md @@ -101,6 +101,30 @@ scripts/run-end-to-end-dev-tests Note that this scripts assumes you have permission to run Docker. If you don't, then you may need to run with `sudo`. + +#### Podman + +New in version 1.7.12 +borgmatic's end-to-end tests optionally support using +[rootless](https://github.com/containers/podman/blob/main/docs/tutorials/rootless_tutorial.md) +[Podman](https://podman.io/) instead of Docker. + +Setting up Podman is outside the scope of this documentation, but here are +some key points to double-check: + + * Install Podman along with `podman-docker` and your desired networking + support. + * Configure `/etc/subuid` and `/etc/subgid` to map users/groups for the + non-root user who will run tests. + * Create a non-root Podman socket for that user: + ```bash + systemctl --user enable --now podman.socket + ``` + +Then you'll be able to run end-to-end tests as per normal, and the test script +will automatically use your non-root Podman socket instead of a Docker socket. + + ## Code style Start with [PEP 8](https://www.python.org/dev/peps/pep-0008/). But then, apply @@ -149,3 +173,15 @@ http://localhost:8080 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 additional documentation changes to take effect. + + +#### Podman + +New in version 1.7.12 +borgmatic's developer build for documentation optionally supports using +[rootless](https://github.com/containers/podman/blob/main/docs/tutorials/rootless_tutorial.md) +[Podman](https://podman.io/) instead of Docker. + +Setting up Podman is outside the scope of this documentation. But once you +install `podman-docker`, then `scripts/dev-docs` should automatically use +Podman instead of Docker. diff --git a/scripts/run-end-to-end-dev-tests b/scripts/run-end-to-end-dev-tests index 575de00..032967f 100755 --- a/scripts/run-end-to-end-dev-tests +++ b/scripts/run-end-to-end-dev-tests @@ -10,5 +10,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" +fi + docker-compose --file tests/end-to-end/docker-compose.yaml up --force-recreate \ --renew-anon-volumes --abort-on-container-exit diff --git a/tests/end-to-end/docker-compose.yaml b/tests/end-to-end/docker-compose.yaml index 80f12e9..e6b0bf2 100644 --- a/tests/end-to-end/docker-compose.yaml +++ b/tests/end-to-end/docker-compose.yaml @@ -1,22 +1,22 @@ version: '3' services: postgresql: - image: postgres:13.1-alpine + image: docker.io/postgres:13.1-alpine environment: POSTGRES_PASSWORD: test POSTGRES_DB: test mysql: - image: mariadb:10.5 + image: docker.io/mariadb:10.5 environment: MYSQL_ROOT_PASSWORD: test MYSQL_DATABASE: test mongodb: - image: mongo:5.0.5 + image: docker.io/mongo:5.0.5 environment: MONGO_INITDB_ROOT_USERNAME: root MONGO_INITDB_ROOT_PASSWORD: test tests: - image: alpine:3.13 + image: docker.io/alpine:3.13 environment: TEST_CONTAINER: true volumes: