Dockerfile 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. FROM i386/alpine:3.18.6
  2. ENV KERNEL=lts
  3. ENV HOSTNAME=localhost
  4. ENV ROOT_PASSWORD='root'
  5. ENV ADDPKGS=''
  6. RUN apk add openrc \
  7. alpine-base \
  8. agetty \
  9. alpine-conf \
  10. $ADDPKGS
  11. # Install mkinitfs from edge (todo: remove this when 3.19+ has worked properly with 9pfs)
  12. RUN apk add mkinitfs --no-cache --allow-untrusted --repository https://dl-cdn.alpinelinux.org/alpine/edge/main/
  13. RUN if [ "$KERNEL" == "lts" ]; then \
  14. apk add linux-lts \
  15. linux-firmware-none \
  16. linux-firmware-sb16; \
  17. else \
  18. apk add linux-$KERNEL; \
  19. fi
  20. RUN sed -i 's/getty 38400 tty1/agetty --autologin root tty1 linux/' /etc/inittab && \
  21. echo "root:$ROOT_PASSWORD" | chpasswd
  22. RUN setup-hostname $HOSTNAME
  23. # Adding networking.sh script (works only on lts kernel yet)
  24. RUN if [ "$KERNEL" == "lts" ]; then \
  25. echo -e "rmmod ne2k-pci && modprobe ne2k-pci\nhwclock -s\nsetup-interfaces -a -r" > /root/networking.sh && \
  26. chmod +x /root/networking.sh; \
  27. fi
  28. # https://wiki.alpinelinux.org/wiki/Alpine_Linux_in_a_chroot#Preparing_init_services
  29. RUN for i in devfs dmesg mdev hwdrivers; do rc-update add $i sysinit; done
  30. RUN for i in hwclock modules sysctl hostname syslog bootmisc; do rc-update add $i boot; done
  31. RUN rc-update add killprocs shutdown
  32. # Generate initramfs with 9p modules
  33. RUN mkinitfs -F "ata base ide scsi virtio ext4 9p" $(cat /usr/share/kernel/$KERNEL/kernel.release)