-
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
Final non-root changes to Python, Ruby and C# templates #91
Conversation
This looks great @ems5311 - you are blazing a trail through these issues! |
template/csharp/Dockerfile
Outdated
WORKDIR /root/ | ||
WORKDIR /root/src | ||
#WORKDIR /root/ | ||
#WORKDIR /root/src |
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.
Can we remove the comments here?
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.
no prob -- will be done this evening
46b41bc
to
17cdcee
Compare
Derek add label: status/testing |
We should move the adduser/useradd up top.. @ericstoekl can you work on this or recruit some help from the community? |
Yeah, I can get some stuff done on this later tonight. |
The change for Node.js is already merged and released 👍 |
all working xenial x64 |
Btw is there a reason they should not use root? At work I pass in UID and GID, that seems to stop effects of containers writing files as root or a user that doesn't exist. It's done once at container initial start |
17cdcee
to
4d7dd84
Compare
@alexellis Just updated to move @Lewiscowles1986, Thanks for testing! This change was proposed after Nic gave a presentation about the potential vulnerabilities of running the docker images as root. |
template/python/Dockerfile
Outdated
@@ -9,19 +11,26 @@ RUN apk --no-cache add curl \ | |||
|
|||
WORKDIR /root/ |
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.
Is this line required?
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.
Probably not, I think we can safely remove. Thanks Nic!
@ericstoekl @alexellis I have tested a python 2 function, including pip to install a package and it seems all ok. There is one line in the docker file: https://github.com/openfaas/faas-cli/pull/91/files#diff-2c26f08f6712431fc39c186c9bf2117cL10 Temp file is also written |
@ericstoekl @alexellis I have also tested python 3, including pip to install a package and all seems ok. Temp file is also written: |
Thank you for your contribution. I've just checked and your commit doesn't appear to be signed-off. |
20504af
to
c94b058
Compare
So I've put together a script that lets anyone easily test this change. If you have
It will download the templates from this PR and build a function in |
Tested, works.
|
This script is good for a cursory check but we have to ensure there is no breakage for getting/installing/accessing 3rd-party dependencies too. I also found some issues with the .lock file not being written properly to /tmp/. You can check on |
To test lock file status, I created functions from the node, python, ruby, and csharp templates using the script posted above, and checked each deployed function with
|
template/python/Dockerfile
Outdated
@@ -1,27 +1,34 @@ | |||
FROM python:2.7-alpine | |||
|
|||
RUN adduser app -D |
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.
Templates need to add a group too so they follow the pattern of the Node example.
RUN addgroup -S app && adduser -S -g app app
Then chown to app:app
Please also chmod /tmp to 777
for all templates to get around buildkit/containerd issue.
template/python/Dockerfile
Outdated
@@ -1,27 +1,34 @@ | |||
FROM python:2.7-alpine | |||
|
|||
RUN adduser app -D | |||
|
|||
# Alternatively use ADD https:// (which will not be cached by Docker builder) | |||
RUN apk --no-cache add curl \ | |||
&& echo "Pulling watchdog binary from Github." \ | |||
&& curl -sSL https://github.com/openfaas/faas/releases/download/0.6.1/fwatchdog > /usr/bin/fwatchdog \ |
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 version is now 0.6.9
please update.
template/python/Dockerfile
Outdated
# Alternatively use ADD https:// (which will not be cached by Docker builder) | ||
RUN apk --no-cache add curl \ | ||
&& echo "Pulling watchdog binary from Github." \ | ||
&& curl -sSL https://github.com/openfaas/faas/releases/download/0.6.1/fwatchdog > /usr/bin/fwatchdog \ | ||
&& chmod +x /usr/bin/fwatchdog \ | ||
&& apk del curl --no-cache | ||
|
||
WORKDIR /root/ | ||
RUN mkdir -p /home/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's going on with the ordering here? Does it optimize the build?
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 is the same ordering used in the node template, which I am basing these templates off of.
Edit -- actually looks like this line is unnecessary. Removing.
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.
Really close, few minor changes needed.
Derek add label: risk/high |
Review given. This is a high risk item so we can't afford for mistakes. Thank you for taking care with this. |
@ericstoekl can you update/respond to @alexellis' comments and we can get this closed out. |
c94b058
to
856bb7c
Compare
@alexellis Updated to address comments from the review. Sorry for the delay, this one got lost in the shuffle somehow 😕 To test this out to verify it works, run the following:
When it's done running you should see this kind of output:
This shows that for each function template, the user is |
Thanks to @austinfrey we found some issues in the current status of this PR -- the csharp function fails to build due to the Edit -- updated the PR with a squashed commit, Set up a new deployment ( |
856bb7c
to
8146ee5
Compare
lgtm |
…ROOT Signed-off-by: Eric Stoekl <ems5311@gmail.com>
Signed-off-by: Eric Stoekl <ems5311@gmail.com>
8146ee5
to
345fd09
Compare
Please can we raise against this site too? https://github.com/openfaas/templates Templates are graduating up. |
@ericstoekl templates are graduating to the new repo so I'm closing this PR. Please raise it against the new repo. |
Dockerfile for python, ruby, and C# template should not use ROOT
Signed-off-by: Eric Stoekl ems5311@gmail.com
Description
Like #83, this change is to have template Dockerfiles establish the function in an environment not running as
root
.Motivation and Context
Proposal: Alter templates to run as non-privileged user #81
How Has This Been Tested?
ad-hoc
Types of changes
Checklist:
git commit -s