Files
fizzy/bin/setup
T
Mike Dalessio ffc0c86f36 Minio support in development
for when we need to debug direct upload problems
2025-10-14 19:11:50 -04:00

70 lines
1.7 KiB
Bash
Executable File

#!/usr/bin/env bash
set -eo pipefail
# Prefer app executables
app_root="$(cd "$(dirname "$0")/.."; pwd)"
export PATH="$app_root/bin:$PATH"
# Install gum if needed
if ! command -v gum &> /dev/null; then
echo
echo "▸ Installing gum"
if command -v pacman &> /dev/null; then
sudo pacman -S --noconfirm gum
elif command -v brew &> /dev/null; then
brew install gum
else
echo "Please install gum: https://github.com/charmbracelet/gum"
exit 1
fi
echo
fi
step() {
local step_name="$1"
shift
gum style --foreground 135 --bold "$step_name"
gum style --foreground 240 "$*"
"$@"
local exit_code=$?
echo
return $exit_code
}
echo
gum style --foreground 153 " ˚ ∘ ∘ ˚ "
gum style --foreground 111 --bold " ∘˚˳°∘° 𝒻𝒾𝓏𝓏𝓎 °∘°˳˚∘ "
echo
step "Installing Ruby" mise install --yes
eval "$(mise hook-env)"
if which pacman >/dev/null 2>&1; then
packages=(imagemagick openslide)
if ! pacman -Q "${packages[@]}" >/dev/null 2>&1; then
step "Installing packages" sudo pacman -S --noconfirm --needed "${packages[@]}"
fi
fi
bundle config set --local auto_install true
step "Installing RubyGems" bundle install
if [ -e tmp/minio-dev.txt ] ; then
step "Starting Docker services" bash -c "[ -d ~/Work/basecamp/docker-dev ] && git -C ~/Work/basecamp/docker-dev pull || gh repo clone basecamp/docker-dev ~/Work/basecamp/docker-dev && ~/Work/basecamp/docker-dev/setup minio"
step "Configuring MinIO" bin/minio-setup
fi
if [[ $* == *--reset* ]]; then
step "Resetting the database" rails db:reset
else
step "Preparing the database" rails db:prepare
fi
step "Cleaning up logs and tempfiles" rails log:clear tmp:clear
gum style --foreground 46 "✓ Done (${SECONDS} sec)"