diff --git a/.docker/00-prepare-for-prod-dump.sql b/.docker/00-prepare-for-prod-dump.sql index 81b86aa..369d9ff 100644 --- a/.docker/00-prepare-for-prod-dump.sql +++ b/.docker/00-prepare-for-prod-dump.sql @@ -1,3 +1,4 @@ CREATE DATABASE decidim_luzern_production; -CREATE ROLE postgres; -CREATE ROLE app; +CREATE DATABASE app; +CREATE ROLE postgres WITH LOGIN SUPERUSER PASSWORD 'postgres'; +CREATE ROLE app WITH LOGIN SUPERUSER PASSWORD 'app'; diff --git a/Gemfile.lock b/Gemfile.lock index 7de09a5..165bb04 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -241,7 +241,7 @@ GEM cells-rails (0.1.5) actionpack (>= 5.0) cells (>= 4.1.6, < 5.0.0) - charlock_holmes (0.7.7) + charlock_holmes (0.7.9) chef-utils (18.4.2) concurrent-ruby childprocess (4.1.0) @@ -1052,4 +1052,4 @@ RUBY VERSION ruby 3.0.6p216 BUNDLED WITH - 2.5.5 + 2.5.23 diff --git a/bin/bundle-binstub b/bin/bundle-binstub index 50da5fd..65642f2 100755 --- a/bin/bundle-binstub +++ b/bin/bundle-binstub @@ -8,7 +8,7 @@ # this file is here to facilitate running it. # -require "rubygems" +require 'rubygems' m = Module.new do module_function @@ -18,36 +18,36 @@ m = Module.new do end def env_var_version - ENV["BUNDLER_VERSION"] + ENV.fetch('BUNDLER_VERSION', nil) end def cli_arg_version return unless invoked_as_script? # don't want to hijack other binstubs - return unless "update".start_with?(ARGV.first || " ") # must be running `bundle update` + return unless 'update'.start_with?(ARGV.first || ' ') # must be running `bundle update` + bundler_version = nil update_index = nil ARGV.each_with_index do |a, i| - if update_index && update_index.succ == i && a.match?(Gem::Version::ANCHORED_VERSION_PATTERN) - bundler_version = a - end + bundler_version = a if update_index && update_index.succ == i && a.match?(Gem::Version::ANCHORED_VERSION_PATTERN) next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/ - bundler_version = $1 + + bundler_version = Regexp.last_match(1) update_index = i end bundler_version end def gemfile - gemfile = ENV["BUNDLE_GEMFILE"] - return gemfile if gemfile && !gemfile.empty? + gemfile = ENV.fetch('BUNDLE_GEMFILE', nil) + return gemfile if gemfile - File.expand_path("../Gemfile", __dir__) + File.expand_path('../Gemfile', __dir__) end def lockfile lockfile = case File.basename(gemfile) - when "gems.rb" then gemfile.sub(/\.rb$/, ".locked") + when 'gems.rb' then gemfile.sub(/\.rb$/, '.locked') else "#{gemfile}.lock" end File.expand_path(lockfile) @@ -55,8 +55,10 @@ m = Module.new do def lockfile_version return unless File.file?(lockfile) + lockfile_contents = File.read(lockfile) return unless lockfile_contents =~ /\n\nBUNDLED WITH\n\s{2,}(#{Gem::Version::VERSION_PATTERN})\n/ + Regexp.last_match(1) end @@ -76,21 +78,30 @@ m = Module.new do end def load_bundler! - ENV["BUNDLE_GEMFILE"] ||= gemfile + ENV['BUNDLE_GEMFILE'] ||= gemfile activate_bundler end def activate_bundler gem_error = activation_error_handling do - gem "bundler", bundler_requirement + gem 'bundler', bundler_requirement end return if gem_error.nil? + require_error = activation_error_handling do - require "bundler/version" + require 'bundler/version' + end + if require_error.nil? && Gem::Requirement.new(bundler_requirement).satisfied_by?(Gem::Version.new(Bundler::VERSION)) + return end - return if require_error.nil? && Gem::Requirement.new(bundler_requirement).satisfied_by?(Gem::Version.new(Bundler::VERSION)) - warn "Activating bundler (#{bundler_requirement}) failed:\n#{gem_error.message}\n\nTo install the version of bundler this project requires, run `gem install bundler -v '#{bundler_requirement}'`" + + warn <<~WARN + Activating bundler (#{bundler_requirement}) failed: + #{gem_error.message} + + To install the version of bundler this project requires, run `gem install bundler -v '#{bundler_requirement}'` + WARN exit 42 end @@ -104,6 +115,4 @@ end m.load_bundler! -if m.invoked_as_script? - load Gem.bin_path("bundler", "bundle") -end +load Gem.bin_path('bundler', 'bundle') if m.invoked_as_script? diff --git a/docker-compose.yml b/docker-compose.yml index f7266b2..361dd96 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -40,8 +40,8 @@ services: - 5432:5432 volumes: - pg-data:/var/lib/postgresql/data - #- ./.docker/00-prepare-for-prod-dump.sql:/docker-entrypoint-initdb.d/00-prepare-for-prod-dump.sql - #- ./.docker/database-init.sql:/docker-entrypoint-initdb.d/database-init.sql + - ./.docker/00-prepare-for-prod-dump.sql:/docker-entrypoint-initdb.d/00-prepare-for-prod-dump.sql + # - ./.docker/database-init.sql:/docker-entrypoint-initdb.d/database-init.sql cache: image: memcached:1.5-alpine command: [ memcached, -l, '0.0.0.0', -p, '11211' ]