简体   繁体   中英

Can I merge two requirements.txt files to one via Docker compose?

I have multiple python microservices, that all have separate requirements, but share some requirements and some code. I mount this shared code and requirements.txt to every service in a volume specified by a docker-compose file.

Example, where the two mounted volumes have different requirements.txt files:

  search:
    build: ./services/search
    volumes:
      - ./services/search:/app
      - ./shared:/app/shared
    command: python search.py

  filter:
    build: ./services/filter
    volumes:
      - ./services/filter:/app
      - ./shared:/app/shared
    command: python filter.py

Is there a way to merge the two requirements.txt files? At the moment, I run two separate pip -r install requirements.txt commands, but I don't like that approach.

I see no reason why running the command twice isn't good, but you can also merge requirements1.txt into requirements2.txt using cat requirements1.txt >> requirements2.txt

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM