-
Notifications
You must be signed in to change notification settings - Fork 293
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
Run dockerized pip as invoking user #15
Conversation
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.
- Setting UID/GID: yes! great idea! Did you test this? When I tested it, I get permission errors when pip is trying to write to
/.cache
. And simply adding--disable-cache-dir
doesn't help either bc pip doesn't have permissions to upgrade itself. - Getting the option from the "right" place. It already is. See https://github.com/UnitedIncome/serverless-python-requirements/pull/15/files#diff-168726dbe96b3ce427e7fedce31bb0bcL119 which sets
this.custom
tothis.serverless.service.custom.pythonRequirements
. ThedockerizePip
option should be in thepythonRequirements
object per the docs (this did change in v2, thus the increase in major version number since it's a breaking change) - Setting
exclude
andinclude
correctly. I'm not sure what was wrong about the existing lodash based code (in fact, the code you added wouldn't work if it wasn't working):
$ node
> const _ = require('lodash')
undefined
> this.serverless = {service: {}} // add path that in the plugin is always there
{ service: {} }
> _.has(this.serverless.service, ['package', 'exclude'])
false
> _.set(this.serverless.service, ['package', 'exclude'], []);
{ package: { exclude: [] } }
> this.serverless.service.package.exclude
[]
> this.serverless = {service: {}}
{ service: {} }
> this.serverless.service.package.exclude = []
TypeError: Cannot set property 'exclude' of undefined
For context, I'm updating pip because I need a newer version and I didn't feel like making my own docker image just for this, mostly because I didn't know what was necessary for keeping it up to date despite the |
92891e4
to
b9c6524
Compare
By default docker executes commands in an container as root. This causes the downloaded dependencies to be owned by root. This messes up cleanup scripts. Using the correct object which holds the dockerizePip option. this.serverless.service.custom.dockerizePip Initialize the this.serverless.service.package.exclude and this.serverless.service.package.include correctly if they are not set.
I removed everything related to the option and the include/exclude parts. I tested it on our Jenkins slaves:
My local machine:
The pip version in the container was already up to date when I tested it.
If I mount a directory to /.cache (like |
By default docker executes commands in an container as root. This causes the downloaded dependencies to be owned by root. This messes up cleanup scripts.
Using the correct object which holds the dockerizePip option.
this.serverless.service.custom.dockerizePip
Initialize the this.serverless.service.package.exclude and this.serverless.service.package.include correctly if they are not set.