-
Notifications
You must be signed in to change notification settings - Fork 46
Directly execute start.jar rather than use shell script #16
Conversation
I like where you're going with this, but I think we'll need to refine it a bit. One thing in particular that stands out as going against the best practices for Official Images (and Dockerfiles in general), is the use of Most of the official images instead use a small Bash wrapper script that detect whether the first argument to the Many of those wrapper scripts also add a call to One thing that concerns me about the approach normally used in those wrapper scripts is that Another thing I noticed is that we'll no longer be setting It also looks like the I may have some other comments once I sleep on it, but like I said initially, I definitely support the goal of allowing the users to pass command line arguments to |
BTW, the rationale for the restricted use of |
@md5, yeh I was a bit concerned about breaking changes.... The only purpose of the jetty.state file is so that "jetty.sh start" can wait to report success or failure before exiting. Since the current image uses "jetty.sh run", this is not required and another reason to look to avoid the complex moving parts of jetty.sh. I can't think that anybody else would be using the state file, so if it doesn't get created it should not break your read-only containers. Thus I think the biggest problem is the use of entry point that is against the conventions of other containers. So perhaps a simple shell wrapper that looks at the first passed parameter and if it is executable (eg bash), then execute the whole line, otherwise just append to java -jar start.jar Note that one of the drivers for this for me is start time, were I have a need to spin up containers ASAP, so even the few ms to start a shell and then exec java are seen as unacceptable cost... but then we are likely to replace whatever CMD is there by the exact command generated by --dry-run anyway... so a little shell script is OK. Which takes me full circle to thinking that if there is a shell script... then why not use the standard one. But then jetty.sh also does stuff like looking for /etc/default/jetty and /etc/jetty.conf for additional configuration... so depending on if that is ever used or not, that is either more unnecessary work or breaking changes :( I'll ponder on this some more. cheers |
I just pushed a change with a few clean ups and moved the ENTRYPOINT to a CMD. This is a not so bad compromise as the following commands are all simple enough and work:
The last is a little verbose and not so obvious... but documentation can help with that. So this avoids shell scripts and allows the bash convention to be observed. One additional breaking change may be that we need to add the logging module, as currently jetty.sh adds jetty-logging.xml to the command line, so this PR removes it and thus changes behaviour. I kind of like the log coming out stderr... but that would be a change. thoughts? |
Ah ignore the jetty-logging comment, I see that is stripped out of the jetty.conf anyway! No need to do that now... another push coming... |
Note also, regarding the setuid, I don't think that is really necessary. You would use setuid if you want to open port 80 and then change to the jetty user. But this image opens 8080, so it is probably better just to use USER? Even if you want to use 80, it is probably better to use ipchains or iptables to map to 8080 rather than open as root and setuid. |
I'm not a big fan of using
|
We should be able to revisit that decision, but it will break some of the existing derived images. I see at least a few doing thing that require https://github.com/search?l=Dockerfile&q=from+jetty&type=Code&utf8=%E2%9C%93 The big problem with Docker images in general is that there's no in-band way to notify users of breaking changes. Couple this with the standard practice of only tagging images with a (mutable) tag based on the upstream version and it becomes really easy to break a user's installation unexpectedly. 😢 |
Also, there was some discussion of publishing the SHA256 digest of official images in the |
I seem to remember the discussion being related to the |
Found it! The discussion starts here: docker-library/postgres#75 (comment) |
@gregw One more thing regarding the Using |
It could also let them do things as |
@tianon What do you think about an approach like the following instead of the if ! which "$1" >/dev/null; then
set -- java -jar /usr/local/jetty/start.jar "$@"
fi ??? |
@gregw I'll also mention that the reason I'm setting |
@md5 seems pretty reasonable to me, assuming the set of things you might
want to pass in aren't valid commands
I did something similar for the new "docker" image:
https://github.com/docker-library/docker/blob/251cf235760a2ba6db1cf1ddc8ccb3d4da5ec99d/1.8/docker-entrypoint.sh#L8-L12
|
@md5 - I probably have raised too many issues in this PR. So let's put some to bed:) I'm sold on setuid - good as it is. I understand the need for not using ENTRYPOINT and am happy with how the PR currently is with a CMD. This works for the existing cases exactly the same as now. If you want to pass extra args into start.jar, then you have to reproduce the whole line... a bit verbose, but not too bad. With regards to avoiding the jetty.sh invocation, while speed is part of my concern, it is mostly motivated by the fact that that script is not well suited for that task and is looking for /etc configuration and rediscovering env variables that are already known. Ie it is a moving part that is not needed. So I think the PR as it currently stands is worthy of consideration. It removes the jetty.sh script and simplifies things, but should not change any significant behaviour. For the record, start.jar can process:
But I see no need for a ENTRYPOINT script as the direct execution of start.jar as a CMD is simple and can be replaced as needed. Actually if it is the norm to not use ENTRYPOINT, then perhaps we should raise a feature request on docker run to support additive args to CMD... but that is definitely a different issue. |
The norm for Once that's merged into your branch (assuming it makes sense to you), we can squash and then merge your PR into In the future, I think it would be fine if you create branches in this repo directly. That will avoid the back-and-forth dance of me having to send me a PR for your PR 👍 One question I still have is about the removal of the |
Ah I misunderstood the best practise on ENTRYPOINT. So a little script is best practise, so let's go with that - it avoids jetty.sh and allows easy additional args to be passed. Perhaps the best check to do is [which $1] ie if the first argument is executable, then execute it, else pass it to start.jar as extra arguments With regards to removing jetty-logging from jetty.conf, that file is only used if jetty.sh is used. So no need to edit it. If you want, perhaps remove it and jetty.sh to be clear? Do you want me to have a go at creating the script rather than a PR on a PR? +1 on branches in future :) |
Here's the script I would use (not tested, but it should work unless I flubbed something): #!/bin/bash
set -e
if [ "$1" = jetty.sh ]; then
cat >&2 <<- 'EOWARN'
********************************************************************
WARNING: Use of jetty.sh from this image is deprecated and may
be removed at some point in the future.
See the documentation for guidance on extending this image:
https://github.com/docker-library/docs/tree/master/jetty
********************************************************************
EOWARN
fi
if ! type "$1" &>/dev/null; then
set -- java -jar "-Djava.io.tmpdir=$TMPDIR" "$JETTY_HOME/start.jar" "$@"
fi
exec "$@" We're going to want to have a copy of that script at the root of the repository and some additional code in Also, since existing users could have done customization based on |
In the |
We might also want a comment in the script before the |
I just noticed that GitHub rendered my tabs as four spaces instead of actual tabs... I think that's because I used |
Pushed another iteration - now using docker-entrypoint.bash |
I'd actually prefer a more minimal diff that reflects just the functionality that has changed. I just spent 5 minutes before I saw that you'd pushed a new commit and did this: https://github.com/appropriate/docker-jetty/compare/use-start-jar |
One difference is that I left the |
Also, with the |
Do you want me to do a PR to jetty-project:master so you can squash the commits and keep everything in this same PR? That will record you as the author instead of me, but I don't care either way. |
@md5 I'm not worried about commit credit, so whatever is simplest. But I think I'm missing about that docker-entrypoint.bash? If it is not set as the ENTRYPOINT, then how is it executed? Is it an automagic thing? Your branch currently fails on :
So I'm not understanding something??? Note also that it does work for
but no warning is produced? out of time today.... will look again tomorrow. |
Gah! You're totally I right about my missing the I'll fix this up and squash it. |
I've got a working version over in #17. Squashing left you as the author since your commit was first. I'm going to update the tests to add a |
Thanks for initiating these changes! 👍 |
@md5 - all good! manual testing working as expected for me. Only quibble is that perhaps the JETTY_RUN and JETTY_STATE env variables should be removed. I've also noticed that it is missing a -R on the chown for JETTY_BASE, but I'll open that as another issue and do a direct commit if nobody objects. |
Closing as now covered by #17 |
The reason I left |
Rather than use the shell script to start Jetty, I believe it would be better to directly run the start.jar
The jetty shell script is really intended as an /etc/init.d script and does all the location of java, home and base, which is already known in the ENV settings of the Dockerfile.
So we can avoid creating a shell process, which will be some time and space savings, but more importantly we are able to pass in command line arguments to the start.jar, so you can do things like:
To see the configuration of the image.
runs jetty, but with the debug module enabled
Reports the exact command line that would be run by start.jar, which can be used to craft an Entry-Point for another image that avoids even the start.jar startup time and memory.
I've only updated 9.3 image at the moment.... if this is considered a good idea I can do all the versions... or perhaps we only do it for versions going forward? or perhaps it is a bad idea for some reason I don't know yet???