blob: 5f179cdb4539b7258280c669d5e0511a01b2c632 [file] [log] [blame]
Leopold Schabel2983d722019-10-23 12:16:42 +02001#!/bin/bash
2set -euo pipefail
3
4# Our local user needs write access to /dev/kvm (best accomplished by
5# adding your user to the kvm group).
6if ! touch /dev/kvm; then
7 echo "Cannot write to /dev/kvm - please verify permissions."
8 exit 1
9fi
10
11# The KVM module needs to be loaded, since our container is unprivileged
12# and won't be able to do it itself.
13if ! [[ -d /sys/module/kvm ]]; then
14 echo "kvm module not loaded - please modprobe kvm"
15 exit 1
16fi
17
18# Rebuild base image
Hendrik Hofstadt0d7c91e2019-10-23 21:44:47 +020019podman build -t nexantic-builder build
Leopold Schabel2983d722019-10-23 12:16:42 +020020
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 Schabel5ed291e2019-11-14 19:09:24 +010023chcon -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 Schabel2983d722019-10-23 12:16:42 +020027 .arcconfig .idea .git
28
Leopold Schabel052af2d2019-11-06 02:21:53 +000029# Keep this in sync with ci.sh:
30
Hendrik Hofstadt3e6018f2019-10-28 21:29:42 +010031podman pod create --name nexantic
32
Leopold Schabel8b9c0552019-11-15 14:07:45 +010033# Mount bazel root to identical paths inside and outside the container.
34# This caches build state even if the container is destroyed, and
35BAZEL_ROOT=${HOME}/.cache/bazel-nxt
Leopold Schabel8b9c0552019-11-15 14:07:45 +010036mkdir -p ${BAZEL_ROOT}
37
Leopold Schabel399fe832019-11-15 21:15:30 +010038# 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.
40
41ASPECT_ORIG=${HOME}/.IntelliJIdea2019.2/config/plugins/ijwb/aspect
42
43ASPECT_PATH=${BAZEL_ROOT}/ijwb_aspect
44rm -rf "$ASPECT_PATH"
45cp -r "$ASPECT_ORIG" "$ASPECT_PATH"
46patch -d "$ASPECT_PATH" -p1 < scripts/patches/bazel_intellij_aspect_filter.patch
47
Leopold Schabel2983d722019-10-23 12:16:42 +020048podman run -it -d \
Leopold Schabel8b9c0552019-11-15 14:07:45 +010049 -v $(pwd):$(pwd) \
50 -w $(pwd) \
51 --volume=${BAZEL_ROOT}:${BAZEL_ROOT} \
Leopold Schabel2983d722019-10-23 12:16:42 +020052 --device /dev/kvm \
Leopold Schabel7afd3902019-10-23 12:16:57 +020053 --privileged \
Hendrik Hofstadt3e6018f2019-10-28 21:29:42 +010054 --pod nexantic \
Hendrik Hofstadt0d7c91e2019-10-23 21:44:47 +020055 --name=nexantic-dev \
56 nexantic-builder
Hendrik Hofstadt3e6018f2019-10-28 21:29:42 +010057
58podman run -it -d \
59 --pod nexantic \
60 --ulimit nofile=262144:262144 \
61 --name=nexantic-cockroach \
62 cockroachdb/cockroach:v19.1.5 start --insecure