-
-
Notifications
You must be signed in to change notification settings - Fork 305
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Unify Dockerfiles #364
feat: Unify Dockerfiles #364
Conversation
> Avoid use of wget without progress bar. Use `wget --progress=dot:giga <url>`. Or consider using `-q` or `-nv` (shorthands for `--quiet` or `--no-verbose`)
> Do not use --platform flag with FROM While this would be a good idea for single-arch images, on amd64 this image must still resolve to avoid build errors but is not used in the final image
> Always tag the version of an image explicitly Hadolint is unaware that the final FROM image is based on one of the two FROM's above, both of which are tagged. Therefore this is a false positive.
Hadolint makes two good points that I don't want to ignore:
This is the
Which is solid advice in general. I would consider creating and using appropriate users to be out of scope for this PR, but I'd be happy to make a separate PR for this if y'all want it! |
Dockerfile
Outdated
FROM cm2network/steamcmd:root as base-amd64 | ||
# Ignoring --platform=arm64 as this is required for the multi-arch build to continue to work on amd64 hosts | ||
# hadolint ignore=DL3029 | ||
FROM --platform=arm64 sonroyaalmerol/steamcmd-arm64:latest as base-arm64 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One thing you could do is use sonroyaalmerol/steamcmd-arm64:root
instead of the latest
tag. This would also allow you to remove USER root
from the other linting error. While this is definitely not a fix, at least you'll have the linting errors suppressed for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh hey, that's you!
What's the difference between the root
and latest
tags? I noticed that the arm64
build used latest
, so I was a bit leery of just swapping tags without understanding the difference, lest I unintentionally break something.
Though that would avoid the lint error, the "spirit" of the DL3007 lint rule would still be violated, as it's point is to avoid tags that aren't deterministic
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The image is identical to cm2network/steamcmd
(the base image used for amd64) but with the addition of Box64 and Box86 which adds compatibility for arm64. The root
tag is literally just the latest
tag but with root
as its active user. The latest
tag has steam
as its active user as the steamcmd executable within the images are owned and can only be executed by steam
.
The only reason the Dockerfile.arm64
used the latest
tag was that I hadn't implemented the root
tag yet when I PR-ed the arm64 support.
Well, I can definitely add some deterministic tags for version pinning in my image but I can't say the same for the original cm2network/steamcmd
image.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for clarifying!
Excellent! |
feat: Unify Dockerfiles
Context
-arm64
tags since Docker will resolve the appropriate architecture image automatically.Choices
There's no real magic to this unification, it uses:
$TARGETARCH
build argument to choose which base image to usegorcon
for both arm64 and amd64arm64v8/golang:1.22.0-bullseye
image for officialgolang
alpine image when buildinggorcon
gorcon
compilation so that the GCC compiler toolchain doesn't have to be installed and the binary is portablego get
command sincego build
will resolve any missing dependencies based on thego.sum
file$TARGETARCH
build argument to choose which SHA1SUM to check against per-architecture--progress=dot:giga
fromwget
in the Go build ofgorcon
since the Alpine/Busybox variant ofwget
doesn't support this option, but utilizes-q
to to comply with Hadolint DL3047unit-test.yml
workflow as doing so would prevent running the arm64 and amd64 tests in parallel like they currently are.Do not use --platform flag with FROM
) as on amd64 this image must still resolve to avoid build errors but is not used in the final image, but it is used in the arm64 build.Always tag the version of an image explicitly
) as Hadolint is unaware that the final FROM image is based on one of the two FROM's above, both of which are tagged. Therefore this is a false positive.As @sonroyaalmerol pointed out in #319 (comment), this could possibly require building future dependencies from source if added, though the
arm64
emulation in GitHub Actions is likely to always be the slowest point in the image build. Usingbuildx
now means that some of the workflow can run in parallel vs the default builder which was sequential, meaning it's likely the time to build has been reduced by a bit.Test instructions
docker buildx build --platform=linux/amd64,linux/arm64 .
to verify build sanitydocker buildx build --platform=linux/amd64 . --load -t palworld:test
docker run -p 8211:8211/udp --rm -it palworld:test
and connected via Palworld to verify the server still runsdocker buildx build --platform=linux/arm64 . --load -t palworld:test
docker run -p 8211:8211/udp --rm -it palworld:test
and connected via Palworld to verify the server still runsChecklist before requesting a review
I have introduced breaking changes in that the
-arm64
tags suffixes will no longer be required.