mirror of
https://github.com/community-scripts/ProxmoxVE.git
synced 2026-09-18 10:44:03 +00:00
Refactor: Oxicloud (#17338)
* refactor: streamline OxiCloud installation process by using prebuilt binaries * oxicloud: take the prebuilt binary in the update too Upstream now attaches musl tarballs to every release (AtalayaLabs/ OxiCloud#533), so the update no longer has to install a Rust toolchain and Node and compile for up to 35 minutes. That compile is also what broke #16216: a release whose source did not build left users with a failed install and no way forward. The tarball carries one top-level directory, which the deploy helper strips, so the binary lands at /opt/oxicloud/oxicloud. The frontend is baked into it, so the SPA build and OXICLOUD_STATIC_PATH both go; the variable is commented out rather than removed, since a stale ./static path would otherwise point at a directory that no longer exists. migrate-nfc-filenames is gone as a separate binary - it is now a subcommand, oxicloud migrate nfc-filenames - so the update removes the old one. ffmpeg replaces build-essential: the server forks it for video thumbnails and it is the one runtime dependency the musl build still needs from the system. Defaults drop to 2 CPU and 2048 MB, which were sized for the compile. * oxicloud: install ffmpeg on update as well The install gained it, the update did not, so a container created before this change would never get it. The musl binary forks ffmpeg for video thumbnails; without it that one feature stays silently unavailable.
This commit is contained in:
committed by
GitHub
parent
afbdf20aed
commit
5555c6e404
@@ -10,8 +10,8 @@ source "$_cs_boot" 2>/dev/null || source <(curl -fsSL "${COMMUNITY_SCRIPTS_CORE_
|
||||
|
||||
APP="OxiCloud"
|
||||
var_tags="${var_tags:-files;documents}"
|
||||
var_cpu="${var_cpu:-4}"
|
||||
var_ram="${var_ram:-6144}"
|
||||
var_cpu="${var_cpu:-2}"
|
||||
var_ram="${var_ram:-2048}"
|
||||
var_disk="${var_disk:-20}"
|
||||
var_os="${var_os:-debian}"
|
||||
var_version="${var_version:-13}"
|
||||
@@ -33,42 +33,19 @@ function update_script() {
|
||||
exit
|
||||
fi
|
||||
|
||||
NODE_VERSION="26" setup_nodejs
|
||||
ensure_dependencies ffmpeg
|
||||
|
||||
if check_for_gh_release "OxiCloud" "DioCrafts/OxiCloud"; then
|
||||
msg_info "Stopping OxiCloud"
|
||||
systemctl stop oxicloud
|
||||
msg_ok "Stopped OxiCloud"
|
||||
|
||||
CLEAN_INSTALL=1 fetch_and_deploy_gh_release "OxiCloud" "DioCrafts/OxiCloud" "tarball" "latest" "/opt/oxicloud"
|
||||
TOOLCHAIN="$(grep -oP 'FROM\s+rust:\K[0-9]+\.[0-9]+(\.[0-9]+)?' /opt/oxicloud/Dockerfile | head -1)"
|
||||
RUST_TOOLCHAIN="${TOOLCHAIN:-stable}" setup_rust
|
||||
CLEAN_INSTALL=1 fetch_and_deploy_gh_release "OxiCloud" "DioCrafts/OxiCloud" "prebuild" "latest" "/opt/oxicloud" "oxicloud-*-$(arch_resolve x86_64 aarch64)-unknown-linux-musl.tar.gz"
|
||||
|
||||
msg_info "Building Frontend SPA"
|
||||
cd /opt/oxicloud/frontend
|
||||
$STD npm ci
|
||||
$STD npm run build
|
||||
msg_ok "Built Frontend SPA"
|
||||
|
||||
msg_info "Updating OxiCloud (Patience)"
|
||||
set -a
|
||||
source /etc/oxicloud/.env
|
||||
set +a
|
||||
cd /opt/oxicloud
|
||||
export DATABASE_URL
|
||||
export RUSTFLAGS="-C target-cpu=native"
|
||||
RAM_MB=$(awk '/MemTotal/ {print int($2/1024)}' /proc/meminfo)
|
||||
CARGO_JOBS=$((RAM_MB / 2560))
|
||||
[[ $CARGO_JOBS -lt 1 ]] && CARGO_JOBS=1
|
||||
[[ $CARGO_JOBS -gt $(nproc) ]] && CARGO_JOBS=$(nproc)
|
||||
$STD cargo build --release -j "$CARGO_JOBS" --bin oxicloud --bin migrate-nfc-filenames
|
||||
mv target/release/oxicloud /usr/local/bin/oxicloud
|
||||
mv target/release/migrate-nfc-filenames /usr/local/bin/migrate-nfc-filenames
|
||||
chmod +x /usr/local/bin/oxicloud /usr/local/bin/migrate-nfc-filenames
|
||||
rm -f /usr/bin/oxicloud
|
||||
rm -rf /opt/oxicloud/static
|
||||
mv /opt/oxicloud/static-dist /opt/oxicloud/static
|
||||
rm -rf /opt/oxicloud/target /opt/oxicloud/frontend/node_modules
|
||||
msg_info "Updating OxiCloud"
|
||||
install -m 755 /opt/oxicloud/oxicloud /usr/local/bin/oxicloud
|
||||
rm -f /usr/local/bin/migrate-nfc-filenames /usr/bin/oxicloud
|
||||
sed -i 's|^OXICLOUD_STATIC_PATH=|#OXICLOUD_STATIC_PATH=|' /etc/oxicloud/.env
|
||||
msg_ok "Updated OxiCloud"
|
||||
|
||||
msg_info "Starting OxiCloud"
|
||||
|
||||
@@ -14,43 +14,20 @@ network_check
|
||||
update_os
|
||||
|
||||
msg_info "Installing Dependencies"
|
||||
$STD apt install -y build-essential
|
||||
$STD apt install -y ffmpeg
|
||||
msg_ok "Installed Dependencies"
|
||||
|
||||
NODE_VERSION="26" setup_nodejs
|
||||
PG_VERSION="17" setup_postgresql
|
||||
PG_DB_NAME="oxicloud" PG_DB_USER="oxicloud" setup_postgresql_db
|
||||
fetch_and_deploy_gh_release "OxiCloud" "DioCrafts/OxiCloud" "tarball" "latest" "/opt/oxicloud"
|
||||
TOOLCHAIN="$(grep -oP 'FROM\s+rust:\K[0-9]+\.[0-9]+(\.[0-9]+)?' /opt/oxicloud/Dockerfile | head -1)"
|
||||
RUST_TOOLCHAIN="${TOOLCHAIN:-stable}" setup_rust
|
||||
|
||||
msg_info "Building Frontend SPA"
|
||||
cd /opt/oxicloud/frontend
|
||||
$STD npm ci
|
||||
$STD npm run build
|
||||
msg_ok "Built Frontend SPA"
|
||||
|
||||
msg_info "Building OxiCloud (Patience)"
|
||||
cd /opt/oxicloud
|
||||
export DATABASE_URL="postgres://${PG_DB_USER}:${PG_DB_PASS}@localhost/${PG_DB_NAME}"
|
||||
export RUSTFLAGS="-C target-cpu=native"
|
||||
RAM_MB=$(awk '/MemTotal/ {print int($2/1024)}' /proc/meminfo)
|
||||
CARGO_JOBS=$((RAM_MB / 2560))
|
||||
[[ $CARGO_JOBS -lt 1 ]] && CARGO_JOBS=1
|
||||
[[ $CARGO_JOBS -gt $(nproc) ]] && CARGO_JOBS=$(nproc)
|
||||
$STD cargo build --release -j "$CARGO_JOBS" --bin oxicloud --bin migrate-nfc-filenames
|
||||
mv target/release/oxicloud /usr/local/bin/oxicloud
|
||||
mv target/release/migrate-nfc-filenames /usr/local/bin/migrate-nfc-filenames
|
||||
rm -rf /opt/oxicloud/static
|
||||
mv /opt/oxicloud/static-dist /opt/oxicloud/static
|
||||
rm -rf /opt/oxicloud/target /opt/oxicloud/frontend/node_modules
|
||||
msg_ok "Built OxiCloud"
|
||||
fetch_and_deploy_gh_release "OxiCloud" "DioCrafts/OxiCloud" "prebuild" "latest" "/opt/oxicloud" "oxicloud-*-$(arch_resolve x86_64 aarch64)-unknown-linux-musl.tar.gz"
|
||||
install -m 755 /opt/oxicloud/oxicloud /usr/local/bin/oxicloud
|
||||
|
||||
msg_info "Configuring OxiCloud"
|
||||
mkdir -p {/mnt/oxicloud,/etc/oxicloud}
|
||||
DATABASE_URL="postgres://${PG_DB_USER}:${PG_DB_PASS}@localhost/${PG_DB_NAME}"
|
||||
sed -e 's|OXICLOUD_STORAGE_PATH=.*|OXICLOUD_STORAGE_PATH=/mnt/oxicloud|' \
|
||||
-e 's|OXICLOUD_SERVER_HOST=.*|OXICLOUD_SERVER_HOST=0.0.0.0|' \
|
||||
-e 's|OXICLOUD_STATIC_PATH=.*|OXICLOUD_STATIC_PATH=/opt/oxicloud/static|' \
|
||||
-e 's|^OXICLOUD_STATIC_PATH=|#OXICLOUD_STATIC_PATH=|' \
|
||||
-e "s|^#OXICLOUD_BASE_URL=.*|OXICLOUD_BASE_URL=http://${LOCAL_IP}:8086|" \
|
||||
-e "s|OXICLOUD_DB_CONNECTION_STRING=.*|OXICLOUD_DB_CONNECTION_STRING=${DATABASE_URL}|" \
|
||||
-e "s|^DATABASE_URL=.*|DATABASE_URL=${DATABASE_URL}|" \
|
||||
|
||||
Reference in New Issue
Block a user