From 630f0fa7614c8ff800e17964aedffc8504e337f2 Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Tue, 28 May 2019 18:58:11 -0700 Subject: [PATCH] Vagrantfile: Add UBUNTU_MIRROR configuration option. The default http://archive.ubuntu.com/ubuntu/ is pretty slow in some locations. Signed-off-by: Anders Kaseorg --- Vagrantfile | 9 +++++++++ tools/setup/dev-vagrant-docker/Dockerfile | 3 +++ 2 files changed, 12 insertions(+) diff --git a/Vagrantfile b/Vagrantfile index 52d5c2da71..e14fdad4bd 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -57,6 +57,8 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| vm_num_cpus = "2" vm_memory = "2048" + ubuntu_mirror = "" + config.vm.synced_folder ".", "/vagrant", disabled: true if (/darwin/ =~ RUBY_PLATFORM) != nil 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 "GUEST_CPUS"; vm_num_cpus = value when "GUEST_MEMORY_MB"; vm_memory = value + when "UBUNTU_MIRROR"; ubuntu_mirror = value end end end @@ -109,6 +112,9 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| config.vm.provider "docker" do |d, override| d.build_dir = File.join(__dir__, "tools", "setup", "dev-vagrant-docker") 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.create_args = ["--ulimit", "nofile=1024:65536"] end @@ -135,6 +141,9 @@ set -o pipefail # something that we don't want to happen when running provision in a # 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 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 diff --git a/tools/setup/dev-vagrant-docker/Dockerfile b/tools/setup/dev-vagrant-docker/Dockerfile index 5bfa0019e0..7c30bc6340 100644 --- a/tools/setup/dev-vagrant-docker/Dockerfile +++ b/tools/setup/dev-vagrant-docker/Dockerfile @@ -1,8 +1,11 @@ FROM ubuntu:18.04 +ARG UBUNTU_MIRROR + # Basic packages and dependencies of docker-systemctl-replacement 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 \ + && { [ ! "$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 # stripped from the default Ubuntu cloud image and installs # ubuntu-minimal and ubuntu-standard.