Hello, Trying to setup a hook to automatically connect to my docker network when discourse restarts or boots back up after building. This is so I can use the admin web updater when I can but trying to figure out the best way to go about this. Docs don’t really say all the hook types I can use and Looking up hooks such as after_post_boot and after_restart does nothing. Do these hooks no longer work and if so, why? Here’s my hooks code.
hooks:
begin custom network hook
after_restart:
- exec:
cmd: - bash
- “-c”
- |
Connect Discourse to the custom Docker network if not already connected
NETWORK_NAME=“proxy”
CONTAINER_NAME=$(hostname)
# Create the network if it doesn't exist
if ! docker network inspect "$NETWORK_NAME" >/dev/null 2>&1; then
echo "Creating Docker network: $NETWORK_NAME"
docker network create "$NETWORK_NAME"
fi
# Connect container to the network (ignore if already connected)
echo "Connecting $CONTAINER_NAME to $NETWORK_NAME..."
docker network connect "$NETWORK_NAME" "$CONTAINER_NAME" 2>/dev/null || true
echo "Network connection complete."