Skip to content
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

Docker build warnings #181

Open
faisal-memon opened this issue Sep 8, 2024 · 3 comments
Open

Docker build warnings #181

faisal-memon opened this issue Sep 8, 2024 · 3 comments
Milestone

Comments

@faisal-memon
Copy link
Collaborator

Running make docker-build results in the following warnings:

 2 warnings found (use --debug to expand):
 - InvalidDefaultArgInFrom: Default value for ARG golang:${go_version}-alpine results in empty or invalid base image name (line 3)
 - Requested platforms linux/arm64 do not match result platforms linux/amd64,linux/arm64
 - ```
@keeganwitt
Copy link
Contributor

keeganwitt commented Sep 8, 2024

Two approaches for fixing the warning involving the goversion occur to me. One would be to keep the default in the Dockerfile up-to-date with the Go version desired. The other would be to use a default that's valid, but not an exact match (such as defaulting to the latest version). On the one hand, it is inconvenient to have to maintain another version reference, and when invoking the build through Make, you'll still get the desired version. On the other hand, I think most users will try docker build first before make, and if there's a default arg they won't even realize they're using a different version than expected and may get unexpected results.

@faisal-memon
Copy link
Collaborator Author

Thanks @keeganwitt for the breakdown. I like the idea of having it pull latest if no goversion is specified. Though I think setting up that logic within a Dockerfile might be a bit challenging. Right now we are using ${goversion}-alpine which errors when $goversion is empty as -alpine is not a valid tag. We need to do some string manipulation to get rid of the leading dash and default to alpine

@keeganwitt
Copy link
Contributor

keeganwitt commented Sep 10, 2024

One option would be

# syntax=docker/dockerfile-upstream:master
ARG go_version=latest
ARG incomplete_tag=${go_version}-alpine
ARG image_tag=${incomplete_tag#latest-}
FROM --platform=$BUILDPLATFORM golang:${image_tag} as base

But I'd love to not have to use pre-release Dockerfile features. The only option I can think of to avoid that would be to change the argument, like

ARG go_image=alpine
FROM --platform=$BUILDPLATFORM golang:${go_image} as base

https://docs.docker.com/reference/dockerfile/#environment-replacement

@faisal-memon faisal-memon modified the milestones: 0.9.0, 0.10.0 Nov 12, 2024
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

No branches or pull requests

2 participants