-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Adds container.user configuration #1109
Adds container.user configuration #1109
Conversation
Thanks for the contribution! We'll take a look at this soon. For the future, we'd recommend commenting on the issue thread with the design/solution you will be implementing before starting work to help save time potentially changing large portions of the implementation. |
Ok I understand. It was very easy to implement. |
We can definitely work with most of this :) It's mostly that we need to decide what we would support for the user configuration. Currently, as proposed in #1029 (comment), we are intending only to support user id and group id and not username, but we might decide to allow username as well. @GoogleContainerTools/java-tools |
Yeah, looks like we can work on this. There are a few things to think about though. And thinking about it for a while, it might be possible to accept any string as the parameter value, not just numbers, if what we end up doing is to just set the value in the container config metadata. In that case, we may always be able to build an image (need to check), which may error at runtime due to non-existing username. |
Never mind. I think it is always buildable. Now I think there is no problem supporting usernames and it is the user's responsibility to use the base image that has the right user database. Same for usual Docker build. |
If we set the wrong username, we have this error at runtime :
|
Yeah, it's the same story for |
@@ -136,14 +137,25 @@ public Builder setEntrypoint(@Nullable List<String> entrypoint) { | |||
return this; | |||
} | |||
|
|||
/** | |||
* Sets the username or UID which the process in the container should run as. |
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.
I believe this can be a mix of user and group.
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.
You're right, I changed the javadoc.
@@ -299,6 +311,7 @@ public void generate(Path targetDirectory) throws IOException { | |||
* LABEL [key1]="[value1]" \ | |||
* [key2]="[value2]" \ | |||
* [...] | |||
* USER [user or UID] |
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.
ditto
/** | ||
* Sets the username or UID which the process in the container should run as. | ||
* | ||
* @param user the username or UID |
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.
ditto
/** | ||
* Sets the username or UID which the process in the container should run as. | ||
* | ||
* @param user the username or UID. |
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.
ditto
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.
Javadoc modified.
jib-core/src/main/java/com/google/cloud/tools/jib/image/json/ImageToJsonTranslator.java
Show resolved
Hide resolved
3216c1a
to
dadc2f5
Compare
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.
Looks great! Just some comment nits.
@@ -136,14 +137,26 @@ public Builder setEntrypoint(@Nullable List<String> entrypoint) { | |||
return this; | |||
} | |||
|
|||
/** | |||
* Sets the user name (or UID) and optionally the user group (or GID) which the process in the |
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.
Wording suggestion: Sets the user and group to run the container as. {@code user} can be a username or UID along with an optional groupname or GID. The following are all valid: {@code user}, {@code uid}, {@code user:group}, {@code uid:gid}, {@code uid:group}, {@code user:gid}.
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.
done
@@ -191,6 +192,18 @@ public JavaDockerContextGenerator setEntrypoint(List<String> entrypoint) { | |||
return this; | |||
} | |||
|
|||
/** | |||
* Sets the user name (or UID) and optionally the user group (or GID) which the process in the |
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.
Wording suggestion: Sets the user for the {@code USER} directive.
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.
done
@@ -89,6 +90,18 @@ | |||
return this; | |||
} | |||
|
|||
/** | |||
* Sets the user name (or UID) and optionally the user group (or GID) which the process in the |
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.
Wording suggestion: Sets the user/group to run the container as.
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.
done
* Sets the user name (or UID) and optionally the user group (or GID) which the process in the | ||
* container should run as. | ||
* | ||
* @param user the username and optionally the user group |
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 username/UID and optionally the groupname/GID
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.
done
* Sets the user name (or UID) and optionally the user group (or GID) which the process in the | ||
* container should run as. | ||
* | ||
* @param user the username and optionally the user group |
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 username/UID and optionally the groupname/GID
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.
done
Looks good to me. Updating some wordings, and I think we're good to go. |
dadc2f5
to
0082168
Compare
Great. I've rebased on master and fixed wordings. |
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.
LGTM. Thanks for your contribution again! I think this just fixes #1029. We should also add CHANGELOG entries for this new feature, but that can be done in a follow-up PR.
Towards #1029, this PR adds the possibility to sets the username or UID which the process in the container should run as.
For security reason, we prefer to start a tomcat container with non-root user. We have a generic base image with this (in our private registry) :