From 4a20c0f5f1cc8d3f0598ca57a5b360690aa36dd2 Mon Sep 17 00:00:00 2001 From: David Siaw Date: Tue, 16 Jul 2024 16:41:39 +0900 Subject: [PATCH 1/6] fix dns in docker mode --- README.md | 4 ++-- lib/kaiser/cli.rb | 12 +++++++++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 69ad582b..51f3a5f8 100644 --- a/README.md +++ b/README.md @@ -38,14 +38,14 @@ docker build -t degica/kaiser . And then add the following line to your `.bashrc` or `.bash_profile` ``` -alias kaiser='docker run --pull=always --rm -ti -v /var/run/docker.sock:/var/run/docker.sock -v $HOME/.kaiser:/root/.kaiser -v `pwd`:`pwd` -e CONTEXT_DIR="`pwd`" degicadev/kaiser' +alias kaiser='docker run --pull=always --rm -ti -v /var/run/docker.sock:/var/run/docker.sock -v $HOME/.kaiser:/root/.kaiser -v `pwd`:`pwd` -e _KAISER_USER_HOME=$HOME -e _KAISER_POS=docker -e CONTEXT_DIR="`pwd`" degicadev/kaiser' ``` Or if you use fish ``` function kaiser - docker run --pull=always --rm -ti -v /var/run/docker.sock:/var/run/docker.sock -v $HOME/.kaiser:/root/.kaiser -v (pwd):(pwd) -e CONTEXT_DIR=(pwd) degicadev/kaiser $argv + docker run --pull=always --rm -ti -v /var/run/docker.sock:/var/run/docker.sock -v $HOME/.kaiser:/root/.kaiser -v (pwd):(pwd) -e _KAISER_USER_HOME=$HOME -e _KAISER_POS=docker -e CONTEXT_DIR=(pwd) degicadev/kaiser $argv end ``` diff --git a/lib/kaiser/cli.rb b/lib/kaiser/cli.rb index 2082a54f..801c8c57 100644 --- a/lib/kaiser/cli.rb +++ b/lib/kaiser/cli.rb @@ -571,8 +571,14 @@ def ensure_setup jwilder/nginx-proxy" ) - dnsconffile = "#{ENV['HOME']}/.kaiser/dnsconf" - File.write(dnsconffile, <<~HOSTS) + homedir_loc = ENV['HOME'] + if ENV['_KAISER_POS'] == 'docker' + homedir_loc = ENV['_KAISER_USER_HOME'] + end + + innerdnsconffile = "#{ENV['HOME']}/.kaiser/dnsconf" + outerdnsconffile = "#{homedir_loc}/.kaiser/dnsconf" + File.write(innerdnsconffile, <<~HOSTS) log-queries no-resolv server=8.8.8.8 @@ -585,7 +591,7 @@ def ensure_setup "docker run -d --name #{Config.config[:shared_names][:dns]} --network #{Config.config[:networkname]} - -v #{dnsconffile}:/etc/dnsmasq.conf:ro + -v #{outerdnsconffile}:/etc/dnsmasq.conf:ro degica/dnsmasq " ) From 16fc52d3299018698d61056ef10618681d37e6f1 Mon Sep 17 00:00:00 2001 From: David Siaw Date: Wed, 17 Jul 2024 18:54:19 +0900 Subject: [PATCH 2/6] rubocop --- lib/kaiser/cli.rb | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/kaiser/cli.rb b/lib/kaiser/cli.rb index 801c8c57..04b1c94a 100644 --- a/lib/kaiser/cli.rb +++ b/lib/kaiser/cli.rb @@ -572,9 +572,7 @@ def ensure_setup ) homedir_loc = ENV['HOME'] - if ENV['_KAISER_POS'] == 'docker' - homedir_loc = ENV['_KAISER_USER_HOME'] - end + homedir_loc = ENV['_KAISER_USER_HOME'] if ENV['_KAISER_POS'] == 'docker' innerdnsconffile = "#{ENV['HOME']}/.kaiser/dnsconf" outerdnsconffile = "#{homedir_loc}/.kaiser/dnsconf" From f973e6504d9b5d0395e4fb182058b1c036572faa Mon Sep 17 00:00:00 2001 From: David Siaw Date: Wed, 17 Jul 2024 18:59:24 +0900 Subject: [PATCH 3/6] rubocop again --- .rubocop_todo.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 0b668452..c5f8cf4e 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2024-06-27 01:53:02 UTC using RuboCop version 1.50.2. +# on 2024-07-17 09:55:51 UTC using RuboCop version 1.50.2. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new @@ -37,7 +37,7 @@ Lint/ConstantDefinitionInBlock: # Offense count: 13 # Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes. Metrics/AbcSize: - Max: 64 + Max: 67 # Offense count: 1 # Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns. @@ -48,7 +48,7 @@ Metrics/BlockLength: # Offense count: 1 # Configuration parameters: CountComments, CountAsOne. Metrics/ClassLength: - Max: 485 + Max: 488 # Offense count: 1 # Configuration parameters: AllowedMethods, AllowedPatterns. @@ -58,7 +58,7 @@ Metrics/CyclomaticComplexity: # Offense count: 17 # Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns. Metrics/MethodLength: - Max: 51 + Max: 54 # Offense count: 1 # Configuration parameters: CountKeywordArgs, MaxOptionalParameters. From c020e717730cd80dc4de7fd1f3a6a1081055d0f4 Mon Sep 17 00:00:00 2001 From: David Siaw Date: Fri, 19 Jul 2024 15:05:14 +0900 Subject: [PATCH 4/6] fix another pwd thing --- lib/kaiser/cli.rb | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/kaiser/cli.rb b/lib/kaiser/cli.rb index 04b1c94a..d8c6938c 100644 --- a/lib/kaiser/cli.rb +++ b/lib/kaiser/cli.rb @@ -229,7 +229,7 @@ def current_branch_db_image_dir def db_image_path(name) if name.start_with?('./') - path = "#{`pwd`.chomp}/#{name.sub('./', '')}" + path = "#{home_dir_loc}/#{name.sub('./', '')}" Config.info_out.puts "Database image path is: #{path}" return path end @@ -542,6 +542,12 @@ def selenium_node_image 'selenium/standalone-chrome-debug' end + def home_dir_loc + return ENV['_KAISER_USER_HOME'] if ENV['_KAISER_POS'] == 'docker' + + ENV['HOME'] + end + def ensure_setup ensure_env @@ -571,9 +577,6 @@ def ensure_setup jwilder/nginx-proxy" ) - homedir_loc = ENV['HOME'] - homedir_loc = ENV['_KAISER_USER_HOME'] if ENV['_KAISER_POS'] == 'docker' - innerdnsconffile = "#{ENV['HOME']}/.kaiser/dnsconf" outerdnsconffile = "#{homedir_loc}/.kaiser/dnsconf" File.write(innerdnsconffile, <<~HOSTS) From d307a8aee8412ba711180dc8ad75af4f8459657d Mon Sep 17 00:00:00 2001 From: David Siaw Date: Fri, 19 Jul 2024 15:08:26 +0900 Subject: [PATCH 5/6] typo --- lib/kaiser/cli.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/kaiser/cli.rb b/lib/kaiser/cli.rb index d8c6938c..038dc08b 100644 --- a/lib/kaiser/cli.rb +++ b/lib/kaiser/cli.rb @@ -578,7 +578,7 @@ def ensure_setup ) innerdnsconffile = "#{ENV['HOME']}/.kaiser/dnsconf" - outerdnsconffile = "#{homedir_loc}/.kaiser/dnsconf" + outerdnsconffile = "#{home_dir_loc}/.kaiser/dnsconf" File.write(innerdnsconffile, <<~HOSTS) log-queries no-resolv From 94226f580c59d0be48b01265e536078c14d7c7ea Mon Sep 17 00:00:00 2001 From: David Siaw Date: Fri, 19 Jul 2024 15:33:12 +0900 Subject: [PATCH 6/6] update rubocop --- .rubocop_todo.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index c5f8cf4e..12cbfc52 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2024-07-17 09:55:51 UTC using RuboCop version 1.50.2. +# on 2024-07-19 06:32:42 UTC using RuboCop version 1.50.2. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new @@ -37,7 +37,7 @@ Lint/ConstantDefinitionInBlock: # Offense count: 13 # Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes. Metrics/AbcSize: - Max: 67 + Max: 65 # Offense count: 1 # Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns. @@ -48,7 +48,7 @@ Metrics/BlockLength: # Offense count: 1 # Configuration parameters: CountComments, CountAsOne. Metrics/ClassLength: - Max: 488 + Max: 490 # Offense count: 1 # Configuration parameters: AllowedMethods, AllowedPatterns. @@ -58,7 +58,7 @@ Metrics/CyclomaticComplexity: # Offense count: 17 # Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns. Metrics/MethodLength: - Max: 54 + Max: 52 # Offense count: 1 # Configuration parameters: CountKeywordArgs, MaxOptionalParameters.