dev-vagrant-docker: Copy the host user’s uid for the vagrant user.

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 <anders@zulipchat.com>
This commit is contained in:
Anders Kaseorg 2019-05-27 19:21:51 -07:00 committed by Tim Abbott
parent a98447b312
commit f21d3be5fb
2 changed files with 4 additions and 1 deletions

1
Vagrantfile vendored
View File

@ -162,6 +162,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.provider "docker" do |d, override| config.vm.provider "docker" do |d, override|
override.vm.box = nil override.vm.box = nil
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.has_ssh = true d.has_ssh = true
d.create_args = ["--ulimit", "nofile=1024:65536"] d.create_args = ["--ulimit", "nofile=1024:65536"]
end end

View File

@ -21,6 +21,8 @@ RUN echo locales locales/default_environment_locale select en_US.UTF-8 | debconf
systemd \ systemd \
&& rm -rf /var/lib/apt/lists/* && rm -rf /var/lib/apt/lists/*
ARG VAGRANT_UID
RUN \ RUN \
# We use https://github.com/gdraheim/docker-systemctl-replacement # We use https://github.com/gdraheim/docker-systemctl-replacement
# to make services we install like postgres, redis, etc. normally # to make services we install like postgres, redis, etc. normally
@ -42,7 +44,7 @@ RUN \
&& mkdir /etc/systemd/system/redis-server.service.d \ && 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 \ && 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) # 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 \ && mkdir -m 700 ~vagrant/.ssh \
&& curl -so ~vagrant/.ssh/authorized_keys 'https://raw.githubusercontent.com/hashicorp/vagrant/be7876d83644aa6bdf7f951592fdc681506bcbe6/keys/vagrant.pub' \ && curl -so ~vagrant/.ssh/authorized_keys 'https://raw.githubusercontent.com/hashicorp/vagrant/be7876d83644aa6bdf7f951592fdc681506bcbe6/keys/vagrant.pub' \
&& chown -R vagrant: ~vagrant/.ssh \ && chown -R vagrant: ~vagrant/.ssh \