I have a python project which contains multiple separate services, each with its own Dockerfile. I have a libs
directory in the project which contains multiple common modules which the services can depend on. The structure looks like this:
Project/
|-- service1/
| |-- src
| | | main.py
| | | ...
| |-- Dockerfile
| |-- setup.py
| |-- requirements.txt
|
|-- service2/
| | ...
| |
|-- libs
| |-- common_lib1
| | |-- src
| | | | lib1.py
| | |-- setup.py
| | |-- requirements.txt
| |-- common_lib2
| | | ...
|-- docker-compose.yml
What is the best way to install these local library dependencies into each service docker container?
I tried mounting the libs folder in the docker-compose file, but it wasn't available during build time so when I tried to install common_lib1, it failed.
I also tried to copy the libs folder in the service's Dockerfile, but it looks like I can't copy folders outside of the service folder.