44 lines
1.7 KiB
Bash
Executable File
44 lines
1.7 KiB
Bash
Executable File
#!/bin/sh
|
|
#
|
|
# ./run_docker.sh [-b] [DOCKERFILE]
|
|
#
|
|
# Builds DOCKERFILE (default Dockerfile.alpine) and starts a throwaway
|
|
# container from it.
|
|
#
|
|
# -b for building packages from source (BUILD_DESIGN.txt): gsandbox
|
|
# needs user namespaces, overlayfs and a fresh /proc, which
|
|
# Docker's seccomp and AppArmor profiles and its /proc masking
|
|
# refuse, so those are turned off; /glacier goes on a tmpfs
|
|
# (overlayfs can't sit on Docker's own overlay root); and the
|
|
# recipe tree $RECIPES (default ../everest/recipes) is mounted
|
|
# read-only at /recipes. Use it with Dockerfile.alpine_root,
|
|
# then run /app/tests/buildenv inside (see TESTING.txt).
|
|
|
|
BUILD=
|
|
while getopts bh opt; do
|
|
case $opt in
|
|
b) BUILD=1 ;;
|
|
*) echo "usage: $0 [-b] [DOCKERFILE]" >&2; exit 1 ;;
|
|
esac
|
|
done
|
|
shift $((OPTIND - 1))
|
|
|
|
DOCKERFILE="${1:-Dockerfile.alpine}"
|
|
TAG="glacier-$(echo $DOCKERFILE | sed 's/Dockerfile\.//')"
|
|
|
|
# Dockerfiles that build libglacier-ng in-container (Dockerfile.alpine_root)
|
|
# take its source from this named context; the others ignore it.
|
|
LIBGLACIER_SRC="${LIBGLACIER_SRC:-$(dirname "$0")/../libglacier-ng}"
|
|
RECIPES="${RECIPES:-$(dirname "$0")/../everest/recipes}"
|
|
|
|
docker build -f "$DOCKERFILE" --build-context libglacier="$LIBGLACIER_SRC" -t "$TAG" . || exit 1
|
|
|
|
if [ -n "$BUILD" ]; then
|
|
[ -d "$RECIPES" ] || { echo "$0: no recipe tree at $RECIPES (set RECIPES)" >&2; exit 1; }
|
|
exec docker run -it --rm --network host \
|
|
--security-opt seccomp=unconfined --security-opt apparmor=unconfined \
|
|
--security-opt systempaths=unconfined --tmpfs /glacier:exec,mode=755 \
|
|
-v "$(realpath "$RECIPES")":/recipes:ro "$TAG"
|
|
fi
|
|
exec docker run -it --rm --network host "$TAG"
|