From 44f5656a562d39fd7eb70a581f5c0d69696af842 Mon Sep 17 00:00:00 2001 From: "CanbiZ (MickLesk)" <47820557+MickLesk@users.noreply.github.com> Date: Thu, 29 Jan 2026 13:31:14 +0100 Subject: [PATCH] Alpine-Valkey (#11320) --- ct/alpine-valkey.sh | 73 ++++++++++++++++++++++++++++++++ frontend/public/json/valkey.json | 15 +++++++ install/alpine-valkey-install.sh | 45 ++++++++++++++++++++ 3 files changed, 133 insertions(+) create mode 100644 ct/alpine-valkey.sh create mode 100644 install/alpine-valkey-install.sh diff --git a/ct/alpine-valkey.sh b/ct/alpine-valkey.sh new file mode 100644 index 000000000..131ae581d --- /dev/null +++ b/ct/alpine-valkey.sh @@ -0,0 +1,73 @@ +#!/usr/bin/env bash +source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func) +# Copyright (c) 2021-2026 community-scripts ORG +# Author: pshankinclarke (lazarillo) +# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE +# Source: https://valkey.io/ + +APP="Alpine-Valkey" +var_tags="${var_tags:-alpine;database}" +var_cpu="${var_cpu:-1}" +var_ram="${var_ram:-256}" +var_disk="${var_disk:-1}" +var_os="${var_os:-alpine}" +var_version="${var_version:-3.23}" +var_unprivileged="${var_unprivileged:-1}" + +header_info "$APP" +variables +color +catch_errors + +function update_script() { + if ! apk -e info newt >/dev/null 2>&1; then + apk add -q newt + fi + LXCIP=$(ip a s dev eth0 | awk '/inet / {print $2}' | cut -d/ -f1) + while true; do + CHOICE=$( + whiptail --backtitle "Proxmox VE Helper Scripts" --title "Valkey Management" --menu "Select option" 11 58 3 \ + "1" "Update Valkey" \ + "2" "Allow 0.0.0.0 for listening" \ + "3" "Allow only ${LXCIP} for listening" 3>&2 2>&1 1>&3 + ) + exit_status=$? + if [ $exit_status == 1 ]; then + clear + exit-script + fi + header_info + case $CHOICE in + 1) + msg_info "Updating Valkey" + apk update && apk upgrade valkey + rc-service valkey restart + msg_ok "Updated Valkey" + msg_ok "Updated successfully!" + exit + ;; + 2) + msg_info "Setting Valkey to listen on all interfaces" + sed -i 's/^bind .*/bind 0.0.0.0/' /etc/valkey/valkey.conf + rc-service valkey restart + msg_ok "Valkey now listens on all interfaces!" + exit + ;; + 3) + msg_info "Setting Valkey to listen only on ${LXCIP}" + sed -i "s/^bind .*/bind ${LXCIP}/" /etc/valkey/valkey.conf + rc-service valkey restart + msg_ok "Valkey now listens only on ${LXCIP}!" + exit + ;; + esac + done +} + +start +build_container +description + +msg_ok "Completed successfully!\n" +echo -e "${APP} should be reachable on port 6379. + ${BL}valkey-cli -h ${IP} -p 6379${CL} \n" diff --git a/frontend/public/json/valkey.json b/frontend/public/json/valkey.json index 6506e0319..ba7f276a1 100644 --- a/frontend/public/json/valkey.json +++ b/frontend/public/json/valkey.json @@ -25,6 +25,17 @@ "os": "Debian", "version": "13" } + }, + { + "type": "alpine", + "script": "ct/alpine-valkey.sh", + "resources": { + "cpu": 1, + "ram": 256, + "hdd": 1, + "os": "alpine", + "version": "3.23" + } } ], "default_credentials": { @@ -35,6 +46,10 @@ { "text": "Show Login Credentials, type `cat ~/valkey.creds` in the LXC console", "type": "info" + }, + { + "text": "Alpines Valkey package is compiled without TLS support. For TLS, use the Debian-based valkey script instead.", + "type": "info" } ] } diff --git a/install/alpine-valkey-install.sh b/install/alpine-valkey-install.sh new file mode 100644 index 000000000..5beda4860 --- /dev/null +++ b/install/alpine-valkey-install.sh @@ -0,0 +1,45 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2026 community-scripts ORG +# Author: pshankinclarke (lazarillo) +# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE +# Source: https://valkey.io/ + +source /dev/stdin <<<"$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +msg_info "Installing Valkey" +$STD apk add valkey valkey-openrc valkey-cli +sed -i 's/^bind .*/bind 0.0.0.0/' /etc/valkey/valkey.conf + +PASS="$(head -c 100 /dev/urandom | tr -dc 'a-zA-Z0-9' | head -c32)" +echo "requirepass $PASS" >>/etc/valkey/valkey.conf +echo "$PASS" >~/valkey.creds +chmod 600 ~/valkey.creds + +MEMTOTAL_MB=$(free -m | grep ^Mem: | awk '{print $2}') +MAXMEMORY_MB=$((MEMTOTAL_MB * 75 / 100)) + +{ + echo "" + echo "# Memory-optimized settings for small-scale deployments" + echo "maxmemory ${MAXMEMORY_MB}mb" + echo "maxmemory-policy allkeys-lru" + echo "maxmemory-samples 10" +} >>/etc/valkey/valkey.conf +msg_ok "Installed Valkey" + +# Note: Alpine's valkey package is compiled without TLS support +# For TLS, use the Debian-based valkey script instead + +$STD rc-update add valkey default +$STD rc-service valkey start + +motd_ssh +customize +cleanup_lxc