zeek/auxil/spicy/docker/docker-helper
Patrick Kelley 8fd444092b initial
2025-05-07 15:35:15 -04:00

40 lines
909 B
Bash
Executable File

#!/bin/bash
# Copyright (c) 2020-now by the Zeek Project. See LICENSE for details.
#
# Helper for the Makefile to trigger Docker commands with the desired image.
set -e
usage() {
echo "usage: $(basename $0) build|run <platform>"
exit 1
}
test $# = 2 || usage
version=$(cat ../VERSION)
cmd=$1
platform=$2
if [ ! -e "Dockerfile.${platform}" ]; then
echo "Dockerfile.${platform} does not exist"
exit 1
fi
case "${cmd}" in
build)
DOCKER_BUILDKIT=1 docker build \
-t "spicy-${platform}:${version}" \
-f "Dockerfile.${platform}" .. || exit 1
docker tag \
"$(docker inspect --format='{{.Id}}' "spicy-${platform}:${version}")" \
"spicy-${platform}:latest"
;;
run)
docker run --cap-add SYS_PTRACE --security-opt seccomp=unconfined -i -t "spicy-${platform}:latest" /bin/sh -l
;;
*) usage;;
esac