diff --git a/install.sh b/install.sh index d963e43..1f3823f 100755 --- a/install.sh +++ b/install.sh @@ -70,6 +70,10 @@ if [ "${1:-}" = "-update" ]; then info "Rebuilding binary..." if command -v go &>/dev/null; then + export GOMODCACHE="${INSTALL_DIR}/.go/mod" + export GOPATH="${INSTALL_DIR}/.go" + export GOCACHE="${INSTALL_DIR}/.go/build" + mkdir -p "${GOMODCACHE}" "${GOCACHE}" 2>/dev/null || sudo_if mkdir -p "${GOMODCACHE}" "${GOCACHE}" CGO_ENABLED=0 go build -ldflags="-s -w" -o app . else warn "Go not found — downloading pre-built binary..." @@ -126,10 +130,11 @@ esac if command -v go &>/dev/null; then info "Building binary from source (pure Go, no CGO)..." - # Use a writable module cache — the user's home may not be writable + # Use a writable cache — the user's home (/app/) may not be writable export GOMODCACHE="${INSTALL_DIR}/.go/mod" export GOPATH="${INSTALL_DIR}/.go" - mkdir -p "${GOMODCACHE}" 2>/dev/null || sudo_if mkdir -p "${GOMODCACHE}" + export GOCACHE="${INSTALL_DIR}/.go/build" + mkdir -p "${GOMODCACHE}" "${GOCACHE}" 2>/dev/null || sudo_if mkdir -p "${GOMODCACHE}" "${GOCACHE}" CGO_ENABLED=0 go build -ldflags="-s -w" -o app . else info "Go not found — downloading pre-built binary..."