|
20 | 20 | build:
|
21 | 21 | runs-on: ubuntu-22.04
|
22 | 22 | env:
|
| 23 | + # Some pieces of code (image pulls for example) in podman consult TMPDIR or default to /var/tmp |
| 24 | + TMPDIR: /home/runner/.local/share/containers/tmpdir |
| 25 | + # Use the rootful instance of podman for sharing images with cri-o |
| 26 | + # https://podman-desktop.io/blog/sharing-podman-images-with-kubernetes-cluster#introduction |
| 27 | + # https://access.redhat.com/solutions/6986565 |
| 28 | + CONTAINER_HOST: unix:///var/run/podman/podman.sock |
23 | 29 | # We don't push here when building PRs, so we can use the same IMAGE_REGISTRY in all branches of the workflow
|
24 | 30 | IMAGE_REGISTRY: "ghcr.io/${{ github.repository }}/workbench-images"
|
25 | 31 | # GitHub image registry used for storing $(CONTAINER_ENGINE)'s cache
|
@@ -101,22 +107,45 @@ jobs:
|
101 | 107 |
|
102 | 108 | - name: Configure Podman
|
103 | 109 | run: |
|
104 |
| - set -x |
105 |
| - mkdir -p $HOME/.config/containers/ |
106 |
| - cp ci/cached-builds/containers.conf $HOME/.config/containers/containers.conf |
107 |
| - cp ci/cached-builds/storage.conf $HOME/.config/containers/storage.conf |
108 |
| -
|
109 |
| - # should at least reset storage when touching storage.conf |
110 |
| - podman system reset --force |
| 110 | + set -Eeuxo pipefail |
| 111 | +
|
| 112 | + # podman running as service ignores the TMPDIR env var here, let's give it a bind-mount to /var/tmp |
| 113 | + mkdir -p $TMPDIR |
| 114 | + sudo mount --bind -o rw,noexec,nosuid,nodev,bind $TMPDIR /var/tmp |
| 115 | +
|
| 116 | + # podman from brew has its own /etc (was giving me Failed to obtain podman configuration: runroot must be set) |
| 117 | + # the (default) config location is also where cri-o gets its storage defaults (that can be overriden in crio.conf) |
| 118 | + sudo cp ci/cached-builds/containers.conf /etc/containers.conf |
| 119 | + sudo cp ci/cached-builds/containers.conf /home/linuxbrew/.linuxbrew/opt/podman/etc/containers.conf |
| 120 | + sudo cp ci/cached-builds/storage.conf /etc/containers/storage.conf |
| 121 | + sudo cp ci/cached-builds/storage.conf /home/linuxbrew/.linuxbrew/opt/podman/etc/containers/storage.conf |
| 122 | + sudo cp ci/cached-builds/registries.conf /etc/containers/registries.conf |
| 123 | + sudo cp ci/cached-builds/registries.conf /home/linuxbrew/.linuxbrew/opt/podman/etc/containers/registries.conf |
| 124 | +
|
| 125 | + # should reset storage when changing storage.conf |
111 | 126 | mkdir -p $HOME/.local/share/containers/storage/tmp
|
| 127 | + # remote (CONTAINER_HOST) podman does not do reset (and refuses --force option) |
| 128 | + sudo /home/linuxbrew/.linuxbrew/opt/podman/bin/podman system reset --force |
112 | 129 |
|
113 |
| - # start systemd user service |
| 130 | + # https://github.com/containers/podman/blob/main/docs/tutorials/socket_activation.md |
114 | 131 | # since `brew services start podman` is buggy, let's do our own brew-compatible service
|
115 |
| - mkdir -p "${HOME}/.config/systemd/user/" |
116 |
| - cp ci/cached-builds/homebrew.podman.service "${HOME}/.config/systemd/user/homebrew.podman.service" |
117 |
| - systemctl --user daemon-reload |
118 |
| - systemctl --user start homebrew.podman.service |
119 |
| - echo "PODMAN_SOCK=/run/user/${UID}/podman/podman.sock" >> $GITHUB_ENV |
| 132 | + # Regarding directory paths, see https://unix.stackexchange.com/questions/224992/where-do-i-put-my-systemd-unit-file |
| 133 | + sudo mkdir -p /usr/local/lib/systemd/system/ |
| 134 | + sudo cp ci/cached-builds/podman.service /usr/local/lib/systemd/system/podman.service |
| 135 | + sudo cp ci/cached-builds/podman.socket /usr/local/lib/systemd/system/podman.socket |
| 136 | + sudo systemctl daemon-reload |
| 137 | + sudo systemctl unmask --now podman.service podman.socket |
| 138 | + sudo systemctl start podman.socket |
| 139 | +
|
| 140 | + # needed (much) later for trivy |
| 141 | + echo "PODMAN_SOCK=/var/run/podman/podman.sock" >> $GITHUB_ENV |
| 142 | +
|
| 143 | + # quick check podman works |
| 144 | + podman ps |
| 145 | +
|
| 146 | + - name: Show error logs (on failure) |
| 147 | + if: ${{ failure() }} |
| 148 | + run: journalctl -xe |
120 | 149 |
|
121 | 150 | - name: Calculate image name and tag
|
122 | 151 | id: calculated_vars
|
|
0 commit comments