#!/bin/bash set -euo pipefail # Start Redis in the background redis-server --daemonize yes # Optional SSH setup: only if /root/ssh has keys if [ -d /root/ssh ] && compgen -G "/root/ssh/*" > /dev/null; then mkdir -p /root/.ssh cp -r /root/ssh/* /root/.ssh/ chmod 600 /root/.ssh/* eval "$(ssh-agent)" ssh-add /root/.ssh/* fi # Support optionally bind-mounting a local herolib into the container. # If /opt/herolib_mount exists, we use that; otherwise we use the cloned /opt/herolib rm -f /root/.vmodules/freeflowuniverse/herolib if [ -d "/opt/herolib_mount" ]; then ln -s /opt/herolib_mount/lib /root/.vmodules/incubaid/herolib cd /opt/herolib_mount else ln -s /opt/herolib/lib /root/.vmodules/incubaid/herolib cd /opt/herolib git fetch git checkout "${HEROLIB_REF:-development}" git pull fi # Build hero CLI once so it's available as /bin/hero cd cli echo "Building hero..." v -enable-globals hero.v > build.log 2>&1 || (cat build.log && exit 1) ln -s "$(realpath hero)" /bin/hero cd /root # If a command was provided to `docker run`, execute it as-is. if [ "$#" -gt 0 ]; then exec "$@" else # No command passed → give an interactive shell exec bash fi