Vagrantfile: Add UBUNTU_MIRROR configuration option.

The default http://archive.ubuntu.com/ubuntu/ is pretty slow in some
locations.

Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
This commit is contained in:
Anders Kaseorg 2019-05-28 18:58:11 -07:00
parent ae393456f9
commit 630f0fa761
2 changed files with 12 additions and 0 deletions

9
Vagrantfile vendored
View File

@ -57,6 +57,8 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
vm_num_cpus = "2" vm_num_cpus = "2"
vm_memory = "2048" vm_memory = "2048"
ubuntu_mirror = ""
config.vm.synced_folder ".", "/vagrant", disabled: true config.vm.synced_folder ".", "/vagrant", disabled: true
if (/darwin/ =~ RUBY_PLATFORM) != nil if (/darwin/ =~ RUBY_PLATFORM) != nil
config.vm.synced_folder ".", "/srv/zulip", type: "nfs", config.vm.synced_folder ".", "/srv/zulip", type: "nfs",
@ -80,6 +82,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
when "HOST_IP_ADDR"; host_ip_addr = value when "HOST_IP_ADDR"; host_ip_addr = value
when "GUEST_CPUS"; vm_num_cpus = value when "GUEST_CPUS"; vm_num_cpus = value
when "GUEST_MEMORY_MB"; vm_memory = value when "GUEST_MEMORY_MB"; vm_memory = value
when "UBUNTU_MIRROR"; ubuntu_mirror = value
end end
end end
end end
@ -109,6 +112,9 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.provider "docker" do |d, override| config.vm.provider "docker" do |d, override|
d.build_dir = File.join(__dir__, "tools", "setup", "dev-vagrant-docker") d.build_dir = File.join(__dir__, "tools", "setup", "dev-vagrant-docker")
d.build_args = ["--build-arg", "VAGRANT_UID=#{Process.uid}"] d.build_args = ["--build-arg", "VAGRANT_UID=#{Process.uid}"]
if !ubuntu_mirror.empty?
d.build_args += ["--build-arg", "UBUNTU_MIRROR=#{ubuntu_mirror}"]
end
d.has_ssh = true d.has_ssh = true
d.create_args = ["--ulimit", "nofile=1024:65536"] d.create_args = ["--ulimit", "nofile=1024:65536"]
end end
@ -135,6 +141,9 @@ set -o pipefail
# something that we don't want to happen when running provision in a # something that we don't want to happen when running provision in a
# development environment not using Vagrant. # development environment not using Vagrant.
# Set the Ubuntu mirror
[ ! '#{ubuntu_mirror}' ] || sudo sed -i 's|http://\\(\\w*\\.\\)*archive\\.ubuntu\\.com/ubuntu/\\? |#{ubuntu_mirror} |' /etc/apt/sources.list
# Set the MOTD on the system to have Zulip instructions # Set the MOTD on the system to have Zulip instructions
sudo ln -nsf /srv/zulip/tools/setup/dev-motd /etc/update-motd.d/99-zulip-dev sudo ln -nsf /srv/zulip/tools/setup/dev-motd /etc/update-motd.d/99-zulip-dev
sudo rm -f /etc/update-motd.d/10-help-text sudo rm -f /etc/update-motd.d/10-help-text

View File

@ -1,8 +1,11 @@
FROM ubuntu:18.04 FROM ubuntu:18.04
ARG UBUNTU_MIRROR
# Basic packages and dependencies of docker-systemctl-replacement # Basic packages and dependencies of docker-systemctl-replacement
RUN echo locales locales/default_environment_locale select en_US.UTF-8 | debconf-set-selections \ RUN echo locales locales/default_environment_locale select en_US.UTF-8 | debconf-set-selections \
&& echo locales locales/locales_to_be_generated select "en_US.UTF-8 UTF-8" | debconf-set-selections \ && echo locales locales/locales_to_be_generated select "en_US.UTF-8 UTF-8" | debconf-set-selections \
&& { [ ! "$UBUNTU_MIRROR" ] || sed -i "s|http://\(\w*\.\)*archive\.ubuntu\.com/ubuntu/\? |$UBUNTU_MIRROR |" /etc/apt/sources.list; } \
# This restores man pages and other documentation that have been # This restores man pages and other documentation that have been
# stripped from the default Ubuntu cloud image and installs # stripped from the default Ubuntu cloud image and installs
# ubuntu-minimal and ubuntu-standard. # ubuntu-minimal and ubuntu-standard.