mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-08-05 05:25:24 +02:00
Add zero-config self hosting on Render (#612)
* v1 of backend implementation for self hosting * Add docs * Add upgrades controller * Add global helpers for self hosting mode * Add self host settings controller * Conditionally show self hosting settings * Environment and config updates * Complete upgrade prompting flow * Update config for forked repo * Move configuration of github provider within class * Add upgrades cron * Update deploy button * Update guides * Fix render deployer * Typo * Enable auto upgrades * Fix cron * Make upgrade modes more clear and consistent * Trigger new available version * Fix logic for displaying upgrade prompts * Finish implementation * Fix regression * Trigger new version * Add i18n translations * trigger new version * reduce caching time for testing * Decrease cache for testing * trigger upgrade * trigger upgrade * Only trigger deploy once * trigger upgrade * If target is commit, always upgrade if any upgrade is available * trigger upgrade * trigger upgrade * Test release * Change back to maybe repo for defaults * Fix lint errors * Clearer naming * Fix relative link * Add abs path * Relative link * Update docs
This commit is contained in:
parent
2bbf120e2f
commit
5aca2ff9b6
53 changed files with 1356 additions and 111 deletions
|
@ -1,88 +1,20 @@
|
|||
# PostgreSQL. Versions 9.3 and up are supported.
|
||||
#
|
||||
# Install the pg driver:
|
||||
# gem install pg
|
||||
# On macOS with Homebrew:
|
||||
# gem install pg -- --with-pg-config=/usr/local/bin/pg_config
|
||||
# On Windows:
|
||||
# gem install pg
|
||||
# Choose the win32 build.
|
||||
# Install PostgreSQL and put its /bin directory on your path.
|
||||
#
|
||||
# Configure Using Gemfile
|
||||
# gem "pg"
|
||||
#
|
||||
default: &default
|
||||
adapter: postgresql
|
||||
encoding: unicode
|
||||
# For details on connection pooling, see Rails configuration guide
|
||||
# https://guides.rubyonrails.org/configuring.html#database-pooling
|
||||
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
|
||||
host: <%= ENV.fetch("DB_HOST") { "127.0.0.1" } %>
|
||||
port: <%= ENV.fetch("DB_PORT") { "5432" } %>
|
||||
password: <%= ENV.fetch("POSTGRES_PASSWORD") { nil } %>
|
||||
user: <%= ENV.fetch("POSTGRES_USER") { nil } %>
|
||||
password: <%= ENV.fetch("POSTGRES_PASSWORD") { nil } %>
|
||||
|
||||
development:
|
||||
<<: *default
|
||||
database: maybe_development
|
||||
database: <%= ENV.fetch("POSTGRES_DB") { "maybe_development" } %>
|
||||
|
||||
# The specified database role being used to connect to PostgreSQL.
|
||||
# To create additional roles in PostgreSQL see `$ createuser --help`.
|
||||
# When left blank, PostgreSQL will use the default role. This is
|
||||
# the same name as the operating system user running Rails.
|
||||
#username: maybe
|
||||
|
||||
# The password associated with the PostgreSQL role (username).
|
||||
#password:
|
||||
|
||||
# Connect on a TCP socket. Omitted by default since the client uses a
|
||||
# domain socket that doesn't need configuration. Windows does not have
|
||||
# domain sockets, so uncomment these lines.
|
||||
#host: localhost
|
||||
|
||||
# The TCP port the server listens on. Defaults to 5432.
|
||||
# If your server runs on a different port number, change accordingly.
|
||||
#port: 5432
|
||||
|
||||
# Schema search path. The server defaults to $user,public
|
||||
#schema_search_path: myapp,sharedapp,public
|
||||
|
||||
# Minimum log levels, in increasing order:
|
||||
# debug5, debug4, debug3, debug2, debug1,
|
||||
# log, notice, warning, error, fatal, and panic
|
||||
# Defaults to warning.
|
||||
#min_messages: notice
|
||||
|
||||
# Warning: The database defined as "test" will be erased and
|
||||
# re-generated from your development database when you run "rake".
|
||||
# Do not set this db to the same as development or production.
|
||||
test:
|
||||
<<: *default
|
||||
database: maybe_test
|
||||
database: <%= ENV.fetch("POSTGRES_DB") { "maybe_test" } %>
|
||||
|
||||
# As with config/credentials.yml, you never want to store sensitive information,
|
||||
# like your database password, in your source code. If your source code is
|
||||
# ever seen by anyone, they now have access to your database.
|
||||
#
|
||||
# Instead, provide the password or a full connection URL as an environment
|
||||
# variable when you boot the app. For example:
|
||||
#
|
||||
# DATABASE_URL="postgres://myuser:mypass@localhost/somedatabase"
|
||||
#
|
||||
# If the connection URL is provided in the special DATABASE_URL environment
|
||||
# variable, Rails will automatically merge its configuration values on top of
|
||||
# the values provided in this file. Alternatively, you can specify a connection
|
||||
# URL environment variable explicitly:
|
||||
#
|
||||
# production:
|
||||
# url: <%= ENV["MY_APP_DATABASE_URL"] %>
|
||||
#
|
||||
# Read https://guides.rubyonrails.org/configuring.html#configuring-a-database
|
||||
# for a full overview on how database connection configuration can be specified.
|
||||
#
|
||||
production:
|
||||
<<: *default
|
||||
database: maybe_production
|
||||
username: maybe
|
||||
password: <%= ENV["MAYBE_DATABASE_PASSWORD"] %>
|
||||
database: <%= ENV.fetch("POSTGRES_DB") { "maybe_production" } %>
|
||||
|
|
|
@ -1,9 +1,13 @@
|
|||
Rails.application.configure do
|
||||
config.good_job.enable_cron = true
|
||||
config.good_job.cron = {
|
||||
maintenance: {
|
||||
cron: "0 22 * * *",
|
||||
class: "DailyExchangeRateJob"
|
||||
|
||||
if ENV["UPGRADES_ENABLED"] == "true"
|
||||
config.good_job.cron = {
|
||||
auto_upgrade: {
|
||||
cron: "every 30 seconds",
|
||||
class: "AutoUpgradeJob",
|
||||
description: "Check for new versions of the app and upgrade if necessary"
|
||||
}
|
||||
}
|
||||
}
|
||||
end
|
||||
end
|
||||
|
|
16
config/initializers/version.rb
Normal file
16
config/initializers/version.rb
Normal file
|
@ -0,0 +1,16 @@
|
|||
module Maybe
|
||||
class << self
|
||||
def version
|
||||
Semver.new(semver)
|
||||
end
|
||||
|
||||
def commit_sha
|
||||
`git rev-parse HEAD`.chomp
|
||||
end
|
||||
|
||||
private
|
||||
def semver
|
||||
"0.1.0-alpha.1"
|
||||
end
|
||||
end
|
||||
end
|
13
config/locales/models/upgrader/en.yml
Normal file
13
config/locales/models/upgrader/en.yml
Normal file
|
@ -0,0 +1,13 @@
|
|||
---
|
||||
en:
|
||||
upgrader:
|
||||
deployer:
|
||||
null_deployer:
|
||||
success_message: 'No-op: null deployer initiated deploy successfully'
|
||||
render:
|
||||
deploy_log_error: 'Failed to deploy %{type} %{commit_sha} to Render: %{error_message}'
|
||||
deploy_log_info: Deploying %{type} %{commit_sha} to Render...
|
||||
error_message_failed_deploy: Failed to deploy to Render
|
||||
error_message_not_set: Render deploy hook URL is not set
|
||||
success_message: 'Triggered deployment to Render for commit: %{commit_sha}'
|
||||
troubleshooting_url: https://render.com/docs/deploy-hooks
|
8
config/locales/views/settings/en.yml
Normal file
8
config/locales/views/settings/en.yml
Normal file
|
@ -0,0 +1,8 @@
|
|||
---
|
||||
en:
|
||||
settings:
|
||||
self_hosting:
|
||||
update:
|
||||
render_deploy_hook_error: Render deploy hook must be provided to enable auto
|
||||
upgrades
|
||||
success: Settings updated successfully.
|
|
@ -20,3 +20,9 @@ en:
|
|||
and account graphs.</p></br><p>The only way you’ll be able to add this entry
|
||||
back is by re-entering it manually via a new entry</p>"
|
||||
title: Delete Entry?
|
||||
shared:
|
||||
upgrade_notification:
|
||||
app_upgraded: The app has been upgraded to %{version}.
|
||||
dismiss: Dismiss
|
||||
new_version_available: A new version of Maybe is available for upgrade.
|
||||
upgrade_now: Upgrade Now
|
||||
|
|
10
config/locales/views/upgrades/en.yml
Normal file
10
config/locales/views/upgrades/en.yml
Normal file
|
@ -0,0 +1,10 @@
|
|||
---
|
||||
en:
|
||||
upgrades:
|
||||
acknowledge:
|
||||
upgrade_complete_dismiss: We hope you enjoy the new features!
|
||||
upgrade_dismissed: Upgrade dismissed
|
||||
upgrade_not_available: Upgrade not available
|
||||
upgrade_not_found: Upgrade not found
|
||||
deploy:
|
||||
upgrade_not_found: Upgrade not found
|
|
@ -5,7 +5,10 @@ Rails.application.routes.draw do
|
|||
resource :session
|
||||
resource :password_reset
|
||||
resource :password
|
||||
resource :settings, only: %i[edit update]
|
||||
|
||||
resource :settings, only: %i[edit update] do
|
||||
resource :self_hosting, only: %i[edit update], controller: "settings/self_hosting"
|
||||
end
|
||||
|
||||
resources :transactions do
|
||||
match "search" => "transactions#search", on: :collection, via: [ :get, :post ], as: :search
|
||||
|
@ -20,6 +23,14 @@ Rails.application.routes.draw do
|
|||
resources :valuations
|
||||
end
|
||||
|
||||
# For managing self-hosted upgrades and release notifications
|
||||
resources :upgrades, only: [] do
|
||||
member do
|
||||
post :acknowledge
|
||||
post :deploy
|
||||
end
|
||||
end
|
||||
|
||||
# Reveal health status on /up that returns 200 if the app boots with no exceptions, otherwise 500.
|
||||
# Can be used by load balancers and uptime monitors to verify that the app is live.
|
||||
get "up" => "rails/health#show", as: :rails_health_check
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue