-
Notifications
You must be signed in to change notification settings - Fork 848
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Monolithic Docker provider #2632
Changes from 5 commits
22ad4b4
c9ec449
62c5796
ace8de7
92758fd
0b6b2ac
188bcaf
a646c93
ce156b6
a40ab54
e78b6f9
d80d105
79a57ea
48ab479
23464a6
7fd737e
76a008b
b8a0c44
fdade8b
d6ed345
a8101df
636a530
da3b697
de8c959
58a2c88
729da51
08c4db5
1cda256
ff1b71b
d103405
4acaa62
f0ae39a
39d794f
47057c8
8252690
bb58041
42efd1c
fabccb8
d442355
1da5dd1
00d7499
ef6106b
4a5d545
a488c4b
1a5394a
af1209f
42f99f1
3ee80e4
a11e359
c0f4a6c
22fd603
4c7e6bf
206e661
69a65af
60c5532
459e5e2
c67bb0c
1f0c981
c005314
bd53f8f
6d14048
906b15e
abea1f5
07f1111
cd3d1e3
e634188
798b6b6
9f5f064
b8f3745
1000b3e
f4696ea
2dfd0e4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ Vagrant.require_version '>= 2.2.4' | |
require 'yaml' | ||
require 'fileutils' | ||
require 'pathname' | ||
require 'socket' | ||
|
||
def sudo_warnings | ||
red = "\033[38;5;9m" # 124m" | ||
|
@@ -216,9 +217,9 @@ defaults['memory'] = 2048 | |
defaults['cores'] = 1 | ||
defaults['provider'] = 'virtualbox' | ||
|
||
# if Arm default to parallels | ||
# if Arm default to docker | ||
if Etc.uname[:version].include? 'ARM64' | ||
defaults['provider'] = 'parallels' | ||
defaults['provider'] = 'docker' | ||
end | ||
|
||
# This should rarely be overridden, so it's not included in the config/default-config.yml file. | ||
|
@@ -304,6 +305,8 @@ if show_logo | |
provider_version = '??' | ||
when 'hyperv' | ||
provider_version = 'n/a' | ||
when 'docker' | ||
provider_version = VagrantPlugins::DockerProvider::Driver.new.execute("docker", "-v").gsub("Docker version ", "") | ||
else | ||
provider_version = '??' | ||
end | ||
|
@@ -436,17 +439,42 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| | |
override.vm.box = 'bento/ubuntu-20.04' | ||
end | ||
|
||
def port_is_open?(*ports) | ||
_port = 0 | ||
ports.each do |port| | ||
_port = port | ||
begin | ||
Socket.tcp('127.0.0.1', port, connect_timeout: 5) {} | ||
rescue Errno::ECONNREFUSED, Errno::ETIMEDOUT | ||
return port | ||
end | ||
end | ||
|
||
loop do | ||
_port = _port + 1 | ||
begin | ||
Socket.tcp('127.0.0.1', _port, connect_timeout: 5) {} | ||
rescue Errno::ECONNREFUSED, Errno::ETIMEDOUT | ||
return _port | ||
end | ||
end | ||
end | ||
|
||
http_port = port_is_open?(80, 8080, 8888, 8000) | ||
https_port = port_is_open?(443, 8443, 9999, 9000) | ||
mysql_port = port_is_open?(3306) | ||
mailhog_port = port_is_open?(8025) | ||
|
||
# Docker use image. | ||
config.vm.provider :docker do |d| | ||
d.image = 'pentatonicfunk/vagrant-ubuntu-base-images:20.04' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we can avoid this by using a dockerfile and layering over a general ubuntu 20 container There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That'd be preferrable for me as well |
||
d.has_ssh = true | ||
if Vagrant::Util::Platform.platform == 'darwin19' | ||
# Docker in mac need explicit ports publish to access | ||
d.ports = [ "#{vvv_config['vm_config']['private_network_ip']}:80:80" ] | ||
d.ports += [ "#{vvv_config['vm_config']['private_network_ip']}:443:443" ] | ||
d.ports += [ "#{vvv_config['vm_config']['private_network_ip']}:3306:3306" ] | ||
d.ports += [ "#{vvv_config['vm_config']['private_network_ip']}:8025:8025" ] | ||
d.ports += [ "#{vvv_config['vm_config']['private_network_ip']}:1025:1025" ] | ||
d.ports = [ "#{http_port}:80" ] | ||
d.ports += [ "#{https_port}:443" ] | ||
d.ports += [ "#{mysql_port}:3306" ] | ||
d.ports += [ "#{mailhog_port}:8025" ] | ||
end | ||
end | ||
|
||
|
@@ -923,24 +951,6 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| | |
end | ||
end | ||
|
||
# specific trigger for mac and docker | ||
if Vagrant::Util::Platform.platform == 'darwin19' && vvv_config['vm_config']['provider'] == 'docker' | ||
config.trigger.before :up do |trigger| | ||
trigger.name = "VVV Setup docker local network before up" | ||
trigger.run = {inline: "bash -c 'sudo ifconfig lo0 alias #{vvv_config['vm_config']['private_network_ip']}/24'"} | ||
end | ||
config.trigger.after :halt do |trigger| | ||
trigger.name = 'VVV delete docker local network after halt' | ||
trigger.run = {inline: "bash -c 'sudo ifconfig lo0 inet delete #{vvv_config['vm_config']['private_network_ip']}'"} | ||
trigger.on_error = :continue | ||
end | ||
config.trigger.after :destroy do |trigger| | ||
trigger.name = 'VVV delete docker local network after destroy' | ||
trigger.run = {inline: "bash -c 'sudo ifconfig lo0 inet delete #{vvv_config['vm_config']['private_network_ip']}'"} | ||
trigger.on_error = :continue | ||
end | ||
end | ||
|
||
config.trigger.after :up do |trigger| | ||
trigger.name = 'VVV Post-Up' | ||
trigger.run_remote = { inline: '/srv/config/homebin/vagrant_up' } | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -58,5 +58,7 @@ function git_after_packages() { | |
vvv_info " * Git hasn't been told how to merge branches, setting pull.rebase false for the merge strategy" | ||
noroot git config --global pull.rebase false | ||
fi | ||
git config --global --add safe.directory '*' # Allow git to work well under docker provider | ||
noroot git config --global --add safe.directory '*' # Allow git to work well under docker provider | ||
Comment on lines
+61
to
+62
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. these might be needed regardless of wether we use docker or not, could these be a separate PR? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this should be extracted into a separate PR |
||
} | ||
vvv_add_hook after_packages git_after_packages |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this looks like a nice self contained change