Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions .github/workflows/uffizzi-previews.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Build Images and Handle Uffizzi Previews.

on:
push:
branches:
- main
- master
- qa
pull_request:
types: [opened,reopened,synchronize,closed]

jobs:
render-compose-file:
name: Render Docker Compose File
runs-on: ubuntu-latest
outputs:
compose-file-cache-key: ${{ steps.hash.outputs.hash }}
compose-file-cache-path: sub-docker-compose-files/docker-compose.uffizzi_multy_svc.yml
steps:
- name: Checkout git repo
uses: actions/checkout@v3
- name: Hash Rendered Compose File
id: hash
run: echo "::set-output name=hash::$(md5sum sub-docker-compose-files/docker-compose.uffizzi_multy_svc.yml | awk '{ print $1 }')"
- name: Cache Rendered Compose File
uses: actions/cache@v3
with:
path: sub-docker-compose-files/docker-compose.uffizzi_multy_svc.yml
key: ${{ steps.hash.outputs.hash }}

deploy-uffizzi-preview:
name: Use Remote Workflow to Preview on Uffizzi
needs:
- render-compose-file
uses: UffizziCloud/preview-action/.github/workflows/reusable.yaml@v2
if: ${{ github.event_name == 'pull_request' && github.event.action != 'closed' }}
with:
compose-file-cache-key: ${{ needs.render-compose-file.outputs.compose-file-cache-key }}
compose-file-cache-path: ${{ needs.render-compose-file.outputs.compose-file-cache-path }}
server: https://pr-437-deployment-7156-uffizzi-platform.app.uffizzi.com/
project: test_rails
permissions:
contents: read
pull-requests: write
id-token: write
6 changes: 3 additions & 3 deletions config/database.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ default: &default

development:
<<: *default
database: /db/development.sqlite3
database: /public_db/development.sqlite3

# 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: /db/test.sqlite3
database: /public_db/test.sqlite3

production:
<<: *default
database: /db/production.sqlite3
database: /public_db/production.sqlite3
6 changes: 4 additions & 2 deletions docker-compose.uffizzi_multy_svc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ services:
memory: 1000M
command: ["bash", "-c", "bin/rails db:create && bin/rails db:migrate && bundle exec rails s -b '0.0.0.0' -p 3000"]
volumes:
- db_share:/db
- ./public_db:/public_db
- ./config:/app/config

subweb:
image: zipofar/uffizzi_test_rails_simple:latest
Expand All @@ -36,7 +37,8 @@ services:
memory: 1000M
command: ["bash", "-c", "bin/rails db:create && bin/rails db:migrate && bundle exec rails s -b '0.0.0.0' -p 4000"]
volumes:
- db_share:/db
- ./public_db:/public_db
- ./config:/app/config

volumes:
db_share:
Expand Down
Binary file added public_db/production.sqlite3
Binary file not shown.
22 changes: 22 additions & 0 deletions sub-docker-compose-files/config/application.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
require_relative "boot"

require "rails/all"

# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)

module App
class Application < Rails::Application
# Initialize configuration defaults for originally generated Rails version.
config.load_defaults 7.0

# Configuration for the application, engines, and railties goes here.
#
# These settings can be overridden in specific environments using the files
# in config/environments, which are processed later.
#
# config.time_zone = "Central Time (US & Canada)"
# config.eager_load_paths << Rails.root.join("extras")
end
end
4 changes: 4 additions & 0 deletions sub-docker-compose-files/config/boot.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)

require "bundler/setup" # Set up gems listed in the Gemfile.
require "bootsnap/setup" # Speed up boot time by caching expensive operations.
10 changes: 10 additions & 0 deletions sub-docker-compose-files/config/cable.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
development:
adapter: async

test:
adapter: test

production:
adapter: redis
url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %>
channel_prefix: app_production
1 change: 1 addition & 0 deletions sub-docker-compose-files/config/credentials.yml.enc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
5mzCX+4vLDSl3ntQdBegjVOCh1TT3feVkxR6sXlaPtXFi5RamTWrxI+nVVRckaCHbf3unHbmcwF7RWj2ZeDz+RIUdB+G05oX5VM2VURB96e1TINqN1HpmLfsSYh1NdDY79aWDZ+6U57dAdg5j4CWuHoPD6HPtLiNQgk214ZnG6IS6rrRnEALtbHj96ato6/Bq1UWUH6jwqrpGpxUJf6URkeTm5hfEFr6eyS+5e4jzzJVG1j0R3PbSJhu2suiy5IpP7fCPiTtaNuo2Xddb91m7vR+wjFoaJ0oc8c1TbP2FSkik6RcrVTe+Iby81omPUCUhJHBOhF7Gd6dVjglyZ2FdLDWLY9znkWmBeWIhA7ygxIFwpTguNpMNbJQg4w7o2KDvIm0DR/F7ZYzdA1sWT13+fD7yjwQKUx7BbyQ--z0tX35i/X46jtlu2--Npcd+ersJAgMRaQFy8gPnQ==
25 changes: 25 additions & 0 deletions sub-docker-compose-files/config/database.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# SQLite. Versions 3.8.0 and up are supported.
# gem install sqlite3
#
# Ensure the SQLite 3 gem is defined in your Gemfile
# gem "sqlite3"
#
default: &default
adapter: sqlite3
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
timeout: 5000

development:
<<: *default
database: /public_db/development.sqlite3

# 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: /public_db/test.sqlite3

production:
<<: *default
database: /public_db/production.sqlite3
5 changes: 5 additions & 0 deletions sub-docker-compose-files/config/environment.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Load the Rails application.
require_relative "application"

# Initialize the Rails application.
Rails.application.initialize!
71 changes: 71 additions & 0 deletions sub-docker-compose-files/config/environments/development.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
require "active_support/core_ext/integer/time"

Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.

# In the development environment your application's code is reloaded any time
# it changes. This slows down response time but is perfect for development
# since you don't have to restart the web server when you make code changes.
config.cache_classes = false

# Do not eager load code on boot.
config.eager_load = false

# Show full error reports.
config.consider_all_requests_local = true

# Enable server timing
config.server_timing = true

# Enable/disable caching. By default caching is disabled.
# Run rails dev:cache to toggle caching.
if Rails.root.join("tmp/caching-dev.txt").exist?
config.action_controller.perform_caching = true
config.action_controller.enable_fragment_cache_logging = true

config.cache_store = :memory_store
config.public_file_server.headers = {
"Cache-Control" => "public, max-age=#{2.days.to_i}"
}
else
config.action_controller.perform_caching = false

config.cache_store = :null_store
end

# Store uploaded files on the local file system (see config/storage.yml for options).
config.active_storage.service = :local

# Don't care if the mailer can't send.
config.action_mailer.raise_delivery_errors = false

config.action_mailer.perform_caching = false

# Print deprecation notices to the Rails logger.
config.active_support.deprecation = :log

# Raise exceptions for disallowed deprecations.
config.active_support.disallowed_deprecation = :raise

# Tell Active Support which deprecation messages to disallow.
config.active_support.disallowed_deprecation_warnings = []

# Raise an error on page load if there are pending migrations.
config.active_record.migration_error = :page_load

# Highlight code that triggered database queries in logs.
config.active_record.verbose_query_logs = true

# Suppress logger output for asset requests.
config.assets.quiet = true

# Raises error for missing translations.
# config.i18n.raise_on_missing_translations = true

# Annotate rendered view with file names.
# config.action_view.annotate_rendered_view_with_filenames = true

# Uncomment if you wish to allow Action Cable access from any origin.
# config.action_cable.disable_request_forgery_protection = true
config.hosts = [IPAddr.new("0.0.0.0/0"), 'localhost', /.*/]
end
94 changes: 94 additions & 0 deletions sub-docker-compose-files/config/environments/production.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
require "active_support/core_ext/integer/time"

Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.

# Code is not reloaded between requests.
config.cache_classes = true

# 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?

# Compress CSS using a preprocessor.
# config.assets.css_compressor = :sass

# 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.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

# Include generic and useful information about system operation, but avoid logging too much
# information to avoid inadvertent exposure of personally identifiable information (PII).
config.log_level = :info

# 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 = "app_production"

config.action_mailer.perform_caching = false

# 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

# Don't log any deprecations.
config.active_support.report_deprecations = false

# 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
config.hosts = [/.*\.com/, IPAddr.new("0.0.0.0/0"), 'localhost', /.*/]
end
60 changes: 60 additions & 0 deletions sub-docker-compose-files/config/environments/test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
require "active_support/core_ext/integer/time"

# The test environment is used exclusively to run your application's
# test suite. You never need to work with it otherwise. Remember that
# your test database is "scratch space" for the test suite and is wiped
# and recreated between test runs. Don't rely on the data there!

Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.

# Turn false under Spring and add config.action_view.cache_template_loading = true.
config.cache_classes = true

# Eager loading loads your whole application. When running a single test locally,
# this probably isn't necessary. It's a good idea to do in a continuous integration
# system, or in some way before deploying your code.
config.eager_load = ENV["CI"].present?

# Configure public file server for tests with Cache-Control for performance.
config.public_file_server.enabled = true
config.public_file_server.headers = {
"Cache-Control" => "public, max-age=#{1.hour.to_i}"
}

# Show full error reports and disable caching.
config.consider_all_requests_local = true
config.action_controller.perform_caching = false
config.cache_store = :null_store

# Raise exceptions instead of rendering exception templates.
config.action_dispatch.show_exceptions = false

# Disable request forgery protection in test environment.
config.action_controller.allow_forgery_protection = false

# Store uploaded files on the local file system in a temporary directory.
config.active_storage.service = :test

config.action_mailer.perform_caching = false

# Tell Action Mailer not to deliver emails to the real world.
# The :test delivery method accumulates sent emails in the
# ActionMailer::Base.deliveries array.
config.action_mailer.delivery_method = :test

# Print deprecation notices to the stderr.
config.active_support.deprecation = :stderr

# Raise exceptions for disallowed deprecations.
config.active_support.disallowed_deprecation = :raise

# Tell Active Support which deprecation messages to disallow.
config.active_support.disallowed_deprecation_warnings = []

# Raises error for missing translations.
# config.i18n.raise_on_missing_translations = true

# Annotate rendered view with file names.
# config.action_view.annotate_rendered_view_with_filenames = true
end
12 changes: 12 additions & 0 deletions sub-docker-compose-files/config/initializers/assets.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Be sure to restart your server when you modify this file.

# Version of your assets, change this if you want to expire all your assets.
Rails.application.config.assets.version = "1.0"

# Add additional assets to the asset load path.
# Rails.application.config.assets.paths << Emoji.images_path

# Precompile additional assets.
# application.js, application.css, and all non-JS/CSS in the app/assets
# folder are already added.
# Rails.application.config.assets.precompile += %w( admin.js admin.css )
Loading