Podman Fun Fact of the Day – Git Builds

As folks who know me know, I love fun facts.  At our scrum meetings, I usually have one that I share after we complete our standup discussion.  Recently, I found, or at least rediscovered, a fun fact about `podman build` that I thought I’d share in a quick blog post.

A few weeks ago, an issue was reported against Podman’s build man page.  A community member had tried using the example on the page showing how to build from a Git repository, but it failed.  The issue was the repository was a private one and had been removed by the owner.  Dan Walsh asked me to set up a little Git repository for our PodmanHello Ascii art and to change the sample.

I was shocked that this was even possible.  So, after playing around a bit, I created this GitHub Repository for PodmanHello, which has two files of significance for the building of the PodmanHello container image.  The first is the Containerfile, which has all of the build instructions for making the image.  A Containerfile is equivalent to a Dockerfile and you could have a Dockerfile instead if you prefer.  The second is the podman_hello_world.c, which is called by the Containerfile at build time to make the Ascii art.

That is all that was necessary to have in the repository to build this image.  If you open up the repository, you’ll see other files, but they are all administrative types of files that are not required for the building of the PodmanHello container image.

How do you build from the repository you ask?  It’s quite simple: `$ podman build -t podmanhello  https://github.com/containers/PodmanHello.git`.  That’s it.  The image is built directly from GitHub quickly and quite easily.  

$ podman build -t podmanhello  https://github.com/containers/PodmanHello.git
[1/2] STEP 1/4: FROM docker.io/alpine AS builder
Trying to pull docker.io/library/alpine:latest...
Getting image source signatures
Copying blob 7264a8db6415 done  
Copying config 7e01a0d0a1 done  
Writing manifest to image destination
[1/2] STEP 2/4: RUN apk add gcc libc-dev
fetch https://dl-cdn.alpinelinux.org/alpine/v3.18/main/x86_64/APKINDEX.tar.gz
fetch https://dl-cdn.alpinelinux.org/alpine/v3.18/community/x86_64/APKINDEX.tar.gz
(1/13) Installing libgcc (12.2.1_git20220924-r10)
(2/13) Installing libstdc++ (12.2.1_git20220924-r10)
(3/13) Installing zstd-libs (1.5.5-r4)
(4/13) Installing binutils (2.40-r7)
(5/13) Installing libgomp (12.2.1_git20220924-r10)
(6/13) Installing libatomic (12.2.1_git20220924-r10)
(7/13) Installing gmp (6.2.1-r3)
(8/13) Installing isl26 (0.26-r1)
(9/13) Installing mpfr4 (4.2.0_p12-r0)
(10/13) Installing mpc1 (1.3.1-r1)
(11/13) Installing gcc (12.2.1_git20220924-r10)
(12/13) Installing musl-dev (1.2.4-r1)
(13/13) Installing libc-dev (0.7.2-r5)
Executing busybox-1.36.1-r2.trigger
OK: 150 MiB in 28 packages
--> 526a984ff6d0
[1/2] STEP 3/4: ADD podman_hello_world.c .
--> dd6453348fcb
[1/2] STEP 4/4: RUN gcc -O2 -static -o podman_hello_world podman_hello_world.c
--> a36b2c970179
[2/2] STEP 1/6: FROM scratch
[2/2] STEP 2/6: LABEL maintainer="Podman Maintainers"
--> 4a92878dd636
[2/2] STEP 3/6: LABEL artist="Máirín Ní Ḋuḃṫaiġ, Twitter:@mairin"
--> e8b0807f14fc
[2/2] STEP 4/6: USER 1000
--> ea421942ccc1
[2/2] STEP 5/6: COPY --from=builder podman_hello_world /usr/local/bin/podman_hello_world
--> 5399568f5d01
[2/2] STEP 6/6: CMD ["/usr/local/bin/podman_hello_world"]
[2/2] COMMIT podmanhello
--> 0f598c9c6b0b
Successfully tagged localhost/podmanhello:latest
0f598c9c6b0b8c8b324a1b12490b171635d33d676b14533d350c08a348502a22

Then, to run the image, another simple command: `$ podman run podmanhello`

$ podman run podmanhello
!... Hello Podman World ...!

         .--"--.      	 
       / -     - \    	 
  	  / (O)   (O) \   	 
   ~~~| -=(,Y,)=- |    	 
	.---. /`  \   |~~ 	 
 ~/  o  o \~~~~.----. ~~   
  | =(X)= |~  / (O (O) \   
   ~~~~~~~  ~| =(Y_)=-  |   
  ~~~~	  ~~~|   U  	|~~

Project:   https://github.com/containers/podman
Website:   https://podman.io
Documents: https://docs.podman.io
Twitter:   @Podman_io

So obviously a pretty simple example here, but if you had a Containerfile that you wanted multiple people to use and didn’t want to sling it along everywhere, this would be a good way to accomplish that.  So there’s your fun Podman fact of the day, and I hope you find it useful.  Just to wrap up, here’s another fun fact: Elephants can’t jump!

Leave a Reply

Subscribe

Sign up with your email address to receive updates by email from this website.


Categories


Search