From f21d3be5fbd49bd1a386a232c6a57230cfd52145 Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Mon, 27 May 2019 19:21:51 -0700 Subject: [PATCH] =?UTF-8?q?dev-vagrant-docker:=20Copy=20the=20host=20user?= =?UTF-8?q?=E2=80=99s=20uid=20for=20the=20vagrant=20user.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This allows /srv/zulip to be writable from the guest even if the host user’s uid is not 1000. Signed-off-by: Anders Kaseorg --- Vagrantfile | 1 + tools/setup/dev-vagrant-docker/Dockerfile | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Vagrantfile b/Vagrantfile index a8a38c3e77..9e5136b8a5 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -162,6 +162,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| config.vm.provider "docker" do |d, override| override.vm.box = nil d.build_dir = File.join(__dir__, "tools", "setup", "dev-vagrant-docker") + d.build_args = ["--build-arg", "VAGRANT_UID=#{Process.uid}"] d.has_ssh = true d.create_args = ["--ulimit", "nofile=1024:65536"] end diff --git a/tools/setup/dev-vagrant-docker/Dockerfile b/tools/setup/dev-vagrant-docker/Dockerfile index e8d4178f35..5bfa0019e0 100644 --- a/tools/setup/dev-vagrant-docker/Dockerfile +++ b/tools/setup/dev-vagrant-docker/Dockerfile @@ -21,6 +21,8 @@ RUN echo locales locales/default_environment_locale select en_US.UTF-8 | debconf systemd \ && rm -rf /var/lib/apt/lists/* +ARG VAGRANT_UID + RUN \ # We use https://github.com/gdraheim/docker-systemctl-replacement # to make services we install like postgres, redis, etc. normally @@ -42,7 +44,7 @@ RUN \ && mkdir /etc/systemd/system/redis-server.service.d \ && printf '[Service]\nExecStart=/usr/bin/redis-server /etc/redis/redis.conf --bind 127.0.0.1\n' > /etc/systemd/system/redis-server.service.d/override.conf \ # Set up the vagrant user and its SSH key (globally public) - && useradd -ms /bin/bash vagrant \ + && useradd -ms /bin/bash -u "$VAGRANT_UID" vagrant \ && mkdir -m 700 ~vagrant/.ssh \ && curl -so ~vagrant/.ssh/authorized_keys 'https://raw.githubusercontent.com/hashicorp/vagrant/be7876d83644aa6bdf7f951592fdc681506bcbe6/keys/vagrant.pub' \ && chown -R vagrant: ~vagrant/.ssh \