1

The Minos Docker compose take long time to compile and fire up, the problem is more relevant if i have to purge the docker and reinstall from scratch. have a way to reduce that time?

this is the docker compose code:


 ...
  microservice-project:
    restart: always
    build:
      context: microservices/project
      target: production
    environment: &id001
      MINOS_BROKER_QUEUE_HOST: postgres
      MINOS_BROKER_HOST: kafka
      MINOS_REPOSITORY_HOST: postgres
      MINOS_SNAPSHOT_HOST: postgres
      MINOS_DISCOVERY_HOST: apigateway
    depends_on: &id002
    - postgres
    - kafka
    - apigateway
  microservice-product:
    restart: always
    build:
      context: microservices/product
      target: production
    environment: *id001
    depends_on: *id002
  microservice-user:
    restart: always
    build:
      context: microservices/user
      target: production
    environment: *id001
    depends_on: *id002
  microservice-github:
    restart: always
    build:
      context: microservices/github
      target: production
    environment: *id001
    depends_on: *id002
x-microservice-environment: *id001
x-microservice-depends-on: *id002
Andrea Mucci
  • 747
  • 2
  • 9
  • 25
  • What part of the build runs slowly? There's a lot of non-build-related options here; can you reproduce the problem with a single `docker build` command, without the rest of the Compose setup? Can you [edit] the question to include the problematic Dockerfile and highlight which specific steps are slow? – David Maze Apr 06 '22 at 17:05

1 Answers1

1

The docker compose take long time to compile because minos provide a docker-compose file with the build -> target parameter on "production".

as you can see on the microservice Dockerfile, minos provide two different stages, one is production that compile wheels files and a development that simply export the poetry requirements and build the project.

so, to improve the build performaces simply modify the docker-compose file like that


  ...
  microservice-project:
    restart: always
    build:
      context: microservices/project
      target: development
    environment: &id001
      MINOS_BROKER_QUEUE_HOST: postgres
      MINOS_BROKER_HOST: kafka
      MINOS_REPOSITORY_HOST: postgres
      MINOS_SNAPSHOT_HOST: postgres
      MINOS_DISCOVERY_HOST: apigateway
    depends_on: &id002
    - postgres
    - kafka
    - apigateway
  microservice-product:
    restart: always
    build:
      context: microservices/product
      target: development
    environment: *id001
    depends_on: *id002
  microservice-user:
    restart: always
    build:
      context: microservices/user
      target: development
    environment: *id001
    depends_on: *id002
  microservice-github:
    restart: always
    build:
      context: microservices/github
      target: development
    environment: *id001
    depends_on: *id002
x-microservice-environment: *id001
x-microservice-depends-on: *id002

Note that you may need to add a RUN poetry install statement in the development stage of your Dockerfile:

...
COPY ./pyproject.toml ./
RUN poetry install --no-root
COPY . .
RUN poetry install  # <-- Add this line
CMD ["poetry", "run", "microservice", "start"]

FROM development as build
...
garciparedes
  • 1,749
  • 2
  • 18
  • 34
Andrea Mucci
  • 747
  • 2
  • 9
  • 25