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. |
Leopold Schabel | 5ed291e | 2019-11-14 19:09:24 +0100 | [diff] [blame] | 23 | chcon -Rh system_u:object_r:container_file_t:s0 . |
| 24 | |
| 25 | # Ignore errors - these might already be masked, like when synchronizing the source. |
| 26 | ! chcon -Rh unconfined_u:object_r:user_home_t:s0 \ |
Leopold Schabel | 2983d72 | 2019-10-23 12:16:42 +0200 | [diff] [blame] | 27 | .arcconfig .idea .git |
| 28 | |
Leopold Schabel | 052af2d | 2019-11-06 02:21:53 +0000 | [diff] [blame] | 29 | # Keep this in sync with ci.sh: |
| 30 | |
Hendrik Hofstadt | 3e6018f | 2019-10-28 21:29:42 +0100 | [diff] [blame] | 31 | podman pod create --name nexantic |
| 32 | |
Leopold Schabel | 8b9c055 | 2019-11-15 14:07:45 +0100 | [diff] [blame] | 33 | # Mount bazel root to identical paths inside and outside the container. |
| 34 | # This caches build state even if the container is destroyed, and |
| 35 | BAZEL_ROOT=${HOME}/.cache/bazel-nxt |
Leopold Schabel | 8b9c055 | 2019-11-15 14:07:45 +0100 | [diff] [blame] | 36 | mkdir -p ${BAZEL_ROOT} |
| 37 | |
Leopold Schabel | 399fe83 | 2019-11-15 21:15:30 +0100 | [diff] [blame] | 38 | # The Bazel plugin injects a Bazel repository into the sync command line, |
| 39 | # We need to copy the aspect repository and apply a custom patch. |
Leopold Schabel | 8cc81f6 | 2020-01-06 17:04:54 +0100 | [diff] [blame] | 40 | IJ_HOME=$(echo ${HOME}/.IntelliJIdea* | tr ' ' '\n' | sort | tail -n 1) |
| 41 | ASPECT_ORIG=${IJ_HOME}/config/plugins/ijwb/aspect |
Leopold Schabel | 399fe83 | 2019-11-15 21:15:30 +0100 | [diff] [blame] | 42 | |
| 43 | ASPECT_PATH=${BAZEL_ROOT}/ijwb_aspect |
| 44 | rm -rf "$ASPECT_PATH" |
| 45 | cp -r "$ASPECT_ORIG" "$ASPECT_PATH" |
| 46 | patch -d "$ASPECT_PATH" -p1 < scripts/patches/bazel_intellij_aspect_filter.patch |
| 47 | |
Leopold Schabel | 2983d72 | 2019-10-23 12:16:42 +0200 | [diff] [blame] | 48 | podman run -it -d \ |
Leopold Schabel | 8b9c055 | 2019-11-15 14:07:45 +0100 | [diff] [blame] | 49 | -v $(pwd):$(pwd) \ |
| 50 | -w $(pwd) \ |
| 51 | --volume=${BAZEL_ROOT}:${BAZEL_ROOT} \ |
Leopold Schabel | 2983d72 | 2019-10-23 12:16:42 +0200 | [diff] [blame] | 52 | --device /dev/kvm \ |
Leopold Schabel | 7afd390 | 2019-10-23 12:16:57 +0200 | [diff] [blame] | 53 | --privileged \ |
Hendrik Hofstadt | 3e6018f | 2019-10-28 21:29:42 +0100 | [diff] [blame] | 54 | --pod nexantic \ |
Hendrik Hofstadt | 0d7c91e | 2019-10-23 21:44:47 +0200 | [diff] [blame] | 55 | --name=nexantic-dev \ |
Leopold Schabel | 980d003 | 2020-06-03 14:44:49 +0200 | [diff] [blame] | 56 | --net=host \ |
Hendrik Hofstadt | 0d7c91e | 2019-10-23 21:44:47 +0200 | [diff] [blame] | 57 | nexantic-builder |
Hendrik Hofstadt | 3e6018f | 2019-10-28 21:29:42 +0100 | [diff] [blame] | 58 | |
| 59 | podman run -it -d \ |
| 60 | --pod nexantic \ |
| 61 | --ulimit nofile=262144:262144 \ |
| 62 | --name=nexantic-cockroach \ |
| 63 | cockroachdb/cockroach:v19.1.5 start --insecure |