forked from servian/hashiqube
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Dockerfile
52 lines (44 loc) · 1.87 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# https://betterprogramming.pub/managing-virtual-machines-under-vagrant-on-a-mac-m1-aebc650bc12c
# https://github.com/rofrano/vagrant-docker-provider
FROM ubuntu:focal
ENV DEBIAN_FRONTEND noninteractive
# Install packages needed for SSH and interactive OS
RUN apt-get update && \
yes | unminimize && \
apt-get -y install \
openssh-server \
passwd \
sudo \
man-db \
curl \
wget \
vim-tiny && \
apt-get -qq clean && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# Enable systemd (from Matthew Warman's mcwarman/vagrant-provider)
# Ref: https://github.com/servian/hashiqube/issues/12
RUN find /lib/systemd/system/sysinit.target.wants -mindepth 1 -not -name "systemd-tmpfiles-setup.service" -delete; \
find /lib/systemd/system/multi-user.target.wants -mindepth 1 -not -name "systemd-user-sessions.service" -delete; \
rm -f /etc/systemd/system/*.wants/*; \
rm -f /lib/systemd/system/local-fs.target.wants/*; \
rm -f /lib/systemd/system/sockets.target.wants/*udev*; \
rm -f /lib/systemd/system/sockets.target.wants/*initctl*; \
rm -f /lib/systemd/system/basic.target.wants/*; \
rm -f /lib/systemd/system/anaconda.target.wants/*;
# Enable ssh for vagrant
RUN systemctl enable ssh.service;
EXPOSE 22
# Create the vagrant user
RUN useradd -m -G sudo -s /bin/bash vagrant && \
echo "vagrant:vagrant" | chpasswd && \
echo 'vagrant ALL=(ALL) NOPASSWD: ALL' > /etc/sudoers.d/vagrant && \
chmod 440 /etc/sudoers.d/vagrant
# Establish ssh keys for vagrant
RUN mkdir -p /home/vagrant/.ssh; \
chmod 700 /home/vagrant/.ssh
ADD https://raw.githubusercontent.com/hashicorp/vagrant/master/keys/vagrant.pub /home/vagrant/.ssh/authorized_keys
RUN chmod 600 /home/vagrant/.ssh/authorized_keys; \
chown -R vagrant:vagrant /home/vagrant/.ssh
# Run the init daemon
VOLUME [ "/sys/fs/cgroup" ]
CMD ["/usr/sbin/init"]