Hello. I ’m Hirose from Pathee.
When using serverless-python-requirements
I didn't find much information about the file structure, so I will write it.
The company is developing an API using ʻAWS lambda` Part of the backend of a new project
--Language is Python3.7
--Package management is Pipenv
--Development / execution / deployment using Serverless Framework
--Package is layered using serverless-python-requirements
--Build the development environment in Docker and perform local tests (UT etc.) in Docker
root
├── lambda
│ ├── env
│ │ ├── dev
│ │ │ └── resource.yml
│ │ └── prod
│ │ └── resource.yml
│ ├── handler
│ │ └── aaa #Unit of each API
│ │ └── aaa.py
│ └── serverless.yml
├── layer
│ └── package
│ ├── Pipfile # ※1
│ ├── Pipfile.lock # ※2
│ └── serverless.yml
├── stepfunctions
│ └── sf_aaa.yml
├── docker-dompose.yml
├── Dockerfile
├── Pipfile #* Symbolic Link to 1
└── Pipfile.lock #* 2 Symbolic Link
Serverless Framework
Pipenv is implemented in the following two situations
--Install the package inside Docker
--Create a layer with serverless-python-requirements
Because I want to use the same package in both of the above situations, I want to use a common Pipfile, but Could not specify the directory for each Pipfile
So, as a solution, put the actual situation on the person who uses it with serverless-python-requirements
,
In the installation inside Docker, I put a symbolic link in the above file and surpassed it
I was looking into it again to write this article, If you specify the PIPENV_PIPFILE environment variable with pipenv, make it an absolute path may solve the problem ... Actually, I built this directory structure a few months ago, and I remember trying the above at that time, but it's ambiguous ... I would like to write a follow-up report if I have time
Recommended Posts