Reputation: 837
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
Upvotes: 2
Views: 4097
Reputation: 837
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
...
Upvotes: 1