Disable rails during ruby setup

This commit is contained in:
vhsdream 2026-02-15 14:29:30 -05:00
parent c265e3232d
commit a0c995e318
2 changed files with 41 additions and 26 deletions

View File

@ -29,16 +29,24 @@ function update_script() {
exit
fi
NODE_VERSION="24" setup_nodejs
if check_for_gh_release "Sure" "we-promise/sure"; then
msg_info "Stopping Sure"
$STD systemctl stop sure
msg_ok "Stopped Sure"
CLEAN_INSTALL=1 fetch_and_deploy_gh_release "Sure" "we-promise/sure" "tarball" "latest" "/opt/sure"
RUBY_VERSION="$(cat /opt/sure/.ruby-version)" RUBY_INSTALL_RAILS=false setup_ruby
msg_info "Updating Sure"
cd /opt/sure
export RAILS_ENV=production
export BUNDLE_DEPLOYMENT=1
export BUNDLE_WITHOUT=development
$STD bundle install
$STD bundle exec bootsnap precompile --gemfile -j 0
$STD bundle exec bootsnap precompile -j 0 app/ lib/
export SECRET_KEY_BASE_DUMMY=1 && $STD ./bin/rails assets:precompile
unset SECRET_KEY_BASE_DUMMY
msg_ok "Updated Sure"
msg_info "Starting Sure"

View File

@ -26,30 +26,34 @@ fetch_and_deploy_gh_release "Sure" "we-promise/sure" "tarball" "latest" "/opt/su
PG_VERSION="$(sed -n '/postgres:/s/[^[:digit:]]*//p' /opt/sure/compose.example.yml)" setup_postgresql
PG_DB_NAME=sure_production PG_DB_USER=sure_user setup_postgresql_db
RUBY_VERSION="$(cat /opt/sure/.ruby-version)" RUBY_INSTALL_RAILS=true setup_ruby
RUBY_VERSION="$(cat /opt/sure/.ruby-version)" RUBY_INSTALL_RAILS=false setup_ruby
# msg_info "Building Sure"
# cd /opt/sure
# export RAILS_ENV=production
# export BUNDLE_DEPLOYMENT=1
# export BUNDLE_WITHOUT=development
# $STD bundle install
# $STD bundle exec bootsnap precompile --gemfile -j 0
# $STD bundle exec bootsnap precompile -j 0 app/ lib/
# export SECRET_KEY_BASE_DUMMY=1 && $STD ./bin/rails assets:precompile
# msg_ok "Built Sure"
#
# msg_info "Configuring Sure"
# KEY="$(openssl rand -hex 64)"
# mkdir -p /etc/sure
# mv /opt/sure/.env.example /etc/sure/.env
# sed -i -e "/^SECRET_KEY_BASE=/s/secret-value/${KEY}/" \
# -e "/POSTGRES_PASSWORD=/s/postgres/${PG_DB_PASS}/" \
# -e "/POSTGRES_USER=/s/postgres/${PG_DB_USER}\\
# POSTGRES_DB=${PG_DB_NAME}/" \
# -e "s|^APP_DOMAIN=|&${LOCAL_IP}|" /etc/sure/.env
# $STD ./bin/rails db:prepare
# msg_ok "Configured Sure"
msg_info "Building Sure"
cd /opt/sure
export RAILS_ENV=production
export BUNDLE_DEPLOYMENT=1
export BUNDLE_WITHOUT=development
$STD bundle install
$STD bundle exec bootsnap precompile --gemfile -j 0
$STD bundle exec bootsnap precompile -j 0 app/ lib/
export SECRET_KEY_BASE_DUMMY=1 && $STD ./bin/rails assets:precompile
unset SECRET_KEY_BASE_DUMMY
msg_ok "Built Sure"
msg_info "Configuring Sure"
KEY="$(openssl rand -hex 64)"
mkdir -p /etc/sure
mv /opt/sure/.env.example /etc/sure/.env
sed -i -e "/^SECRET_KEY_BASE=/s/secret-value/${KEY}/" \
-e 's/_KEY_BASE=.*$/&\n\nRAILS_FORCE_SSL=false \\
\\
# Change to true when using a reverse proxy \\
RAILS_ASSUME_SSL=false/' \
-e "/POSTGRES_PASSWORD=/s/postgres/${PG_DB_PASS}/" \
-e "/POSTGRES_USER=/s/postgres/${PG_DB_USER}\\
POSTGRES_DB=${PG_DB_NAME}/" \
-e "s|^APP_DOMAIN=|&${LOCAL_IP}|" /etc/sure/.env
msg_ok "Configured Sure"
msg_info "Creating Service"
cat <<EOF >/etc/systemd/system/sure.service
@ -60,7 +64,10 @@ After=network.target
[Service]
Type=simple
WorkingDirectory=/opt/sure
Environment=RAILS_ENV=production
Environment=PATH=/root/.rbenv/shims:/root/.rbenv/bin:/usr/bin:\$PATH
EnvironmentFile=/etc/sure/.env
ExecStartPre=/opt/sure/bin/rails db:prepare
ExecStart=/opt/sure/bin/rails server
Restart=always
RestartSec=5
@ -70,7 +77,7 @@ StandardError=journal
[Install]
WantedBy=multi-user.target
EOF
# $STD systemctl enable -q --now sure
$STD systemctl enable -q --now sure
msg_ok "Created Service"
motd_ssh