8000 Restructure our Dockerfiles and incorporate 22.04 as an option (#329) · python/psf-salt@2e91fbc · GitHub
[go: up one dir, main page]

Skip to content

Commit 2e91fbc

Browse files
authored
Restructure our Dockerfiles and incorporate 22.04 as an option (#329)
* Restructure our Dockerfiles and incorporate 22.04 as an option This restructures us from a single Dockerfile to multiple allowing us to have more than one active distribution at a time. In order to "upgrade" a given vagrant box, configure the `codename` value in the Vagrant file for that box to the matching distro codename. Salt-master is special cased as it is configured in-line. Uncomment the current bit or update the "build_dir" for its docker provider in order to change its distro. * refine to use docker provider "dockerfile" option This keeps us from duplicating common files between the docker builds
1 parent c189eb1 commit 2e91fbc

File tree

5 files changed

+73
-3
lines changed

5 files changed

+73
-3
lines changed

Vagrantfile

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,20 @@ Vagrant.configure("2") do |config|
3737
override.vm.box = nil
3838
override.ssh.insert_key = true
3939

40-
docker.build_dir = '.'
40+
docker.build_dir = 'dockerfiles'
41+
docker.dockerfile = 'Dockerfile.focal'
4142
docker.has_ssh = true
4243
docker.remains_running = true
4344
docker.privileged = true
4445
end
4546

4647
config.vm.define "salt-master" do |s_config|
48+
# Uncomment below to migrate salt-master to jammy
49+
# s_config.vm.provider "docker" do |docker, override|
50+
# docker.build_dir = "dockerfiles"
51+
# docker.dockerfile = "Dockerfile.jammy"
52+
# end
53+
4754
s_config.vm.hostname = "salt-master.vagrant.psf.io"
4855
s_config.vm.network "private_network", ip: MASTER1
4956
s_config.vm.network "private_network", ip: MASTER2
@@ -98,6 +105,13 @@ Vagrant.configure("2") do |config|
98105
s_config.vm.box = box
99106
end
100107

108+
if codename == "jammy"
109+
s_config.vm.provider "docker" do |d|
110+
d.build_dir = "dockerfiles"
111+
d.dockerfile = "Dockerfile.jammy"
112+
end
113+
end
114+
101115
s_config.vm.hostname = "#{server}.vagrant.psf.io"
102116
s_config.vm.network "private_network", ip: "#{SUBNET1}.#{num + 10}"
103117
s_config.vm.network "private_network", ip: "#{SUBNET2}.#{num + 10}"

Dockerfile renamed to dockerfiles/Dockerfile.focal

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ RUN apt-get update -y && apt-get dist-upgrade -y
1414
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
1515

1616
RUN locale-gen en_US.UTF-8
17-
COPY ./docker/etc/locale.conf /etc/locale.conf
17+
COPY ./etc/locale.conf /etc/locale.conf
1818
ENV LANG en_US.UTF-8
1919
ENV LANGUAGE en_US:en
2020
ENV LC_ALL en_US.UTF-8
2121

22-
COPY ./docker/etc/ssl/private/dhparams.pem /etc/ssl/private/dhparams.pem
22+
COPY ./etc/ssl/private/dhparams.pem /etc/ssl/private/dhparams.pem
2323

2424
# Install Vim
2525
RUN apt-get install -y vim

dockerfiles/Dockerfile.jammy

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
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"]
File renamed without changes.

0 commit comments

Comments
 (0)
0