Skip to content
This repository has been archived by the owner on Oct 28, 2024. It is now read-only.

Commit

Permalink
fix dns in docker mode (#104)
Browse files Browse the repository at this point in the history
fix dns in docker mode
  • Loading branch information
davidsiaw authored Jul 19, 2024
1 parent a67f843 commit 6c78017
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
8 changes: 4 additions & 4 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -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-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
Expand Down Expand Up @@ -37,7 +37,7 @@ Lint/ConstantDefinitionInBlock:
# Offense count: 13
# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes.
Metrics/AbcSize:
Max: 64
Max: 65

# Offense count: 1
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
Expand All @@ -48,7 +48,7 @@ Metrics/BlockLength:
# Offense count: 1
# Configuration parameters: CountComments, CountAsOne.
Metrics/ClassLength:
Max: 485
Max: 490

# Offense count: 1
# Configuration parameters: AllowedMethods, AllowedPatterns.
Expand All @@ -58,7 +58,7 @@ Metrics/CyclomaticComplexity:
# Offense count: 17
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
Metrics/MethodLength:
Max: 51
Max: 52

# Offense count: 1
# Configuration parameters: CountKeywordArgs, MaxOptionalParameters.
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```

Expand Down
15 changes: 11 additions & 4 deletions lib/kaiser/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -571,8 +577,9 @@ def ensure_setup
jwilder/nginx-proxy"
)

dnsconffile = "#{ENV['HOME']}/.kaiser/dnsconf"
File.write(dnsconffile, <<~HOSTS)
innerdnsconffile = "#{ENV['HOME']}/.kaiser/dnsconf"
outerdnsconffile = "#{home_dir_loc}/.kaiser/dnsconf"
File.write(innerdnsconffile, <<~HOSTS)
log-queries
no-resolv
server=8.8.8.8
Expand All @@ -585,7 +592,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
"
)
Expand Down

0 comments on commit 6c78017

Please sign in to comment.