-
Notifications
You must be signed in to change notification settings - Fork 39
/
Dockerfile.dev.os
126 lines (106 loc) · 3.69 KB
/
Dockerfile.dev.os
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
ARG ELEMENTAL_TOOLKIT
ARG ELEMENTAL_REGISTER
FROM ${ELEMENTAL_REGISTER} as register
FROM ${ELEMENTAL_TOOLKIT} as toolkit
# OS base image of our choice
FROM registry.opensuse.org/opensuse/tumbleweed:latest as OS
ARG RANCHER_SYSTEM_AGENT_VERSION
# install kernel, systemd, dracut, grub2 and other required tools
RUN ARCH=$(uname -m); \
[[ "${ARCH}" == "aarch64" ]] && ARCH="arm64"; \
zypper --non-interactive install --no-recommends -- \
kernel-default \
device-mapper \
dracut \
grub2 \
grub2-${ARCH}-efi \
shim \
haveged \
systemd \
NetworkManager \
openssh-server \
openssh-clients \
timezone \
parted \
e2fsprogs \
dosfstools \
mtools \
xorriso \
findutils \
gptfdisk \
rsync \
squashfs \
lvm2 \
tar \
gzip \
vim \
which \
less \
sudo \
curl \
iproute2 \
podman \
sed \
btrfsprogs \
btrfsmaintenance \
snapper \
glibc-gconv-modules-extra \
wget \
unzip
# elemental-register dependencies
RUN ARCH=$(uname -m); \
[[ "${ARCH}" == "aarch64" ]] && ARCH="arm64"; \
zypper --non-interactive install --no-recommends -- \
dmidecode \
libopenssl1_1
# Install nmstatectl
RUN wget https://github.com/nmstate/nmstate/releases/latest/download/nmstatectl-linux-x64.zip && \
unzip nmstatectl-linux-x64.zip && \
chmod +x nmstatectl && \
mv ./nmstatectl /usr/sbin/nmstatectl && \
rm nmstatectl-linux-x64.zip
# Install nm-configurator
RUN curl -o /usr/sbin/nmc -L https://github.com/suse-edge/nm-configurator/releases/latest/download/nmc-linux-$(uname -m)
RUN chmod +x /usr/sbin/nmc
# SELinux policy and tools
RUN ARCH=$(uname -m); \
[[ "${ARCH}" == "aarch64" ]] && ARCH="arm64"; \
zypper --non-interactive install --no-recommends -- \
patterns-microos-selinux \
k3s-selinux \
audit
# Add system files
COPY framework/files/ /
# Enable SELinux (The security=selinux arg is default on Micro, not on Tumbleweed)
RUN sed -i "s/selinux=1/security=selinux selinux=1/g" /etc/elemental/bootargs.cfg
# Enforce SELinux
# RUN sed -i "s/enforcing=0/enforcing=1/g" /etc/elemental/bootargs.cfg
# Add elemental-register
COPY --from=register /usr/sbin/elemental-register /usr/sbin/elemental-register
COPY --from=register /usr/sbin/elemental-support /usr/sbin/elemental-support
# Add the elemental cli
COPY --from=toolkit /usr/bin/elemental /usr/bin/elemental
# Add the elemental-system-agent
ADD --chmod=0755 https://github.com/rancher/system-agent/releases/download/${RANCHER_SYSTEM_AGENT_VERSION}/rancher-system-agent-amd64 /usr/sbin/elemental-system-agent
# Enable essential services
RUN systemctl enable NetworkManager.service sshd
# This is for testing purposes, do not do this in production.
RUN echo "PermitRootLogin yes" > /etc/ssh/sshd_config.d/rootlogin.conf
# Make sure trusted certificates are properly generated
RUN /usr/sbin/update-ca-certificates
# Ensure /tmp is mounted as tmpfs by default
RUN if [ -e /usr/share/systemd/tmp.mount ]; then \
cp /usr/share/systemd/tmp.mount /etc/systemd/system; \
fi
# Save some space
RUN zypper clean --all && \
rm -rf /var/log/update* && \
>/var/log/lastlog && \
rm -rf /boot/vmlinux*
# Update os-release file with some metadata
RUN echo TIMESTAMP="`date +'%Y%m%d%H%M%S'`" >> /etc/os-release && \
echo GRUB_ENTRY_NAME=\"Elemental Dev\" >> /etc/os-release
# Rebuild initrd to setup dracut with the boot configurations
RUN elemental init --force elemental-rootfs,elemental-sysroot,grub-config,dracut-config,cloud-config-essentials,elemental-setup,boot-assessment
# Good for validation after the build
CMD /bin/bash