Serverless-python-requirements: Option to package with supplied Dockerfile

Created on 15 Dec 2017  路  1Comment  路  Source: UnitedIncome/serverless-python-requirements

This option would come in handy when one needs to have a custom image (usually built on top of lambci/lambda ones) for requirements packaging.

The use case I came across was when I needed to run my serverless Python function that uses pymssql in Python 3.6 environment. Unfortunately, the project currently does not provide a pre-built wheel for Python 3.6 in Linux environment - see https://github.com/pymssql/pymssql/issues/473

So my workaround for this is to build pymssql with the environment variable export PYMSSQL_BUILD_WITH_BUNDLED_FREETDS=1, included in a Dockerfile as such:

FROM lambci/lambda:build-python3.6

ENV PYMSSQL_BUILD_WITH_BUNDLED_FREETDS 1

Built the image, and pushed to Docker Hub, specified in custom.pythonRequirements.dockerImage option supported by this plugin. Everything works great.

However, this solution would be more portable and flexible for when the use case prohibits the use of Docker Hub, for whatever reasons. If there's an option to allow dockerImage to be sourced from a Dockerfile directly, basically adding one step to first build the image using supplied Dockerfile, tag it with serverless service name and stage and runtime for matching convention with currently supplied set of lambci/lambda images, and then just follow the existing steps to package pip requirements.

enhancement

Most helpful comment

Oooh, that's a good idea, having to maintain your own image is a nuisance and this would help a ton. I think I'd want to add a dockerfile option which is mutually exclusive with the dockerImage option.

>All comments

Oooh, that's a good idea, having to maintain your own image is a nuisance and this would help a ton. I think I'd want to add a dockerfile option which is mutually exclusive with the dockerImage option.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

calclavia picture calclavia  路  5Comments

brettdh picture brettdh  路  5Comments

sepulworld picture sepulworld  路  5Comments

amitm02 picture amitm02  路  6Comments

IanTayler picture IanTayler  路  4Comments