๐๐ฒ๐ฝ๐น๐ผ๐ ๐๐ฎ๐ฟ๐ฎ๐๐ฒ๐น ๐ช๐ถ๐๐ต ๐๐ผ๐ฐ๐ธ๐ฒ๐ฟ ๐๐ป๐ฑ ๐๐๐ฏ๐ฒ๐ฟ๐ป๐ฒ๐๐ฒ๐
Your Docker images should be small. Large images slow down your deployment.
Use multi-stage builds to fix this.
Stage one is the builder.
- Install system tools.
- Install Composer and NPM.
- Compile your assets.
- This stage does not go to production.
Stage two is production.
- Use a light Alpine image.
- Copy only the needed files from the builder.
- Remove build tools.
- This keeps the image lean.
You need three more things for a professional setup:
- Nginx configuration.
- Log to stdout and stderr.
- Block access to your SQLite database.
- Send PHP requests to port 9000.
- PHP optimization.
- Turn on OPcache.
- Hide your PHP version for security.
- Set memory limits for large tasks.
- Supervisord.
- Run Nginx and PHP-FPM together.
- Ensure both start and restart automatically.
This setup works well for Kubernetes. It is fast and secure.