Leopold Schabel | 2983d72 | 2019-10-23 12:16:42 +0200 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | set -euo pipefail |
| 3 | |
| 4 | # Our local user needs write access to /dev/kvm (best accomplished by |
| 5 | # adding your user to the kvm group). |
| 6 | if ! touch /dev/kvm; then |
| 7 | echo "Cannot write to /dev/kvm - please verify permissions." |
| 8 | exit 1 |
| 9 | fi |
| 10 | |
| 11 | # The KVM module needs to be loaded, since our container is unprivileged |
| 12 | # and won't be able to do it itself. |
| 13 | if ! [[ -d /sys/module/kvm ]]; then |
| 14 | echo "kvm module not loaded - please modprobe kvm" |
| 15 | exit 1 |
| 16 | fi |
| 17 | |
| 18 | # Rebuild base image |
Hendrik Hofstadt | 0d7c91e | 2019-10-23 21:44:47 +0200 | [diff] [blame^] | 19 | podman build -t nexantic-builder build |
Leopold Schabel | 2983d72 | 2019-10-23 12:16:42 +0200 | [diff] [blame] | 20 | |
| 21 | # Set up SELinux contexts to prevent the container from writing to |
| 22 | # files that would allow for easy breakouts via tools ran on the host. |
| 23 | chcon -R system_u:object_r:container_file_t:s0 . |
| 24 | chcon -R unconfined_u:object_r:user_home_t:s0 \ |
| 25 | .arcconfig .idea .git |
| 26 | |
Leopold Schabel | 3ea7070 | 2019-10-23 16:40:06 +0200 | [diff] [blame] | 27 | # TODO(leo): mount .cache/bazel on a volume (waiting for podman issue to be fixed) |
| 28 | # https://github.com/containers/libpod/issues/4318 |
Leopold Schabel | 2983d72 | 2019-10-23 12:16:42 +0200 | [diff] [blame] | 29 | podman run -it -d \ |
| 30 | -v $(pwd):/work \ |
Leopold Schabel | 043daa5 | 2019-10-28 11:48:45 +0000 | [diff] [blame] | 31 | -v smalltown-gopath:/user/go/pkg \ |
| 32 | -v smalltown-gobuildcache:/user/.cache/go-build \ |
| 33 | -v smalltown-bazelcache:/user/.cache/bazel/_bazel_root/cache \ |
| 34 | --tmpfs=/user/.cache/bazel:exec \ |
Leopold Schabel | 2983d72 | 2019-10-23 12:16:42 +0200 | [diff] [blame] | 35 | --device /dev/kvm \ |
Leopold Schabel | 7afd390 | 2019-10-23 12:16:57 +0200 | [diff] [blame] | 36 | --privileged \ |
Leopold Schabel | 52804a1 | 2019-10-24 02:17:13 +0200 | [diff] [blame] | 37 | --userns=keep-id \ |
Hendrik Hofstadt | 0d7c91e | 2019-10-23 21:44:47 +0200 | [diff] [blame^] | 38 | --name=nexantic-dev \ |
| 39 | nexantic-builder |