2019-05-20 06:07:25 +02:00
|
|
|
|
FROM ubuntu:18.04
|
|
|
|
|
|
2019-05-29 03:58:11 +02:00
|
|
|
|
ARG UBUNTU_MIRROR
|
|
|
|
|
|
2019-05-20 06:07:25 +02:00
|
|
|
|
# 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 \
|
2019-05-29 03:58:11 +02:00
|
|
|
|
&& { [ ! "$UBUNTU_MIRROR" ] || sed -i "s|http://\(\w*\.\)*archive\.ubuntu\.com/ubuntu/\? |$UBUNTU_MIRROR |" /etc/apt/sources.list; } \
|
2019-05-25 02:31:20 +02:00
|
|
|
|
# This restores man pages and other documentation that have been
|
|
|
|
|
# stripped from the default Ubuntu cloud image and installs
|
|
|
|
|
# ubuntu-minimal and ubuntu-standard.
|
|
|
|
|
#
|
|
|
|
|
# This makes sense to do because we're using this image as a
|
|
|
|
|
# development environment, not a minimal production system.
|
|
|
|
|
&& printf 'y\n\n' | unminimize \
|
2019-05-20 06:07:25 +02:00
|
|
|
|
&& apt-get install --no-install-recommends -y \
|
|
|
|
|
ca-certificates \
|
|
|
|
|
curl \
|
|
|
|
|
locales \
|
|
|
|
|
lsb-release \
|
|
|
|
|
openssh-server \
|
|
|
|
|
python3 \
|
|
|
|
|
sudo \
|
|
|
|
|
systemd \
|
|
|
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
|
|
2019-05-28 04:21:51 +02:00
|
|
|
|
ARG VAGRANT_UID
|
|
|
|
|
|
2019-05-20 06:07:25 +02:00
|
|
|
|
RUN \
|
|
|
|
|
# We use https://github.com/gdraheim/docker-systemctl-replacement
|
|
|
|
|
# to make services we install like postgres, redis, etc. normally
|
|
|
|
|
# managed by systemd start within Docker, which breaks normal
|
|
|
|
|
# operation of systemd.
|
|
|
|
|
dpkg-divert --add --rename /bin/systemctl \
|
2019-06-25 04:40:08 +02:00
|
|
|
|
&& curl -so /bin/systemctl 'https://raw.githubusercontent.com/gdraheim/docker-systemctl-replacement/73b5aff2ba6abfd254d236f1df22ff4971d44660/files/docker/systemctl3.py' \
|
2019-05-20 06:07:25 +02:00
|
|
|
|
&& chmod +x /bin/systemctl \
|
|
|
|
|
&& ln -nsf /bin/true /usr/sbin/policy-rc.d \
|
|
|
|
|
&& mkdir -p /run/sshd \
|
|
|
|
|
# docker-systemctl-replacement doesn’t work with template units yet:
|
|
|
|
|
# https://github.com/gdraheim/docker-systemctl-replacement/issues/62
|
2019-06-25 04:40:08 +02:00
|
|
|
|
&& ln -ns /lib/systemd/system/postgresql@.service /etc/systemd/system/multi-user.target.wants/postgresql@10-main.service \
|
2019-05-20 06:07:25 +02:00
|
|
|
|
# redis fails to start with the default configuration if IPv6 is disabled:
|
|
|
|
|
# https://github.com/antirez/redis/pull/5598
|
|
|
|
|
&& dpkg-divert --add --rename /etc/default/redis-server \
|
|
|
|
|
&& printf 'ULIMIT=65536\nDAEMON_ARGS="/etc/redis/redis.conf --bind 127.0.0.1"\n' > /etc/default/redis-server \
|
|
|
|
|
&& mkdir /etc/systemd/system/redis-server.service.d \
|
2019-06-01 10:06:13 +02:00
|
|
|
|
&& printf '[Service]\nExecStart=\nExecStart=/usr/bin/redis-server /etc/redis/redis.conf --bind 127.0.0.1\n' > /etc/systemd/system/redis-server.service.d/override.conf \
|
2019-05-20 06:07:25 +02:00
|
|
|
|
# Set up the vagrant user and its SSH key (globally public)
|
2019-05-28 04:21:51 +02:00
|
|
|
|
&& useradd -ms /bin/bash -u "$VAGRANT_UID" vagrant \
|
2019-05-20 06:07:25 +02:00
|
|
|
|
&& 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 \
|
|
|
|
|
&& echo 'vagrant ALL=(ALL) NOPASSWD:ALL' > /etc/sudoers.d/vagrant
|
|
|
|
|
|
|
|
|
|
CMD ["/bin/systemctl"]
|
|
|
|
|
|
|
|
|
|
EXPOSE 22
|
|
|
|
|
EXPOSE 9991
|