59 | | ==== Baseline Image |
| 59 | ==== Bare |
| 60 | |
| 61 | This is a customized image, build off of Ubuntu Server 18.04 |
| 62 | |
| 63 | [[CollapsibleStart]] |
| 64 | {{{#!dockerfile |
| 65 | FROM scratch as bare |
| 66 | ADD src/18.04-server-cloudimg-amd64-root.tar.xz / |
| 67 | #docker optimizations for apt |
| 68 | RUN set -xe \ |
| 69 | \ |
| 70 | # https://github.com/docker/docker/blob/9a9fc01af8fb5d98b8eec0740716226fadb3735c/contrib/mkimage/debootstrap#L85-L105 |
| 71 | && echo 'DPkg::Post-Invoke { "rm -f /var/cache/apt/archives/*.deb /var/cache/apt/archives/partial/*.deb /var/cache/apt/*.bin || true"; };' > /etc/apt/apt.conf.d/docker-clean \ |
| 72 | && echo 'APT::Update::Post-Invoke { "rm -f /var/cache/apt/archives/*.deb /var/cache/apt/archives/partial/*.deb /var/cache/apt/*.bin || true"; };' >> /etc/apt/apt.conf.d/docker-clean \ |
| 73 | && echo 'Dir::Cache::pkgcache ""; Dir::Cache::srcpkgcache "";' >> /etc/apt/apt.conf.d/docker-clean \ |
| 74 | \ |
| 75 | # https://github.com/docker/docker/blob/9a9fc01af8fb5d98b8eec0740716226fadb3735c/contrib/mkimage/debootstrap#L109-L115 |
| 76 | && echo 'Acquire::Languages "none";' > /etc/apt/apt.conf.d/docker-no-languages \ |
| 77 | \ |
| 78 | # https://github.com/docker/docker/blob/9a9fc01af8fb5d98b8eec0740716226fadb3735c/contrib/mkimage/debootstrap#L118-L130 |
| 79 | && echo 'Acquire::GzipIndexes "true"; Acquire::CompressionTypes::Order:: "gz";' > /etc/apt/apt.conf.d/docker-gzip-indexes \ |
| 80 | \ |
| 81 | # https://github.com/docker/docker/blob/9a9fc01af8fb5d98b8eec0740716226fadb3735c/contrib/mkimage/debootstrap#L134-L151 |
| 82 | && echo 'Apt::AutoRemove::SuggestsImportant "false";' > /etc/apt/apt.conf.d/docker-autoremove-suggests |
| 83 | |
| 84 | ARG KERNEL_TYPE="generic" |
| 85 | ARG COMMON_PKGS="vim emacs git dnsutils" |
| 86 | |
| 87 | ENV DEBIAN_FRONTEND=noninteractive \ |
| 88 | TERM=linux |
| 89 | #set up apt sources |
| 90 | COPY files/apt/ /etc/apt/ |
| 91 | RUN wget -qO - https://www.mellanox.com/downloads/ofed/RPM-GPG-KEY-Mellanox | apt-key add - |
| 92 | #install bootloader and kernel, common packages |
| 93 | RUN apt update && apt install --no-install-recommends -fy \ |
| 94 | linux-image-${KERNEL_TYPE} \ |
| 95 | linux-headers-${KERNEL_TYPE} \ |
| 96 | grub-pc \ |
| 97 | software-properties-common \ |
| 98 | build-essential \ |
| 99 | ssh \ |
| 100 | ${COMMON_PKGS} |
| 101 | |
| 102 | #disable auto updates |
| 103 | RUN apt -fy purge unattended-upgrades |
| 104 | |
| 105 | #create users with "blank" passwords. WARNING, very insecure!!! |
| 106 | RUN echo "root:root" | chpasswd && \ |
| 107 | sed -i 's/^\(root:\)[^:]*\(:.*\)$/\1\2/' /etc/shadow && \ |
| 108 | cp -r /etc/skel/. /root/ |
| 109 | |
| 110 | COPY files/fstab /etc/fstab |
| 111 | COPY files/grub /etc/default/grub |
| 112 | RUN rm /etc/default/grub.d/* |
| 113 | COPY files/00-netplan.yaml /etc/netplan/00-netplan.yaml |
| 114 | COPY files/ssh/server/* /etc/ssh/ |
| 115 | COPY files/ssh/client/* /root/.ssh/ |
| 116 | |
| 117 | #fix ssh key permissions |
| 118 | RUN chmod 400 /etc/ssh/ssh_host_*_key && chmod 444 /etc/ssh/ssh_host_*_key.pub |
| 119 | |
| 120 | #16.04 and prior use ifupdown |
| 121 | #COPY dhcp/hostname-ifupdown /etc/dhcp/dhclient-exit-hooks.d/hostname |
| 122 | #18.04 uses netplan and networkd-dispatcher |
| 123 | COPY files/dhcp/hostname-networkd /etc/networkd-dispatcher/routable.d/20-hostname.sh |
| 124 | RUN chmod +x /etc/networkd-dispatcher/routable.d/20-hostname.sh |
| 125 | |
| 126 | #clean up build |
| 127 | RUN rm -f /etc/apt/apt.conf.d/01proxy && \ |
| 128 | rm -rf /var/lib/apt/lists/* && \ |
| 129 | apt clean && \ |
| 130 | apt autoclean |
| 131 | |
| 132 | #commands are rune when container is started |
| 133 | #workaround for "locked" files in docker-build |
| 134 | #this may delay image saving |
| 135 | COPY files/late_commands.sh /root/late_commands.sh |
| 136 | ENTRYPOINT ["/root/late_commands.sh"] |
| 137 | CMD ["/bin/bash"] |
| 138 | }}} |
| 139 | |
| 140 | |
| 141 | [[CollapsibleEnd]] |
| 142 | |
| 143 | ==== Baseline |