aws / ec2-image-builder-roadmap

Public Roadmap for EC2 Image Builder.
Other
34 stars 7 forks source link

[Container image recipes] Support for base image that don't include yum, apt-get nor zypper #90

Open psantus opened 1 year ago

psantus commented 1 year ago

Community Note

Tell us about your request Manage package managers apart from yum, apt-get and zypper

Tell us about the problem you're trying to solve. What are you trying to do, and why is it hard? I have a docker image (for the sake of the example, it's keyfactor/ejbca-ce:latest).

Trying to apply any component fails, because container_bootstrap.sh provided by aws supports only a limited list of package managers

!/bin/bash -xe

function package_exists() {
    $(type "$1" > /dev/null 2>&1 )
    return $?
}

function install_package() {
    if package_exists yum ; then
        yum install -y -q $1
    elif package_exists apt-get ; then
        apt-get update -y -qq
        apt-get install -y -qq $1
    elif package_exists zypper ; then
        zypper -q install -y $1
    else
        echo "Unable to install package '$1'"
        exit -1
    fi
}

if ! package_exists which ; then
    install_package which
fi

if ! package_exists sudo ; then
    install_package sudo
fi

if ! package_exists curl ; then
    install_package curl
fi

My docker image is based on AlmaLinux mnimal installation, that only embed microdnf as its package manager.

Are you currently working around this issue? Installing YUM as a first step in my Dockerfile.

    FROM {{{ imagebuilder:parentImage }}}
    {{{ imagebuilder:environments }}}
    USER 0
    RUN ["/bin/bash", "-c", "microdnf install yum"]
    {{{ imagebuilder:components }}}
    USER 10001
    EOF

Additional context

Attachments