-
Notifications
You must be signed in to change notification settings - Fork 223
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
[WIP] non-root user for NodeJS template #83
Conversation
Initial draft to get feedback before moving on to other templates. No need to merge yet. |
template/node/Dockerfile
Outdated
@@ -12,27 +12,31 @@ WORKDIR /root/ | |||
# Turn down the verbosity to default level. | |||
ENV NPM_CONFIG_LOGLEVEL warn | |||
|
|||
RUN mkdir -p /usr/local/app/function |
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.
What about a regular home directory like /home/app/
?
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.
sounds good
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.
This should be: /home/app/
as per the comment, could you update? I'd like to move forward and merge your change. Thank you for helping lead this @aafrey
template/node/Dockerfile
Outdated
WORKDIR /root/ | ||
WORKDIR /usr/local/app/ | ||
|
||
USER node |
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.
Great start! Maybe the username could be app
and we could use that across the board - like a copy/paste segment for all the templates?
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.
that makes the most sense. I'll work on it this evening
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.
Just picking up on the user, and acknowledging that its largely academic, but why dont we use faas
or openfaas
? Setting this as a sort of principle might be helpful further down the road, when 3rd party templates start to emerge.
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'd just keep it generic like app
for now. Always good to think forward though so thanks for your input.
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.
Changes needed.
When I try this change, I get the following error:
I believe this can be fixed by the following line just before the
|
@ems5311 thank you for testing. |
@ems5311 appreciate the feedback. I couldn't reproduce so I'm unsure what the issue is. I wouldn't think you'd need to |
@aafrey Thanks for the feedback, strangely I am still seeing the issue. I have uploaded the image that I believe if you run I have also made sure that I am building the Thanks again, |
@ems5311 Hi Eric, the image you sent over doesn't work for me either, could you try building with the |
@aafrey good call, I'll try this out tonight. |
Yep, works now. Force rebuilding the image with |
@ems5311 appreciate the testing! thanks! |
@alexellis anything else needed here? |
Yes I posted a comment about using /home/app as the folder for the app. |
@alexellis the most recent commit made that change |
@austinfrey are we good to go with this? |
template/node/Dockerfile
Outdated
|
||
WORKDIR /root/ | ||
RUN addgroup -S app && adduser -S -g app app |
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.
We can add the group at the top - meaning this gets cached and not affected by copying code in.
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 can make this change @alexellis then we should be all set. should I make the change, squash and resubmit? or can i squash and commit with this same PR?
Yes you can squash and re-push with the --force flag. I only raise a new PR if I screw things up really bad and have to push out of a different branch. |
Ping me for merging. |
Thank you for your contribution. I've just checked and your commit doesn't appear to be signed-off. |
@alexellis i had to merge the latest master with my branch to get up to date, i squashed everything down to one commit, but attributing all the previous changes i had to merge in as being part of this commit. is that normal? |
Struggling to see the changes here. This contains 32 files and now has some merge conflicts. Maybe it would be easier to submit a new PR? |
Agreed, I'll resubmit this evening |
…om the `home/app` directory. Signed-off-by: Austin Frey <aafrey85@gmail.com>
@alexellis started fresh, hopefully that's the last of it :) |
Derek add label: status/testing |
WORKDIR /root/ | ||
|
||
# Turn down the verbosity to default level. | ||
ENV NPM_CONFIG_LOGLEVEL warn | ||
|
||
RUN mkdir -p /home/app | ||
|
||
# Wrapper/boot-strapper |
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.
Just wondering if "user app" can go higher?
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.
sure. I'll update and test
Signed-off-by: austinfrey <aafrey85@gmail.com>
@alexellis moved |
Merged. Please can you retro-fit to the armhf template? @rgee0 perhaps you could help test? |
@austinfrey this broke :-/ |
|
Initial draft of non-root user in the NodeJS template.
Description
update the template/node/Dockerfile to use the
node
user rather than root. function directory structure needed to changed from/root/
to/usr/local/app/
as wellMotivation and Context
Allows users to run function as non-root which may increase security
This relates to #81
already raised by @alex Proposal: Alter templates to run as non-privileged user #81
How Has This Been Tested?
Manually built test function after changes, deployed and tested through the UI gateway
Linux 16+ on Docker CE 17.06
Will only impact the NodeJS template
Types of changes
Checklist:
git commit -s