0

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.

Zeitounator
  • 38,476
  • 7
  • 53
  • 66
kepleton
  • 1
  • 1
  • 1
    [How to include files outside of Docker's build context?](https://stackoverflow.com/questions/27068596/how-to-include-files-outside-of-dockers-build-context) discusses how to have a per-service image with a directory structure like this. – David Maze Jul 29 '21 at 10:25
  • Changing the docker build context to the parent directory solved it, thanks! – kepleton Jul 29 '21 at 14:42

0 Answers0