Skip to content

Comments

Better Dockerfile#399

Merged
auerswal merged 7 commits intoschweikert:developfrom
hoodadt:develop
Aug 2, 2025
Merged

Better Dockerfile#399
auerswal merged 7 commits intoschweikert:developfrom
hoodadt:develop

Conversation

@hoodadt
Copy link
Contributor

@hoodadt hoodadt commented Jul 21, 2025

Changed Base image to alpine
Added Multi Staging
this causes image size to reduce from 541MB To 8.49MB since base image is much more minimal and extra packages are not copied from previous stage.
Added Labeling

# docker build -t fping .


[+] Building 15.0s (11/11) FINISHED                                                                                                                                            docker:default
 => [internal] load build definition from Dockerfile                                                                                                                                     0.0s
 => => transferring dockerfile: 514B                                                                                                                                                     0.0s
 => [internal] load metadata for docker.io/library/alpine:3.22.1                                                                                                                         0.4s
 => [internal] load .dockerignore                                                                                                                                                        0.0s
 => => transferring context: 343B                                                                                                                                                        0.0s
 => [internal] load build context                                                                                                                                                        0.1s
 => => transferring context: 1.08MB                                                                                                                                                      0.1s
 => CACHED [builder 1/5] FROM docker.io/library/alpine:3.22.1@sha256:4bcff63911fcb4448bd4fdacec207030997caf25e9bea4045fa6c8c44de311d1                                                    0.0s
 => [builder 2/5] RUN apk add --no-cache   build-base   automake   autoconf   m4                                                                                                         4.5s
 => [builder 3/5] COPY ./ /app                                                                                                                                                           0.1s 
 => [builder 4/5] WORKDIR /app                                                                                                                                                           0.0s 
 => [builder 5/5] RUN autoreconf --install && ./configure && make                                                                                                                        9.9s 
 => CACHED [stage-1 2/2] COPY --from=builder /app/src/fping /usr/local/bin/fping                                                                                                         0.0s 
 => exporting to image                                                                                                                                                                   0.0s 
 => => exporting layers                                                                                                                                                                  0.0s 
 => => writing image sha256:b5480dfcc4b5c61516a8732ea1cc4b8f4bf83f922adf7e317b55f9ef21af6d01                                                                                             0.0s
 => => naming to docker.io/library/fping  
# docker run --rm fping:latest 8.8.8.8

8.8.8.8 is alive

@gsnw-sebast
Copy link
Collaborator

Thanks for the change. I've looked at it and tested it with podman.
Can you make a corresponding change in CHANGELOG.md for the pull request?

Podman build command

podman build -t fping -f contrib/Dockerfile .

Test: imagesize

REPOSITORY                TAG         IMAGE ID      CREATED         SIZE
localhost/fping           latest      e0459c98ddff  21 seconds ago  7.52 MB
<none>                    <none>      5a576a620cb1  49 seconds ago  308 MB
docker.io/library/alpine  3.22.1      f30a2997d9e5  8 days ago      7.36 MB

Test: run

podman run --rm fping:latest 127.0.0.1
127.0.0.1 is alive

podman run --rm fping:latest -c 2 127.0.0.1
127.0.0.1 : [0], 64 bytes, 0.085 ms (0.085 avg, 0% loss)
127.0.0.1 : [1], 64 bytes, 0.061 ms (0.073 avg, 0% loss)

127.0.0.1 : xmt/rcv/%loss = 2/2/0%, min/avg/max = 0.061/0.073/0.085

@hoodadt
Copy link
Contributor Author

hoodadt commented Jul 24, 2025

Done - Let me know if anything else is needed.

@coveralls
Copy link

coveralls commented Jul 24, 2025

Coverage Status

coverage: 86.427%. remained the same
when pulling 83d718a on hoodadt:develop
into 05b8f45 on schweikert:develop.

@hoodadt
Copy link
Contributor Author

hoodadt commented Jul 26, 2025

i am sorry what's this coveralls - macos errors ? am i suppose to change any thing ?

@auerswal
Copy link
Collaborator

i am sorry what's this coveralls - macos errors ? am i suppose to change any thing ?

No, you do not need to change anything because of this Coveralls result.

Copy link
Collaborator

@auerswal auerswal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this pull request!

I'd think that both using a smaller base image (i.e., Alpine), and using a multi-stage build process are useful changes.

(I do not use containers, so I am a bit reluctant to "approve" the pull request, but I am not opposed.)

@hoodadt
Copy link
Contributor Author

hoodadt commented Jul 27, 2025

i made a new commit covering both

docker build -t fping -f contrib/Dockerfile .

[+] Building 10.0s (13/13) FINISHED                                                                                                               docker:default
 => [internal] load build definition from Dockerfile                                                                                                        0.0s
 => => transferring dockerfile: 843B                                                                                                                        0.0s
 => [internal] load metadata for docker.io/library/alpine:latest                                                                                            0.0s
 => [internal] load .dockerignore                                                                                                                           0.0s
 => => transferring context: 343B                                                                                                                           0.0s
 => [internal] load build context                                                                                                                           0.0s
 => => transferring context: 13.30kB                                                                                                                        0.0s
 => [builder 1/5] FROM docker.io/library/alpine:latest                                                                                                      0.0s
 => CACHED [builder 2/5] RUN apk add --no-cache   build-base   automake   autoconf   m4                                                                     0.0s
 => [builder 3/5] COPY ./ /app                                                                                                                              0.1s
 => [builder 4/5] WORKDIR /app                                                                                                                              0.0s
 => [builder 5/5] RUN autoreconf --install && ./configure && make                                                                                           9.8s
 => CACHED [stage-1 2/4] RUN apk add --no-cache mandoc                                                                                                      0.0s
 => CACHED [stage-1 3/4] COPY --from=builder /app/src/fping /usr/local/bin/fping                                                                            0.0s
 => CACHED [stage-1 4/4] COPY --from=builder /app/doc/fping.8 /usr/share/man/man8/fping.8                                                                   0.0s
 => exporting to image                                                                                                                                      0.0s
 => => exporting layers                                                                                                                                     0.0s
 => => writing image sha256:161546cdbc611cbc0fa5a5039fb6f9a4d5dea1c440b18f72d8995c8b8f06c3c6                                                                0.0s
 => => naming to docker.io/library/fping

Copy link
Collaborator

@auerswal auerswal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks!

@auerswal auerswal merged commit d980f9b into schweikert:develop Aug 2, 2025
13 of 14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants