Files
LuPhoto/scripts/dev.sh
T
lucioandClaude Opus 5.5 18a397653a M1: processor CLI
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-04 04:07:45 -08:00

46 lines
1.0 KiB
Bash

#!/usr/bin/env bash
set -euo pipefail
scripts_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
repo_dir="$(dirname "$scripts_dir")"
image="${LUPHOTO_DEV_IMAGE:-luphoto-dev}"
case "$(uname -s)" in
MINGW*|MSYS*|CYGWIN*)
export MSYS_NO_PATHCONV=1
scripts_host="$(cygpath -w "$scripts_dir")"
repo_host="$(cygpath -w "$repo_dir")"
;;
*)
scripts_host="$scripts_dir"
repo_host="$repo_dir"
;;
esac
if [ "${LUPHOTO_DEV_REBUILD:-0}" = "1" ] || ! docker image inspect "$image" >/dev/null 2>&1; then
docker build -t "$image" -f "$scripts_host/dev.Dockerfile" "$scripts_host"
fi
tty_args=()
if [ -t 0 ] && [ -t 1 ]; then
tty_args=(-it)
fi
extra_args=()
if [ -n "${LUPHOTO_DEV_ARGS:-}" ]; then
read -r -a extra_args <<<"$LUPHOTO_DEV_ARGS"
fi
if [ "$#" -eq 0 ]; then
set -- bash
fi
exec docker run --rm "${tty_args[@]}" \
-v "$repo_host:/src" \
-v luphoto-gomod:/root/go/pkg/mod \
-v luphoto-gocache:/root/.cache/go-build \
-e GOFLAGS="${GOFLAGS:-}" \
-w /src \
"${extra_args[@]}" \
"$image" "$@"