Skip to content

Commit

Permalink
Podman support
Browse files Browse the repository at this point in the history
  • Loading branch information
jennydaman committed Aug 29, 2024
1 parent b250b20 commit 99a6945
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 4 deletions.
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@ CHRIS_REMOTE_FS
swarm/prod/secrets
kubernetes/prod/base/secrets
dc.out

# created by `just prefer`
.preference
5 changes: 5 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
24 changes: 23 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).

<details>
<summary>
Expand All @@ -54,6 +54,28 @@ Docker Installation Instructions
</details>

<details>
<summary>
Podman Setup Instructions
</summary>

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
```

</details>

### Just Commands

Development is handled by [`just`](https://just.systems).
Expand Down
4 changes: 2 additions & 2 deletions docker-compose_just.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
43 changes: 42 additions & 1 deletion justfile
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 99a6945

Please sign in to comment.