fix: set GOCACHE alongside GOMODCACHE for users without home write access
- Go build cache was trying to write to /app/.cache/go-build (unwritable) - Now uses /opt/receiptnext/.go/build instead
This commit is contained in:
parent
de29841341
commit
51c5d9a23e
1 changed files with 7 additions and 2 deletions
|
|
@ -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..."
|
||||
|
|
|
|||
Loading…
Reference in a new issue