From d64772bdfc4d444efa272a525f8fae776a3c220e Mon Sep 17 00:00:00 2001 From: Benjamin Date: Thu, 22 Apr 2021 17:50:59 -0500 Subject: [PATCH] Darwin fixes --- config/application.rb | 16 ++++++++++++---- config/couchdb.yml | 2 +- faye/Dockerfile | 1 + faye/rebuild-docker.sh | 12 +++++++++--- 4 files changed, 23 insertions(+), 8 deletions(-) diff --git a/config/application.rb b/config/application.rb index 3cf45013..625c2d40 100644 --- a/config/application.rb +++ b/config/application.rb @@ -11,12 +11,20 @@ require 'sprockets/railtie' require 'net/http' # lib/qwaiter/broadcaster/faye.rb # custom override hack for the couchbase-setting gem, needs to be loaded before other gems, is settings only without dependencies -require File.expand_path('./../../lib/couchbase-setting', __FILE__) +#require File.expand_path('./../../lib/couchbase-setting', __FILE__) +Bundler.require(*Rails.groups(assets: %w[development test user_app])) +Bundler.require(:assets) if ENV['DEPLOY'] == 'yes' -Bundler.require(*Rails.groups(assets: %w[ development test user_app ])) -Bundler.require(:assets) if ENV['DEPLOY']=='yes' - +#NOTE: the JSON.create_id getter/setter has been moved to Thread.current implementation which +# leads to "json_class" fallbacks for created threads. Maybe this will be fixed for future +# rails versions. Current is: 6.1.3.1 +# For now make the getter Thread universal, not safe +module JSON + def self.create_id + 'ruby_class' + end +end if Rails.env.development? class CouchRest::Connection alias_method :old_execute, :execute diff --git a/config/couchdb.yml b/config/couchdb.yml index fb5bae2b..8b01b6ca 100644 --- a/config/couchdb.yml +++ b/config/couchdb.yml @@ -1,7 +1,7 @@ development: validation_framework: :active_model #optional #database: "http://mozo:secret@localhost:5984/qwaiter_development" - database: "http://admin:development@localhost:5984/mozo_development" + database: "http://admin:admin@localhost:5984/mozo_development" #database: mozo_development test: validation_framework: :active_model #optional diff --git a/faye/Dockerfile b/faye/Dockerfile index da188670..7f412f97 100644 --- a/faye/Dockerfile +++ b/faye/Dockerfile @@ -36,6 +36,7 @@ COPY ./faye /usr/src/app ENV FAYE_PORT=9296 EXPOSE $FAYE_PORT + #CMD thin start -R config.ru -p $FAYE_PORT CMD thin start -R config.ru -p $FAYE_PORT --ssl --ssl-key-file=ssl/privkey.pem --ssl-cert-file=ssl/fullchain.pem diff --git a/faye/rebuild-docker.sh b/faye/rebuild-docker.sh index aedfd181..3544979f 100755 --- a/faye/rebuild-docker.sh +++ b/faye/rebuild-docker.sh @@ -4,6 +4,7 @@ # 1. ensure this script is run from the project's root, not the faye directory pwd_dirname=$(basename $(pwd)) script_dirname="faye" +arch=$(uname) #1certs_dir="/etc/letsencrypt/live/mozo.bar" certs_dir="/Users/bj/Library/Application Support/mkcert" #certs_dir="/home/benjamin/mozo/mozo-user/ssl" @@ -18,8 +19,9 @@ if [ -d "$certs_dir" ]; then rm -rf $script_dirname/ssl mkdir $script_dirname/ssl # Note the -L option for copy is required, since the target are symbolic links and we want the real files - if [ -f "$certs_dir/localhost-key.pem" ]; then - echo "Using localhost certificate copy https://medium.com/@matayoshi.mariano/how-to-add-ssl-to-your-localhost-with-puma-37a66a649f29" + #if [ -f "$certs_dir/localhost-key.pem" ]; then + if [ $arch == "Darwin" ]; then + echo "Using Darwin localhost certificate copy https://medium.com/@matayoshi.mariano/how-to-add-ssl-to-your-localhost-with-puma-37a66a649f29" cp "$certs_dir/localhost-key.pem" $script_dirname/ssl/privkey.pem cp "$certs_dir/localhost.pem" $script_dirname/ssl/fullchain.pem else @@ -44,7 +46,11 @@ docker build -f faye/Dockerfile -t mozo_faye . # docker run -t -i --rm mozo_faye bash # 5. Spin up the counter container from the generated image -docker run --network=host --restart unless-stopped --detach --name=mozo_faye mozo_faye +if [ $arch == "Darwin" ]; then + docker run -p 9296:9296 --restart unless-stopped --detach --name=mozo_faye mozo_faye +else + docker run --network=host --restart unless-stopped --detach --name=mozo_faye mozo_faye +fi # To just start the container created through al these steps without rebuilding them: # docker container start $(docker ps -a -q --filter ancestor=mozo_faye)