rhel-labs / instruqt

All lab.redhat.com Instruqt code is stored here.
https://www.redhat.com/en/interactive-labs/enterprise-linux
16 stars 12 forks source link

image-mode-basics: Containerfile should use Heredoc format #516

Open benblasco opened 1 month ago

benblasco commented 1 month ago

As of Podman 4.9 we support the Heredoc format for containerfiles, so maybe it's worth moving to that. This means that the containerfile just has one RUN directive and therefore I believe it would reduce the number of layers, reducing the size of the container and the time it takes to build and transport.

image

Existing Containerfile

FROM registry.redhat.io/rhel9/rhel-bootc

ADD etc /etc

RUN dnf install -y httpd
RUN systemctl enable httpd

Proposed new Containerfile


FROM registry.redhat.io/rhel9/rhel-bootc

ADD etc /etc

RUN <<EOF
    dnf install -y httpd
    systemctl enable httpd
EOF
benblasco commented 1 month ago

Hello @nzwulfin, thoughts?

More reading on Heredoc here: https://www.docker.com/blog/introduction-to-heredocs-in-dockerfiles/

benblasco commented 1 month ago

Note: Later when I added vim to the Containerfile the podman build command seemed not to pick it up. Will investigate further to see if it is a product issue.

nzwulfin commented 1 month ago

Generally I'm on board with this, very happy to see the support land. I did some local testing yesterday on this, it seems to have a few quirks I haven't worked out consistently. I'm going to keep testing and see if I can get consistent successes with a heredoc that works. Until then, I'll watch this.

benblasco commented 1 month ago

Looks like there's a bug based on my testing, so we will have to park it for now. I created a JIRA issue we can follow: https://issues.redhat.com/browse/RHEL-50145