#155 Add a docker common kickstart as a central bit for shared config.
Closed 8 years ago by pbrobinson. Opened 8 years ago by pbrobinson.
pbrobinson/fedora-kickstarts docker-refactor  into  master

file modified
+6 -54
@@ -1,66 +1,18 @@ 

- # This is a minimal Fedora install designed to serve as a Docker base image.

- #

- # To keep this image minimal it only installs English language. You need to change

- # dnf configuration in order to enable other languages.

- #

- ###  Hacking on this image ###

- # This kickstart is processed using Anaconda-in-ImageFactory (via Koji typically),

- # but you can run imagefactory locally too.

- #

- # To do so, testing local changes, first you'll need a TDL file.  I store one here:

- # https://git.fedorahosted.org/cgit/fedora-atomic.git/tree/fedora-atomic-rawhide.tdl

- #

- # Then, once you have imagefactory and imagefactory-plugins installed, run:

- #

- #   imagefactory --debug target_image --template /path/to/fedora-atomic-rawhide.tdl --parameter offline_icicle true --file-parameter install_script $(pwd)/fedora-docker-base.ks docker

- #

- 

- text # don't use cmdline -- https://github.com/rhinstaller/anaconda/issues/931

- bootloader --disabled

- timezone --isUtc --nontp Etc/UTC

- rootpw --lock --iscrypted locked

- 

- keyboard us

- network --bootproto=dhcp --device=link --activate --onboot=on

- reboot

- 

- zerombr

- clearpart --all

- part /boot/efi --fstype="vfat" --size=100

- part / --fstype ext4 --grow

+ # See docker-base-common.ks for details on how to hack on docker image kickstarts

+ # This base is a stripped back Fedora image without python3/dnf.

+ # If you need that use the standard base image.

+ 

+ %include fedora-docker-common.ks

  

  %packages --excludedocs --instLangs=en --nocore --excludeWeakdeps

- bash

- fedora-release

  microdnf

- -kernel

  -e2fsprogs

  -libss # used by e2fsprogs

  -fuse-libs

  

- 

  %end

  

  %post --erroronfail --log=/root/anaconda-post.log

- set -eux

- 

- # Set install langs macro so that new rpms that get installed will

- # only install langs that we limit it to.

- LANG="en_US"

- echo "%_install_langs $LANG" > /etc/rpm/macros.image-language-conf

- 

- # https://bugzilla.redhat.com/show_bug.cgi?id=1400682

- echo "Import RPM GPG key"

- releasever=$(rpm -q --qf '%{version}\n' fedora-release)

- basearch=$(uname -i)

- rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-$releasever-$basearch

- 

- echo "# fstab intentionally empty for containers" > /etc/fstab

- 

- # Remove machine-id on pre generated images

- rm -fv /etc/machine-id

- touch /etc/machine-id

- 

  # remove some random help txt files

  rm -fv usr/share/gnupg/help*.txt

  
@@ -90,7 +42,7 @@ 

  rm -rfv  /usr/share/zoneinfo

  

  # Final pruning

