简体   繁体   中英

How to dockerize a microservice php application?

I have around 10 microservices built on Yii PHP on my development environment. They are all running on vagrant. They share the same database (MongoDB), and same Nginx. Some services uses elastic,redis,rabitmq....etc. I need to use docker instead of vagrant. What is the best way to dockerize the whole application?

There is a lot of things if you are moving to dockerize your application. I have mention few tips that will help you in the development and production environment.

  1. You have to make Dockerfile for all the binaries (Elastic-Search, MongoDB, Redis, etc) and micro-services. In Dockerfile you need to add only the required packages. Docker has a layered architecture. If anything changed in the previous layer it will affect the next all layer. So, frequently changeable layers should be written at the end of Dockerfile. It will help a lot in the production environment.
  2. Make docker-compose.yml to run these binaries and services. Dockerfile are used to make images but docker-compose.yml run that image. so, all the information required to run a service like networks, volume, commands, etc should be in docker-compose.yml
  3. You can use Jenkins for the CI/CD pipeline as well.
  4. Container orchestration tools like Kubernetes, docker swarm, etc, can be used for the production environment.

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