-
-
Notifications
You must be signed in to change notification settings - Fork 47
/
Dockerfile
55 lines (45 loc) · 1.95 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
53
54
55
# https://betterprogramming.pub/managing-virtual-machines-under-vagrant-on-a-mac-m1-aebc650bc12c
# https://github.com/rofrano/vagrant-docker-provider
FROM ubuntu:noble
ENV DEBIAN_FRONTEND=noninteractive
# Install packages needed for SSH and interactive OS
RUN apt-get update -qq < /dev/null > /dev/null
RUN apt-get -y install -qq \
openssh-server \
passwd \
sudo \
man-db \
curl \
wget \
vim-tiny < /dev/null > /dev/null
COPY ./hashiqube/basetools.sh .
RUN bash ./basetools.sh; \
rm ./basetools.sh;
RUN apt-get -qq clean < /dev/null > /dev/null
RUN rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# Enable systemd (from Matthew Warman's mcwarman/vagrant-provider)
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
RUN wget -q -O /home/vagrant/.ssh/authorized_keys https://raw.githubusercontent.com/hashicorp/vagrant/master/keys/vagrant.pub
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"]