I have 2 services in one git repository written in the python and deployed to the containers with docker-compose and docker. And I wanted to add some authorization with the third party OpenID Connect service. I have written a module to deal with authorization and I desire to use it in every service.
My repository looks like this:
services: first_service: Dockerfile docker-compose.yml first_service_python_module second_service: Dockerfile docker-compose.yml second_service_python_module docker-compose.yml .git
Initially, I wanted my authorization module to be in the ‘services’ folder but this way I cannot build my Docker images because Docker can’t deal with the outer folder without special argument.
But I cannot specify this argument because of docker-compose files.
So I ended up with the next repository structure:
services: first_service: Dockerfile docker-compose.yml first_service_python_module authorization_module second_service: Dockerfile docker-compose.yml second_service_python_module authorization_module docker-compose.yml .git
Obviously there is a lot of code duplication and it’s hard to maintain.
I want to avoid code duplication. But also not to change docker and docker-compose files a lot. How can I do it?