From 2f27254c29fdfaa289b079183ee82bbeaaf4cc2f Mon Sep 17 00:00:00 2001 From: Tim Morgan Date: Tue, 10 Sep 2024 15:32:44 -0400 Subject: [PATCH] ActionCable configuration for development and production (using AnyCable) --- .github/workflows/deploy.yml | 2 +- .gitignore | 1 + Dockerfile | 46 +++++++++++----------- Gemfile | 5 ++- Gemfile.lock | 33 +++++++++++++++- README.md | 15 ++++++-- bin/anycable-go | 22 +++++++++++ bin/cable | 2 +- config/anycable.yml | 42 ++++++++++++++++++++ config/application.rb | 2 + config/cable.yml | 8 ++-- config/credentials.yml.enc | 2 +- config/dockerfile.yml | 1 + config/environments/cypress.rb | 61 ++++++++++++++++++------------ config/environments/development.rb | 3 ++ config/environments/production.rb | 4 +- config/routes.rb | 4 -- config/storage.yml | 2 +- config/urls.yml | 4 +- fly.toml | 23 ++++++----- 20 files changed, 205 insertions(+), 77 deletions(-) create mode 100755 bin/anycable-go create mode 100644 config/anycable.yml diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 2630e4d..bea1aa0 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -25,7 +25,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Set up flyctl uses: superfly/flyctl-actions/setup-flyctl@master - name: Deploy to Fly.io diff --git a/.gitignore b/.gitignore index ee7c089..579347c 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ spec/examples.txt +bin/dist diff --git a/Dockerfile b/Dockerfile index 80d7600..42338ac 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,51 +1,53 @@ # syntax = docker/dockerfile:1 -# This Dockerfile is designed for production, not development. Use with Kamal or build'n'run by hand: -# docker build -t my-app . -# docker run -d -p 80:80 -p 443:443 --name my-app -e RAILS_MASTER_KEY= my-app - -# Make sure RUBY_VERSION matches the Ruby version in .ruby-version +# Make sure RUBY_VERSION matches the Ruby version in .ruby-version and Gemfile ARG RUBY_VERSION=3.3.5 -FROM docker.io/library/ruby:$RUBY_VERSION-slim AS base +FROM ruby:$RUBY_VERSION-slim as base LABEL fly_launch_runtime="rails" # Rails app lives here WORKDIR /rails -# Install base packages -RUN apt-get update -qq && \ - apt-get install --no-install-recommends -y curl libjemalloc2 libvips postgresql-client && \ - rm -rf /var/lib/apt/lists /var/cache/apt/archives - # Set production environment -ENV RAILS_ENV="production" \ - BUNDLE_DEPLOYMENT="1" \ +ENV BUNDLE_DEPLOYMENT="1" \ BUNDLE_PATH="/usr/local/bundle" \ - BUNDLE_WITHOUT="development:test" + BUNDLE_WITHOUT="development:test" \ + RAILS_ENV="production" + +# Update gems and bundler +RUN gem update --system --no-document && \ + gem install -N bundler + # Throw-away build stage to reduce size of final image -FROM base AS build +FROM base as build # Install packages needed to build gems RUN apt-get update -qq && \ - apt-get install --no-install-recommends -y build-essential git libpq-dev pkg-config libvips && \ - rm -rf /var/lib/apt/lists /var/cache/apt/archives + apt-get install --no-install-recommends -y build-essential libpq-dev libvips # Install application gems -COPY Gemfile Gemfile.lock ./ +COPY --link Gemfile Gemfile.lock ./ RUN bundle install && \ + bundle exec bootsnap precompile --gemfile && \ rm -rf ~/.bundle/ "${BUNDLE_PATH}"/ruby/*/cache "${BUNDLE_PATH}"/ruby/*/bundler/gems/*/.git # Copy application code -COPY . . - +COPY --link . . +# Precompile bootsnap code for faster boot times +RUN bundle exec bootsnap precompile app/ lib/ # Final stage for app image FROM base +# Install packages needed for deployment +RUN apt-get update -qq && \ + apt-get install --no-install-recommends -y curl imagemagick libvips postgresql-client && \ + rm -rf /var/lib/apt/lists /var/cache/apt/archives + # Copy built artifacts: gems, application COPY --from=build "${BUNDLE_PATH}" "${BUNDLE_PATH}" COPY --from=build /rails /rails @@ -53,10 +55,10 @@ COPY --from=build /rails /rails # Run and own only the runtime files as a non-root user for security RUN groupadd --system --gid 1000 rails && \ useradd rails --uid 1000 --gid 1000 --create-home --shell /bin/bash && \ - chown -R rails:rails db log storage tmp + chown -R 1000:1000 db log storage tmp USER 1000:1000 -# Entrypoint prepares the database. +# Entrypoint sets up the container. ENTRYPOINT ["/rails/bin/docker-entrypoint"] # Start the server by default, this can be overwritten at runtime diff --git a/Gemfile b/Gemfile index cb1fd67..7a777fb 100644 --- a/Gemfile +++ b/Gemfile @@ -9,6 +9,7 @@ gem "bootsnap" gem "good_job" gem "rack-cors" gem "rails" +gem "puma" # MODELS gem "active_storage_validations" @@ -27,12 +28,14 @@ gem "redis" gem "devise" gem "devise-jwt" +# ACTION CABLE +gem "anycable-rails" + # ERRORS gem "bugsnag" group :development do gem "listen" - gem "puma" # LINTING gem "brakeman", require: false diff --git a/Gemfile.lock b/Gemfile.lock index b9dfbb9..2855d90 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -78,8 +78,23 @@ GEM tzinfo (~> 2.0, >= 2.0.5) addressable (2.8.7) public_suffix (>= 2.0.2, < 7.0) + anycable (1.5.1) + anycable-core (= 1.5.1) + grpc (~> 1.53) + anycable-core (1.5.1) + anyway_config (~> 2.2) + google-protobuf (~> 3.25) + anycable-rails (1.5.2) + anycable (~> 1.5.0) + anycable-rails-core (= 1.5.2) + anycable-rails-core (1.5.2) + actioncable (>= 6.0) + anycable-core (~> 1.5.0) + globalid + anyway_config (2.6.4) + ruby-next-core (~> 1.0) aws-eventstream (1.3.0) - aws-partitions (1.971.0) + aws-partitions (1.972.0) aws-sdk-core (3.203.0) aws-eventstream (~> 1, >= 1.3.0) aws-partitions (~> 1, >= 1.651.0) @@ -167,6 +182,20 @@ GEM fugit (>= 1.11.0) railties (>= 6.1.0) thor (>= 1.0.0) + google-protobuf (3.25.4-aarch64-linux) + google-protobuf (3.25.4-arm64-darwin) + google-protobuf (3.25.4-x86_64-linux) + googleapis-common-protos-types (1.15.0) + google-protobuf (>= 3.18, < 5.a) + grpc (1.66.0-aarch64-linux) + google-protobuf (>= 3.25, < 5.0) + googleapis-common-protos-types (~> 1.0) + grpc (1.66.0-arm64-darwin) + google-protobuf (>= 3.25, < 5.0) + googleapis-common-protos-types (~> 1.0) + grpc (1.66.0-x86_64-linux) + google-protobuf (>= 3.25, < 5.0) + googleapis-common-protos-types (~> 1.0) hashdiff (1.1.1) i18n (1.14.5) concurrent-ruby (~> 1.0) @@ -310,6 +339,7 @@ GEM rspec-mocks (~> 3.13) rspec-support (~> 3.13) rspec-support (3.13.1) + ruby-next-core (1.0.3) ruby-vips (2.2.2) ffi (~> 1.12) logger @@ -350,6 +380,7 @@ PLATFORMS DEPENDENCIES active_storage_validations + anycable-rails aws-sdk-s3 binding_of_caller boolean diff --git a/README.md b/README.md index 93f716e..153fe6e 100644 --- a/README.md +++ b/README.md @@ -53,7 +53,8 @@ An example Foreman script that accomplishes all of this: backend: cd Backend && rvm 3.3.5@greenie exec rails server frontend: cd Frontend && yarn serve workers: cd Backend && rvm 3.3.5@greenie exec bundle exec good_job start -cable: cd Backend && rvm 3.3.5@greenie exec ./bin/cable +anycable: cd Backend && rvm 3.3.5@greenie exec anycable +ws: cd Backend && rvm 3.3.5@greenie execcbin/anycable-go --port=8080 mail: mailcatcher -f ``` @@ -77,12 +78,20 @@ E2E test application: backend: cd Backend && rvm 3.3.5@greenie exec rails server -e cypress -b localhost frontend: cd Frontend && yarn run test:e2e workers: cd Backend && RAILS_ENV=cypress rvm 3.3.5@greenie exec bundle exec good_job start -cable: cd Backend && rvm 3.3.5@greenie exec ./bin/cable -e cypress +anycable: cd Backend && RAILS_ENV=cypress rvm 3.3.5@greenie exec anycable +ws: cd Backend && rvm 3.3.5@greenie execcbin/anycable-go --port=8080 ``` #### Deployment -The application is deployed using Capistrano by running `cap production deploy`. +The application is deployed on Fly.io automatically after CI completes, with a +GitHub Action. The `fly.toml` file contains the architecture for the production +environment: an app server, a GoodJob worker server, a Redis cluster, and a +PostgreSQL database cluster. + +The Rails processes run on a separate Fly.io cluster from the AnyCable +processes. An nginx cluster reverse-proxies requests for `/cable` to the +AnyCable process, and all other requests to the Rails process. ## Architecture diff --git a/bin/anycable-go b/bin/anycable-go new file mode 100755 index 0000000..0f1a45b --- /dev/null +++ b/bin/anycable-go @@ -0,0 +1,22 @@ +#!/bin/bash + +cd $(dirname $0)/.. + +# It's recommended to use the exact version of AnyCable here +version="latest" + +if [ ! -f ./bin/dist/anycable-go ]; then + echo "AnyCable server is not installed, downloading..." + ./bin/rails g anycable:download --version=$version --bin-path=./bin/dist +fi + +curVersion=$(./bin/dist/anycable-go -v) + +if [[ "$version" != "latest" ]]; then + if [[ "$curVersion" != "$version"* ]]; then + echo "AnyCable server version is not $version, downloading a new one..." + ./bin/rails g anycable:download --version=$version --bin-path=./bin/dist + fi +fi + +./bin/dist/anycable-go $@ diff --git a/bin/cable b/bin/cable index 977abb3..e767d17 100755 --- a/bin/cable +++ b/bin/cable @@ -1 +1 @@ -bundle exec puma -p 28080 cable/config.ru --pidfile tmp/pids/cable.pid $* +bundle exec puma -p 8080 cable/config.ru --pidfile tmp/pids/cable.pid $* diff --git a/config/anycable.yml b/config/anycable.yml new file mode 100644 index 0000000..9992d86 --- /dev/null +++ b/config/anycable.yml @@ -0,0 +1,42 @@ +# This file contains per-environment settings for AnyCable. +# +# Since AnyCable config is based on anyway_config (https://github.com/palkan/anyway_config), all AnyCable settings +# can be set or overridden through the corresponding environment variables. +# E.g., `rpc_host` is overridden by ANYCABLE_RPC_HOST, `debug` by ANYCABLE_DEBUG etc. +# +# Note that AnyCable recognizes REDIS_URL env variable for Redis pub/sub adapter. If you want to +# use another Redis instance for AnyCable, provide ANYCABLE_REDIS_URL variable. +# +# Read more about AnyCable configuration here: https://docs.anycable.io/ruby/configuration +# +default: &default + # Turn on/off access logs ("Started..." and "Finished...") + access_logs_disabled: false + # Whether to enable gRPC level logging or not + log_grpc: false + # Use Redis to broadcast messages to AnyCable server + broadcast_adapter: redis + # You can use REDIS_URL env var to configure Redis URL. + # Localhost is used by default. + # redis_url: "redis://localhost:6379/1" + # Use the same channel name for WebSocket server, e.g.: + # $ anycable-go --redis_channel="__anycable__" + # redis_channel: "__anycable__" + +development: + <<: *default + # WebSocket endpoint of your AnyCable server for clients to connect to + # Make sure you have the `action_cable_meta_tag` in your HTML layout + # to propagate this value to the client app + websocket_url: "ws://localhost:8080/cable" + +test: + <<: *default + +cypress: + <<: *default + websocket_url: "ws://localhost:8080/cable" + +production: + <<: *default + websocket_url: ~ diff --git a/config/application.rb b/config/application.rb index 1deb722..01facdb 100644 --- a/config/application.rb +++ b/config/application.rb @@ -81,5 +81,7 @@ class Application < Rails::Application config.good_job.enable_cron = true config.good_job.dashboard_default_locale = :en config.good_job.queues = "greenie_#{Rails.env}_default" + + config.host_authorization = { exclude: ->(request) { request.path.start_with?('/up') } } end end diff --git a/config/cable.yml b/config/cable.yml index e47cdc7..9c47d39 100644 --- a/config/cable.yml +++ b/config/cable.yml @@ -1,5 +1,5 @@ development: - adapter: redis + adapter: <%= ENV.fetch("ACTION_CABLE_ADAPTER", "any_cable") %> url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %> channel_prefix: greenie_development @@ -7,11 +7,9 @@ test: adapter: test cypress: - adapter: redis + adapter: <%= ENV.fetch("ACTION_CABLE_ADAPTER", "any_cable") %> url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %> channel_prefix: greenie_cypress production: - adapter: redis - url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %> - channel_prefix: greenie_production + adapter: any_cable diff --git a/config/credentials.yml.enc b/config/credentials.yml.enc index 3c795c1..28e81f9 100644 --- a/config/credentials.yml.enc +++ b/config/credentials.yml.enc @@ -1 +1 @@ -5/tNC7Bf6oNXk7R5vPKWzcxPB70+LGylGly0746Q2XS/UGDkPEKQrJoZ9az8FDuYu5gWaZ7fbbJjmYIPda3o9dAMkU02XHIjFV1DrlKUxdAPZfeY5tXDkDG1VUaqbtE3LMBjL7zHonE+EiI5zR4qyl2EuCuZBV2Nc8QacLpEu+j7Z4g1nw3dcYetAcOyvBRHGQ0vJbF7JiWgNA55sTFoAv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EUnBg0+4i48ljzj8dfklKT6lMo3rVbD3nBLDGLTbrLr3D2S79W64Yea8euQPt/AA3Y2jC0W1XF+8MYUKsckAHcRhHp5xyBYZTEJqBICPRgw6hPVnpR+nPUv5qFxZqWe5Kqcxz--YDMRhzBTNX1Pj6Gl--bCBc0HuDUfX76AR+FhOldA== \ No newline at end of file diff --git a/config/dockerfile.yml b/config/dockerfile.yml index 2568cc9..420936f 100644 --- a/config/dockerfile.yml +++ b/config/dockerfile.yml @@ -7,3 +7,4 @@ options: postgresql: true prepare: false redis: true + tigris: true diff --git a/config/environments/cypress.rb b/config/environments/cypress.rb index 6db91c7..877e7cf 100644 --- a/config/environments/cypress.rb +++ b/config/environments/cypress.rb @@ -1,12 +1,14 @@ # frozen_string_literal: true +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 on - # every request. This slows down response time but is perfect for development + # 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 + config.enable_reloading = true # Do not eager load code on boot. config.eager_load = false @@ -14,45 +16,56 @@ # Show full error reports. config.consider_all_requests_local = 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.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 + # Enable server timing. + config.server_timing = true - config.cache_store = :null_store - end + config.action_controller.perform_caching = false + config.cache_store = :null_store # Store uploaded files on the local file system (see config/storage.yml for options). config.active_storage.service = :local + config.action_mailer.delivery_method = :test + + # Don't care if the mailer can't send. + config.action_mailer.raise_delivery_errors = false + + # Disable caching for Action Mailer templates even if Action Controller + # caching is enabled. + config.action_mailer.perform_caching = false + + config.action_mailer.default_url_options = {host: "localhost", port: 3000} + # 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 - config.action_mailer.delivery_method = :file + # Highlight code that enqueued background job in logs. + config.active_job.verbose_enqueue_logs = true # Raises error for missing translations. - # config.action_view.raise_on_missing_translations = true + config.i18n.raise_on_missing_translations = true - # Use an evented file watcher to asynchronously detect changes in source code, - # routes, locales, etc. This feature depends on the listen gem. - config.file_watcher = ActiveSupport::EventedFileUpdateChecker + # Annotate rendered view with file names. + config.action_view.annotate_rendered_view_with_filenames = true - # Mount Action Cable outside main process or domain. - config.action_cable.mount_path = nil + # Uncomment if you wish to allow Action Cable access from any origin. + # config.action_cable.disable_request_forgery_protection = true - # Use a different cache store in production. - config.cache_store = :redis_cache_store, {url: "redis://localhost:6379/0/greenie_cypress_cache"} + # Raise error when a before_action's only/except options reference missing actions. + config.action_controller.raise_on_missing_callback_actions = true - config.good_job.poll_interval = 1 + # Mount Action Cable outside main process or domain. + config.action_cable.mount_path = nil end diff --git a/config/environments/development.rb b/config/environments/development.rb index 565c752..bf7c6d0 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -74,4 +74,7 @@ # Apply autocorrection by RuboCop to files generated by `bin/rails generate`. config.generators.apply_rubocop_autocorrect_after_generate! + + # Mount Action Cable outside main process or domain. + config.action_cable.mount_path = nil end diff --git a/config/environments/production.rb b/config/environments/production.rb index 072a5ac..dd43efa 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -31,11 +31,11 @@ # 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). + # Store uploaded files in Tigris Global Object Storage (see config/storage.yml for options). config.active_storage.service = :amazon # Mount Action Cable outside main process or domain. - # config.action_cable.mount_path = nil + 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.*/ ] diff --git a/config/routes.rb b/config/routes.rb index de2da88..72e6ce4 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -12,10 +12,6 @@ get "/cypress/emails" => CypressEmails.new end - if Rails.env.production? - mount ActionCable.server => "/cable" - end - devise_for :squadrons, skip: :all devise_scope :squadron do post "login" => "sessions#create" diff --git a/config/storage.yml b/config/storage.yml index 71df899..a5ff7c5 100644 --- a/config/storage.yml +++ b/config/storage.yml @@ -38,5 +38,5 @@ amazon: access_key_id: <%= Rails.application.credentials.dig(:aws, :access_key_id) %> secret_access_key: <%= Rails.application.credentials.dig(:aws, :secret_access_key) %> region: auto - bucket: greenie-storage + bucket: greenie endpoint: https://fly.storage.tigris.dev diff --git a/config/urls.yml b/config/urls.yml index 6e6ef52..5c2e1d4 100644 --- a/config/urls.yml +++ b/config/urls.yml @@ -1,11 +1,11 @@ development: frontend: 'http://localhost:5100' backend: 'http://localhost:5100' - cable: 'ws://localhost:28080/cable' + cable: 'ws://localhost:8080/cable' cypress: frontend: 'http://localhost:5100' backend: 'http://localhost:5100' - cable: 'ws://localhost:28080/cable' + cable: 'ws://localhost:8080/cable' test: frontend: 'http://frontend.example.com' backend: 'http://backend.example.com' diff --git a/fly.toml b/fly.toml index 5e48918..a395ebf 100644 --- a/fly.toml +++ b/fly.toml @@ -1,31 +1,36 @@ -# fly.toml app configuration file generated for greenie-app on 2024-06-19T15:19:06-07:00 +# fly.toml app configuration file generated for greenie-backend on 2024-09-11T12:54:50-07:00 # # See https://fly.io/docs/reference/configuration/ for information about how to use this file. # -app = 'greenie-app' +app = 'greenie-backend' primary_region = 'sjc' console_command = '/rails/bin/rails console' -[build] - [deploy] - release_command = './bin/rails db:prepare' + release_command = "./bin/rails db:prepare" [processes] - app = './bin/rails server' + app = 'bin/rails server' good_job = 'bundle exec good_job start' [http_service] internal_port = 3000 - force_https = true - auto_stop_machines = true + auto_stop_machines = 'stop' auto_start_machines = true min_machines_running = 0 processes = ['app'] +#[[http_service.checks]] +# grace_period = "30s" +# interval = "30s" +# method = "GET" +# timeout = "5s" +# path = "/up" +# protocol = "http" + [[vm]] - memory = '1gb' + memory = '512mb' cpu_kind = 'shared' cpus = 1