-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature add render.com support (#678)
* Drop broken migrations * Add support of deploy to render.com * Add staging env * Update configs and scripts for render.com deploy * Update README.md * Cosmetic fixes for render.com deploy
- Loading branch information
Showing
19 changed files
with
320 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -109,7 +109,67 @@ heroku config:set RAILS_LOG_TO_STDOUT=enabled | |
heroku config:set [email protected] | ||
``` | ||
Configure reCAPTCHA for prodaction: | ||
## Deploy to render.com | ||
<details><summary>INFO IS HERE</summary> | ||
* Go to https://dashboard.render.com | ||
* Add New PostgreSQL with YOUR_CUSTOM_NAME_PG and select Region | ||
* Add New Web Service with link to your repo clone\ | ||
select: | ||
* YOUR_CUSTOM_NAME_CV | ||
* same Region | ||
* Runtime: Ruby | ||
* Build Command - "./bin/render-build.sh" | ||
* Start Command - "./bin/render-start.sh" or "bundle exec puma -C config/puma.rb" | ||
* Go to YOUR_CUSTOM_NAME_PG PostgreSQL -> Info and copy `Internal Database URL` | ||
* Go to YOUR_CUSTOM_NAME_CV app -> Environment | ||
* Environment Variables, by one\ | ||
or | ||
* Secret Files .env with your settings, based on .env.example and add this variables: | ||
* HOST | ||
```shell | ||
echo "HOST=your-app-name.onrender.com" >> .env | ||
``` | ||
* EMAIL_SPECIAL_USER | ||
```shell | ||
echo "EMAIL_SPECIAL_USER=any_existing_email@in_database" >> .env | ||
``` | ||
* DATABASE_URL | ||
```shell | ||
echo "DATABASE_URL=Internal Database URL" >> .env | ||
``` | ||
* RACK_ENV and RAILS_ENV | ||
```shell | ||
echo "RACK_ENV=staging" >> .env | ||
echo "RAILS_ENV=staging" >> .env | ||
``` | ||
* RENDER_LOAD_FIXTURES to load fixtures | ||
```shell | ||
echo "RENDER_LOAD_FIXTURES=1" >> .env | ||
``` | ||
Generate new master.key if the original is missing | ||
* RAILS_MASTER_KEY | ||
```shell | ||
export RAILS_MASTER_KEY="$(ruby -r securerandom -e 'print SecureRandom.hex(16)')" | ||
echo $RAILS_MASTER_KEY | ||
printf $RAILS_MASTER_KEY > config/master.key | ||
echo "RAILS_MASTER_KEY=$RAILS_MASTER_KEY" >> .env | ||
rm config/credentials.yml.enc | ||
EDITOR=vim bin/rails credentials:edit # to update config/credentials.yml.enc | ||
# press :wq+Enter | ||
``` | ||
* CREDENTIALS_ENC | ||
```shell | ||
echo "CREDENTIALS_ENC=$(cat config/credentials.yml.enc)" >> .env | ||
``` | ||
* You can deploy app | ||
</details> | ||
--- | ||
Configure reCAPTCHA for production: | ||
* Follow the link [reCAPTCHA](https://www.google.com/recaptcha) | ||
* Log into Admin Console with your credentials or create a new Google Account in case you don't have one | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/usr/bin/env bash | ||
# exit on error | ||
set -o errexit | ||
|
||
source "$(dirname $0)/render_lib.sh" && load_dotenv_file | ||
|
||
printf "$CREDENTIALS_ENC" > config/credentials.yml.enc | ||
printf "$RAILS_MASTER_KEY" > config/master.key | ||
|
||
bundle install | ||
npm install | ||
npm run build | ||
|
||
bundle exec rake assets:precompile | ||
bundle exec rake assets:clean | ||
|
||
./bin/rails db:prepare | ||
./bin/rails db:seed |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/usr/bin/env bash | ||
# exit on error | ||
set -o errexit | ||
|
||
source "$(dirname $0)/render_lib.sh" && load_dotenv_file | ||
|
||
bundle exec puma -C config/puma.rb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/usr/bin/env bash | ||
# exit on error | ||
set -o errexit | ||
|
||
function load_dotenv_file() { | ||
current_dir="$(pwd)"; | ||
script_dir="$(dirname $0)"; | ||
cd "$script_dir" | ||
export DOTENV_FILE='/etc/secrets/.env' | ||
if [ -f "$DOTENV_FILE" ]; then export $(sed '/^\s*$/d; /^[[:space:]]*#/d' "$DOTENV_FILE"); fi | ||
cd $current_dir | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
# frozen_string_literal: true | ||
|
||
Rails.application.configure do | ||
# Settings specified here will take precedence over those in config/application.rb. | ||
|
||
config.enable_reloading = false | ||
|
||
# Eager load code on boot. This eager loads most of Rails and | ||
# your application in memory, allowing both threaded web servers | ||
# and those relying on copy on write to perform better. | ||
# Rake tasks automatically ignore this option for performance. | ||
config.eager_load = true | ||
|
||
# Full error reports are disabled and caching is turned on. | ||
config.consider_all_requests_local = false | ||
config.action_controller.perform_caching = true | ||
|
||
# Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"] | ||
# or in config/master.key. This key is used to decrypt credentials (and other encrypted files). | ||
# config.require_master_key = true | ||
|
||
# Disable serving static files from the `/public` folder by default since | ||
# Apache or NGINX already handles this. | ||
config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present? || ENV['RENDER'].present? | ||
|
||
# Compress CSS using a preprocessor (compress with webpack). | ||
config.assets.css_compressor = Class.new { def self.compress(str) str end } # rubocop:disable Style/SingleLineMethods | ||
|
||
# Do not fallback to assets pipeline if a precompiled asset is missed. | ||
config.assets.compile = false | ||
|
||
# Enable serving of images, stylesheets, and JavaScripts from an asset server. | ||
# config.action_controller.asset_host = 'http://assets.example.com' | ||
|
||
# Specifies the header that your server uses for sending files. | ||
# config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache | ||
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX | ||
|
||
# Store uploaded files on the local file system (see config/storage.yml for options). | ||
config.active_storage.service = :local | ||
|
||
# Mount Action Cable outside main process or domain. | ||
# config.action_cable.mount_path = nil | ||
# config.action_cable.url = 'wss://example.com/cable' | ||
# config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ] | ||
|
||
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. | ||
config.force_ssl = true | ||
|
||
# Use the lowest log level to ensure availability of diagnostic information | ||
# when problems arise. | ||
config.log_level = :debug | ||
|
||
# Prepend all log lines with the following tags. | ||
config.log_tags = [:request_id] | ||
|
||
# Use a different cache store in production. | ||
# config.cache_store = :mem_cache_store | ||
|
||
# Use a real queuing backend for Active Job (and separate queues per environment). | ||
# config.active_job.queue_adapter = :resque | ||
# config.active_job.queue_name_prefix = "hexlet_cv_production" | ||
|
||
config.action_mailer.perform_caching = false | ||
config.action_mailer.default_url_options = { host: ENV.fetch('HOST') } | ||
config.action_mailer.deliver_later_queue_name = 'default_mailer_queue' | ||
|
||
# Ignore bad email addresses and do not raise email delivery errors. | ||
# Set this to true and configure the email server for immediate delivery to raise delivery errors. | ||
# config.action_mailer.raise_delivery_errors = false | ||
|
||
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to | ||
# the I18n.default_locale when a translation cannot be found). | ||
config.i18n.fallbacks = true | ||
|
||
# Send deprecation notices to registered listeners. | ||
config.active_support.deprecation = :notify | ||
|
||
# Use default logging formatter so that PID and timestamp are not suppressed. | ||
config.log_formatter = Logger::Formatter.new | ||
|
||
# Use a different logger for distributed setups. | ||
# require 'syslog/logger' | ||
# config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name') | ||
|
||
if ENV['RAILS_LOG_TO_STDOUT'].present? | ||
logger = ActiveSupport::Logger.new($stdout) | ||
logger.formatter = config.log_formatter | ||
config.logger = ActiveSupport::TaggedLogging.new(logger) | ||
end | ||
|
||
# Do not dump schema after migrations. | ||
config.active_record.dump_schema_after_migration = false | ||
|
||
# Inserts middleware to perform automatic connection switching. | ||
# The `database_selector` hash is used to pass options to the DatabaseSelector | ||
# middleware. The `delay` is used to determine how long to wait after a write | ||
# to send a subsequent read to the primary. | ||
# | ||
# The `database_resolver` class is used by the middleware to determine which | ||
# database is appropriate to use based on the time delay. | ||
# | ||
# The `database_resolver_context` class is used by the middleware to set | ||
# timestamps for the last write to the primary. The resolver uses the context | ||
# class timestamps to determine how long to wait before reading from the | ||
# replica. | ||
# | ||
# By default Rails will store a last write timestamp in the session. The | ||
# DatabaseSelector middleware is designed as such you can define your own | ||
# strategy for connection switching and pass that into the middleware through | ||
# these configuration options. | ||
# config.active_record.database_selector = { delay: 2.seconds } | ||
# config.active_record.database_resolver = ActiveRecord::Middleware::DatabaseSelector::Resolver | ||
# config.active_record.database_resolver_context = ActiveRecord::Middleware::DatabaseSelector::Resolver::Session | ||
ActionMailer::Base.smtp_settings = { | ||
user_name: 'SMTP_Injection', | ||
password: Rails.application.credentials.sparkpost_key, | ||
address: 'smtp.sparkpostmail.com', | ||
port: 587, | ||
enable_starttls_auto: true, | ||
format: :html, | ||
from: '[email protected]' | ||
} | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
5 changes: 0 additions & 5 deletions
5
db/migrate/20230503135226_add_career_step_ref_to_career_items.rb
This file was deleted.
Oops, something went wrong.
5 changes: 0 additions & 5 deletions
5
db/migrate/20230503135657_remove_uniq_index_from_career_items.rb
This file was deleted.
Oops, something went wrong.
5 changes: 0 additions & 5 deletions
5
db/migrate/20230503135757_remove_ref_step_from_career_items.rb
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.