|
| 1 | +# Docker image to use with Vagrant |
| 2 | +# Aims to be as similar to normal Vagrant usage as possible |
| 3 | +# Adds SSH daemon, Systemd |
| 4 | +# Adapted from https://github.com/BashtonLtd/docker-vagrant-images/blob/master/ubuntu1404/Dockerfile |
| 5 | + |
| 6 | +FROM ubuntu:22.04 |
| 7 | +ENV container docker |
| 8 | + |
| 9 | +RUN ln -snf /usr/share/zoneinfo/UTC /etc/localtime && echo $TZ > /etc/timezone |
| 10 | + |
| 11 | +RUN apt-get update -y && apt-get dist-upgrade -y |
| 12 | + |
| 13 | +# Install system dependencies, you may not need all of these |
| 14 | +RUN apt-get install -y --no-install-recommends ssh sudo libffi-dev systemd openssh-client wget gnupg-utils gnupg apt-utils ca-certificates dbus locales cron dialog rsyslog iproute2 logrotate |
| 15 | + |
| 16 | +RUN locale-gen en_US.UTF-8 |
| 17 | +COPY ./etc/locale.conf /etc/locale.conf |
| 18 | +ENV LANG en_US.UTF-8 |
| 19 | +ENV LANGUAGE en_US:en |
| 20 | +ENV LC_ALL en_US.UTF-8 |
| 21 | + |
| 22 | +COPY ./etc/ssl/private/dhparams.pem /etc/ssl/private/dhparams.pem |
| 23 | + |
| 24 | +# Install Vim |
| 25 | +RUN apt-get install -y vim |
| 26 | + |
| 27 | +# Needed to run systemd |
| 28 | +# VOLUME [ "/sys/fs/cgroup" ] |
| 29 | +# Doesn't appear to be necessary? See comments |
| 30 | + |
| 31 | +# Add vagrant user and key for SSH |
| 32 | +RUN useradd --create-home -s /bin/bash vagrant |
| 33 | +RUN echo -n 'vagrant:vagrant' | chpasswd |
| 34 | +RUN echo 'vagrant ALL = NOPASSWD: ALL' > /etc/sudoers.d/vagrant |
| 35 | +RUN chmod 440 /etc/sudoers.d/vagrant |
| 36 | +RUN mkdir -p /home/vagrant/.ssh |
| 37 | +RUN chmod 700 /home/vagrant/.ssh |
| 38 | +RUN echo "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzIw+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoPkcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NOTd0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcWyLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQ==" > /home/vagrant/.ssh/authorized_keys |
| 39 | +RUN chmod 600 /home/vagrant/.ssh/authorized_keys |
| 40 | +RUN chown -R vagrant:vagrant /home/vagrant/.ssh |
| 41 | +RUN sed -i -e 's/Defaults.*requiretty/#&/' /etc/sudoers |
| 42 | +RUN sed -i -e 's/\(UsePAM \)yes/\1 no/' /etc/ssh/sshd_config |
| 43 | + |
| 44 | +# Start SSH |
| 45 | +RUN mkdir /var/run/sshd |
| 46 | +EXPOSE 22 |
| 47 | +RUN /usr/sbin/sshd |
| 48 | + |
| 49 | +# Setup Salt Common |
| 50 | + |
| 51 | +RUN wget --quiet -O /usr/share/keyrings/salt-archive-keyring.gpg https://repo.saltproject.io/py3/ubuntu/20.04/$(dpkg --print-architecture)/3004/salt-archive-keyring.gpg |
| 52 | +RUN echo "deb [signed-by=/usr/share/keyrings/salt-archive-keyring.gpg arch=$(dpkg --print-architecture)] https://repo.saltproject.io/py3/ubuntu/20.04/$(dpkg --print-architecture)/3004 focal main" > /etc/apt/sources.list.d/salt.list |
| 53 | +RUN apt-get update -y && apt-get install -y --no-install-recommends salt-minion |
| 54 | + |
| 55 | +# Start Systemd (systemctl) |
| 56 | +CMD ["/lib/systemd/systemd"] |
0 commit comments