mirror of
https://github.com/community-scripts/ProxmoxVE.git
synced 2026-10-31 00:22:35 +01:00
fix(discourse): track the Ruby version Discourse requires
Discourse main now pins `ruby "~> 4.0.0"` in its Gemfile, so `bundle install` aborts with exit 18 on containers built against the hardcoded Ruby 3.4.4. The update path never touched Ruby at all, so every existing install breaks. Discourse ships no .ruby-version, so read the pinned version from Gemfile.lock's RUBY VERSION stanza and hand it to setup_ruby — on install (repo is now cloned before the runtime setup) and on update (after the git pull, so a bumped requirement is picked up). Also silence bundler's root warning, split the update into separate progress steps, and skip the unused global Rails gem.
This commit is contained in:
1 parent
bc6ab71982
commit
d795d2f709
2 files changed
+27
-4
No files matched your search
+19
-2
@@ -51,16 +51,33 @@ function update_script() {
|
||||
cd /opt/discourse
|
||||
export PATH="$HOME/.rbenv/bin:$HOME/.rbenv/shims:$PATH"
|
||||
export COREPACK_ENABLE_DOWNLOAD_PROMPT=0
|
||||
export BUNDLE_SILENCE_ROOT_WARNING=1
|
||||
set -a
|
||||
source /opt/discourse/.env
|
||||
set +a
|
||||
$STD git pull origin main
|
||||
$STD bundle install
|
||||
msg_ok "Updated Discourse"
|
||||
|
||||
# Discourse ships no .ruby-version, the required Ruby is pinned in Gemfile.lock
|
||||
RUBY_TARGET=$(grep -A1 '^RUBY VERSION' /opt/discourse/Gemfile.lock | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' | head -n1)
|
||||
RUBY_VERSION="${RUBY_TARGET:-4.0.7}" RUBY_INSTALL_RAILS="false" setup_ruby
|
||||
export PATH="$HOME/.rbenv/bin:$HOME/.rbenv/shims:$PATH"
|
||||
hash -r
|
||||
|
||||
msg_info "Updating Dependencies"
|
||||
cd /opt/discourse
|
||||
$STD bundle install -j"$(nproc)"
|
||||
$STD pnpm install
|
||||
msg_ok "Updated Dependencies"
|
||||
|
||||
msg_info "Running Database Migrations"
|
||||
$STD runuser -u postgres -- psql -d discourse -c "CREATE EXTENSION IF NOT EXISTS vector;"
|
||||
$STD bundle exec rails db:migrate
|
||||
msg_ok "Ran Database Migrations"
|
||||
|
||||
msg_info "Precompiling Assets"
|
||||
$STD bundle exec rails assets:precompile
|
||||
msg_ok "Updated Discourse"
|
||||
msg_ok "Precompiled Assets"
|
||||
|
||||
msg_info "Starting Services"
|
||||
systemctl start discourse discourse-sidekiq
|
||||
|
||||
@@ -28,9 +28,15 @@ $STD apt install -y \
|
||||
redis-server
|
||||
msg_ok "Installed Dependencies"
|
||||
|
||||
msg_info "Cloning Discourse"
|
||||
$STD git clone --depth 1 https://github.com/discourse/discourse.git /opt/discourse
|
||||
msg_ok "Cloned Discourse"
|
||||
|
||||
PG_VERSION="17" PG_MODULES="pgvector" setup_postgresql
|
||||
NODE_VERSION="24" setup_nodejs
|
||||
RUBY_VERSION="3.4.4" setup_ruby
|
||||
# Discourse ships no .ruby-version, the required Ruby is pinned in Gemfile.lock
|
||||
RUBY_TARGET=$(grep -A1 '^RUBY VERSION' /opt/discourse/Gemfile.lock | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' | head -n1)
|
||||
RUBY_VERSION="${RUBY_TARGET:-4.0.7}" RUBY_INSTALL_RAILS="false" setup_ruby
|
||||
|
||||
msg_info "Configuring PostgreSQL for Discourse"
|
||||
DISCOURSE_DB_PASS=$(random_password 13)
|
||||
@@ -42,7 +48,6 @@ msg_ok "Configured PostgreSQL for Discourse"
|
||||
|
||||
msg_info "Configuring Discourse"
|
||||
DISCOURSE_SECRET_KEY=$(openssl rand -hex 64)
|
||||
$STD git clone --depth 1 https://github.com/discourse/discourse.git /opt/discourse
|
||||
cd /opt/discourse
|
||||
cat <<EOF >/opt/discourse/.env
|
||||
RAILS_ENV=production
|
||||
@@ -77,6 +82,7 @@ export PATH="$HOME/.rbenv/bin:$HOME/.rbenv/shims:$PATH"
|
||||
eval "$(rbenv init - bash)" 2>/dev/null || true
|
||||
export RAILS_ENV=production
|
||||
export COREPACK_ENABLE_DOWNLOAD_PROMPT=0
|
||||
export BUNDLE_SILENCE_ROOT_WARNING=1
|
||||
$STD corepack enable
|
||||
$STD bundle config set --local deployment true
|
||||
$STD bundle config set --local without 'test development'
|
||||
|
||||
Reference in new issue
Block a user