- rm -rfv var/cache/* var/log/* tmp/*

+ rm -rfv /var/cache/* /var/log/* /tmp/*

  

  %end

  

file modified
+4 -53
@@ -1,64 +1,19 @@ 

- # This is a minimal Fedora install designed to serve as a Docker base image.

- #

- # To keep this image minimal it only installs English language. You need to change

- # dnf configuration in order to enable other languages.

- #

- ###  Hacking on this image ###

- # This kickstart is processed using Anaconda-in-ImageFactory (via Koji typically),

- # but you can run imagefactory locally too.

- #

- # To do so, testing local changes, first you'll need a TDL file.  I store one here:

- # https://git.fedorahosted.org/cgit/fedora-atomic.git/tree/fedora-atomic-rawhide.tdl

- #

- # Then, once you have imagefactory and imagefactory-plugins installed, run:

- #

- #   imagefactory --debug target_image --template /path/to/fedora-atomic-rawhide.tdl --parameter offline_icicle true --file-parameter install_script $(pwd)/fedora-docker-base.ks docker

- #

+ # See docker-base-common.ks for details on how to hack on docker image kickstarts

+ # This base is a standard Fedora image with python3 and dnf

  

- text # don't use cmdline -- https://github.com/rhinstaller/anaconda/issues/931

- bootloader --disabled

- timezone --isUtc --nontp Etc/UTC

- rootpw --lock --iscrypted locked

- keyboard us

- network --bootproto=dhcp --device=link --activate --onboot=on

- reboot

- 

- zerombr

- clearpart --all

- part /boot/efi --fstype="vfat" --size=100

- part / --fstype ext4 --grow

+ %include fedora-docker-common.ks

  

  %packages --excludedocs --instLangs=en --nocore

- bash

- tar # https://bugzilla.redhat.com/show_bug.cgi?id=1409920

- fedora-release

  rootfiles

+ tar # https://bugzilla.redhat.com/show_bug.cgi?id=1409920

  vim-minimal

  dnf

  dnf-yum  # https://fedorahosted.org/fesco/ticket/1312#comment:29

  sssd-client

- #fakesystemd #TODO: waiting for review https://bugzilla.redhat.com/show_bug.cgi?id=1118740

- -kernel

- 

  

  %end

  

  %post --erroronfail --log=/root/anaconda-post.log

- set -eux

- 

- # Set install langs macro so that new rpms that get installed will

- # only install langs that we limit it to.

- LANG="en_US"

- echo "%_install_langs $LANG" > /etc/rpm/macros.image-language-conf

- 

- # https://bugzilla.redhat.com/show_bug.cgi?id=1400682

- echo "Import RPM GPG key"

- releasever=$(rpm -q --qf '%{version}\n' fedora-release)

- basearch=$(uname -i)

- rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-$releasever-$basearch

- 

- echo "# fstab intentionally empty for containers" > /etc/fstab

- 

  # remove some extraneous files

  rm -rf /var/cache/dnf/*

  rm -rf /tmp/*
@@ -73,8 +28,4 @@ 

  umount /run

  systemd-tmpfiles --create --boot

  

- # Remove machine-id on pre generated images

- rm -f /etc/machine-id

- touch /etc/machine-id

- 

  %end

@@ -0,0 +1,59 @@ 

+ # This is the common bits between Fedora Docker base image.

+ #

+ # To keep this image minimal it only installs English language. You need to change

+ # dnf configuration in order to enable other languages.

+ #

+ # ##  Hacking on this image ###

+ # This kickstart is processed using Anaconda-in-ImageFactory (via Koji typically),

+ # but you can run imagefactory locally too.

+ #

+ # To do so, testing local changes, first you'll need a TDL file.  I store one here:

+ # https://git.fedorahosted.org/cgit/fedora-atomic.git/tree/fedora-atomic-rawhide.tdl

+ #

+ # Then, once you have imagefactory and imagefactory-plugins installed, run:

+ #

+ #   ksflatten -c fedora-docker-base[-minimal].ks -o fedora-docker-base-test.ks

+ #   imagefactory --debug target_image --template /path/to/fedora-atomic-rawhide.tdl --parameter offline_icicle true --file-parameter install_script $(pwd)/fedora-docker-base-test.ks docker

+ #

+ 

+ text # don't use cmdline -- https://github.com/rhinstaller/anaconda/issues/931

+ bootloader --disabled

+ timezone --isUtc --nontp Etc/UTC

+ rootpw --lock --iscrypted locked

+ keyboard us

+ network --bootproto=dhcp --device=link --activate --onboot=on

+ reboot

+ 

+ zerombr

+ clearpart --all

+ part /boot/efi --fstype="vfat" --size=100

+ part / --fstype ext4 --grow

+ 

+ %packages --excludedocs --instLangs=en --nocore

+ fedora-release

+ bash

+ -kernel

+ 

+ %end

+ 

+ %post --erroronfail --log=/root/anaconda-post.log

+ set -eux

+ 

+ # Set install langs macro so that new rpms that get installed will

+ # only install langs that we limit it to.

+ LANG="en_US"

+ echo "%_install_langs $LANG" > /etc/rpm/macros.image-language-conf

+ 

+ # https://bugzilla.redhat.com/show_bug.cgi?id=1400682

+ echo "Import RPM GPG key"

+ releasever=$(rpm -q --qf '%{version}\n' fedora-release)

+ basearch=$(uname -i)

+ rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-$releasever-$basearch
ausil commented 8 years ago

$basearch needs to be -primary

+ 

+ echo "# fstab intentionally empty for containers" > /etc/fstab

+ 

+ # Remove machine-id on pre generated images

+ rm -f /etc/machine-id

+ touch /etc/machine-id

+ 

+ %end

There's a lot of similarities between base and base-minimal so
introduce a docker-common.ks to ensure as much as possible is shared
between the two ensure as much shared as possible.

Signed-off-by: Peter Robinson pbrobinson@fedoraproject.org

@dustymabe this is for you to review too

LGTM although I will point out that I would really like to have a comment in the kickstart file itself about the /boot/efi thing being ignored and properly handled by anaconda. Shouldn't there be a bug somewhere so we don't have to do these "hoops"?

Also for something like commit https://pagure.io/fedora-kickstarts/c/15a6627e093a4edeafaa010b54c259d0f32c0c65?branch=master, would be good to have a comment there about /boot/efi. The commit message has the comment, but I really think this should be a comment in the kickstart so people can see it.

While I'm blabbing - does anyone think it would be useful to have a generated/ subdirectory where the files are ksflattened and stored? This might seem like a pain in the ass but it would be really useful sometimes to browse git history and also see how the change affected the generated kickstart. We could effectively do this by required a post hook that will run ksflatten on the whole repo and if the checked in files don't match the generated kickstarts from the post hook then fail to merge.

Given that the partitioning has no effect as we pull the files and not the partitions, I feel we should switch to auto partitioning and be done as /boot/efi is not needed on say power and it's all in the end unnecessary. Have anaconda do what it wants and we pull what we care about out

Given that the partitioning has no effect as we pull the files and not the partitions, I feel we should switch to auto partitioning and be done as /boot/efi is not needed on say power and it's all in the end unnecessary. Have anaconda do what it wants and we pull what we care about out

Yes, +1 to adding a line like:

# just use automatic partitioning from anaconda since for docker we just
# extract the files out and create a tar archive anyway
autopart

I looked at autopart and it was broken for this usecase (and for cloud) but is now fixed upstream and I'm awaiting for pykickstart to be updated in f26/rawhide for that at which point there will be new PRs to address that issue.

Ultimately though the partitioning here is nothing to do with this particular PR as it's about moving the shared docker bits to to a shared kickstart and that is what actually needs to be be reviewed here.

sure. I gave a LGTM in the first comment and then asked for a few things.

$basearch needs to be -primary

Pull-Request has been closed by pbrobinson

8 years ago