Compare commits

..
Author SHA1 Message Date
CanbiZ (MickLesk) 36ba6581ed move git
Removed comment about Ruby version in install script.
2026-10-30 22:12:17 +01:00
CanbiZ (MickLesk) 2f70cb0e2f move ruby into msg block 2026-10-30 22:11:23 +01:00
MickLesk d795d2f709 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.
2026-10-30 22:07:27 +01:00
2 changed files with 24 additions and 4 deletions

No files matched your search

+17 -2
View File
@@ -51,16 +51,31 @@ 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"
msg_info "Updating Dependencies"
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
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
+7 -2
View File
@@ -28,9 +28,14 @@ $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
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 +47,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 +81,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'