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

fix(docker): remove ARG PORT #157

Merged
merged 2 commits into from
Mar 29, 2024
Merged

fix(docker): remove ARG PORT #157

merged 2 commits into from
Mar 29, 2024

Conversation

vit-zikmund
Copy link
Collaborator

@vit-zikmund vit-zikmund commented Mar 18, 2024

EDIT: This OP no longer holds true, things got rather simplified instead. Follow the discussion below.

Yet another gratuitous fix nobody asked for :)

Shell parameter expansion doesn't happen inside the CMD array, so literal ${PORT} gets passed to uwsgi, which it happily accepts, but, well, doesn't work as expected.

One either needs to set an ENV var and use it in an entrypoint shell script or, if one doesn't want to pollute the container's env space, modify the argument (with sed) within the entrypoint itself. That's what I did.

Also this change ignores a couple fat development directories that complicate local make docker runs.

PS: I'm not a fan of docker entrypoints, but this couldn't be solved better, unless using custom variable expansion like this in the ENTRYPOINT:

r=(); for arg; do eval $'r+=("$(cat <<EoF\n'$arg$'\nEoF\n)")'; shift; done; exec uwsgi "${r[@]}"

which, although surely very beautiful, is also pretty obscure, rather unsafe and adds one more (unwanted) level of variable expansion to the arguments passed as the CMD.

Shell parameter expansion doesn't happen inside the CMD array, one either needs to pass an ENV var and use it in an entrypoint shell script or, if one doesn't want to pollute the container's env space, modify the argument (with sed) within the entrypoint itself.

Also ignore a couple fat directories that complicate local development.
@athornton
Copy link
Collaborator

I guess it'll work. Because I live in K8s-world where I don't have to worry about any of this, I'd just go the other way and force it to 5000 always and rely on a service or an ingress to modify that for the caller if I had to. But maybe assuming you've got k8s around is not a good assumption.

@athornton athornton assigned athornton and unassigned athornton Mar 21, 2024
@athornton athornton self-requested a review March 21, 2024 21:21
Copy link
Collaborator

@athornton athornton left a comment

Choose a reason for hiding this comment

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

It seems fine. My question is whether it's needed, because it is a little harder to read than just saying "Yes, this listens on port 5000". Since it's inherently a docker container, mapping that to something different outside shouldn't be a problem, should it?

@vit-zikmund
Copy link
Collaborator Author

I'm actually with you on this one. Driven by the status quo where there's an ARG PORT, I wanted to make it work as originally designed. But I admit it's insanely convoluted for such an optional task. AFAIK the EXPOSE directive is nothing but a hint for the runtime which port to expose, which is usually overridable from the outside (talking containerPort in k8s, or docker run --publish). So I'd much rather not see any of that, took out the ARG entirely and fix the port in the default CMD to 5000 as you say.
If you think it's fair to remove the ARG PORT, I'm all for that.

@athornton
Copy link
Collaborator

If you're in agreement, yeah, let's just fix PORT to 5000 in the container and be done with it. We can always change it back if anyone screams, and if you are for some reason running without containerization where you might not have as much control, you've still got the option to set the port.

Making it configurable via a build arg complicates the whole dockerfile setup way too much for such a useless feature :)
@vit-zikmund vit-zikmund changed the title fix(docker): properly propagate default ARG PORT fix(docker): remove ARG PORT Mar 28, 2024
@vit-zikmund
Copy link
Collaborator Author

@athornton I'm done, please squash this. Thanks!

Copy link
Collaborator

@athornton athornton left a comment

Choose a reason for hiding this comment

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

LGTM

@athornton athornton merged commit 75b046b into datopian:main Mar 29, 2024
7 checks passed
@vit-zikmund vit-zikmund deleted the fix-default-args branch May 2, 2024 14:58
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.

2 participants