diff --git a/.dockerignore b/.dockerignore index 142895ab..e687fd57 100755 --- a/.dockerignore +++ b/.dockerignore @@ -13,3 +13,6 @@ CHRIS_REMOTE_FS swarm/prod/secrets kubernetes/prod/base/secrets dc.out + +# created by `just prefer` +.preference diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4b00143a..752f2e2c 100755 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,9 +11,14 @@ on: jobs: test: runs-on: ubuntu-24.04 + strategy: + matrix: + engine: [ 'docker', 'podman' ] steps: - uses: actions/checkout@v4 - uses: taiki-e/install-action@just + - name: Set preference to use ${{ matrix.engine }} + run: just prefer ${{ matrix.engine }} - name: Build development image run: just build - name: Pull other images diff --git a/.gitignore b/.gitignore index 8bd8d4bd..f4bc8066 100755 --- a/.gitignore +++ b/.gitignore @@ -18,3 +18,6 @@ venv # created by dev container bc UBI sets HOME to the project src dir chris_backend/.config chris_backend/.bash_history + +# created by `just prefer` +.preference diff --git a/README.md b/README.md index 4721cad4..47ffd674 100755 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ The HTTP API primarily supports the [collection+json](http://amundsen.com/media- Development is mainly supported on Linux. MacOS and WSL on Windows also work (because Docker Desktop is a Linux VM). You will need at least 8GM RAM, 20GB disk space, and a good internet connection. -Install Docker (version 27 or above), Docker Compose, and [just](https://github.com/casey/just?tab=readme-ov-file#installation). +Install Docker (version 27 or above) or Podman (version 5.2 or above), Docker Compose, and [just](https://github.com/casey/just?tab=readme-ov-file#installation).
@@ -54,6 +54,28 @@ Docker Installation Instructions
+
+ +Podman Setup Instructions + + +Rootless Podman is supported. You must install and configure Podman to use `docker-compose`, _not_ `podman-compose`. `podman-compose` is missing features, see issues [#575](https://github.com/containers/podman-compose/issues/575) and [#866](https://github.com/containers/podman-compose/issues/866). + +A Podman daemon must be running, because _ChRIS_ runs containers of its own. To start the Podman daemon on Linux, run + +```shell +systemctl --user start podman.service +``` + +If both Podman and Docker are installed, Podman will be used by default. A preference to use either Podman or Docker can be set by running + +```shell +just prefer podman # or +just prefer docker +``` + +
+ ### Just Commands Development is handled by [`just`](https://just.systems). diff --git a/docker-compose_just.yml b/docker-compose_just.yml index f6aea634..0c4c0150 100644 --- a/docker-compose_just.yml +++ b/docker-compose_just.yml @@ -8,7 +8,7 @@ services: - tools volumes: - "./chrisomatic:/etc/chrisomatic:ro" - - "/var/run/docker.sock:/var/run/docker.sock" + - "${DOCKER_SOCK:-/var/run/docker.sock}:/var/run/docker.sock" working_dir: /etc/chrisomatic userns_mode: host depends_on: @@ -139,7 +139,7 @@ services: SECRET_KEY: secret REMOVE_JOBS: "yes" volumes: - - /var/run/docker.sock:/var/run/docker.sock + - "${DOCKER_SOCK:-/var/run/docker.sock}:/var/run/docker.sock" depends_on: - pfcon ports: diff --git a/justfile b/justfile index 987c636b..426ef814 100644 --- a/justfile +++ b/justfile @@ -78,4 +78,45 @@ run +command: # docker-compose ... helper function. docker-compose +command: - env UID=$(id -u) GID=$(id -g) docker compose -f '{{ compose_file }}' {{command}} + env UID=$(id -u) GID=$(id -g) DOCKER_SOCK=$(just get-socket) $(just get-engine) compose -f '{{ compose_file }}' {{command}} + +# Get the container engine to use (docker or podman) +get-engine: + @if [ -f '.preference' ]; then \ + cat .preference && exit 0; \ + elif type podman > /dev/null 2>&1; then \ + echo podman; \ + else \ + echo docker; \ + fi \ + +# Get the docker daemon socket +get-socket: + @if [ "$(just get-engine)" = 'podman' ]; then \ + just get-podman-socket; \ + else \ + echo '/var/lib/docker.sock'; \ + fi + +get-podman-socket: check-podman-socket + @podman info --format '{{{{ .Host.RemoteSocket.Path }}' + +# Ensure that the podman daemon is running. +check-podman-socket: + @if [ "$(podman info --format '{{{{ .Host.RemoteSocket.Exists }}')" != 'true' ]; then \ + echo 'Podman daemon not running. Please run `systemctl --user start podman.service`'; \ + exit 1; \ + fi + +# Set a preference for using either Docker or Podman. +prefer docker_or_podman: + @[ '{{docker_or_podman}}' = 'docker' ] || [ '{{docker_or_podman}}' = 'podman' ] \ + || ( \ + >&2 echo 'argument must be either "docker" or "podman"'; \ + exit 1 \ + ) + echo '{{docker_or_podman}}' > .preference + +# Remove your preference for Docker or Podman. +unset-preference: + rm -f .preference