Performance: Docker deployment
Docker deployment affects the initial page load speed and server response time by controlling how the Laravel app and its dependencies are packaged and started.
Jump into concepts and practice - no test required
FROM php:8.1-fpm-alpine RUN apk add --no-cache git unzip WORKDIR /app COPY composer.json composer.lock ./ RUN composer install --no-dev --optimize-autoloader COPY . . EXPOSE 9000 CMD ["php-fpm"]
FROM php:8.1-apache RUN apt-get update && apt-get install -y git unzip COPY . /var/www/html RUN composer install EXPOSE 80 CMD ["apache2-foreground"]
| Pattern | Image Size | Startup Time | Resource Usage | Verdict |
|---|---|---|---|---|
| Heavy base image with full PHP and Apache | Large (700MB+) | Slow (20+ seconds) | High CPU and Memory | [X] Bad |
| Lightweight Alpine PHP-FPM with cached dependencies | Small (200-400MB) | Fast (under 5 seconds) | Low CPU and Memory | [OK] Good |
services:
app:
build: .
ports:
- "8000:80"
volumes:
- .:/var/www/html
db:
image: mysql:8
environment:
MYSQL_ROOT_PASSWORD: secret
What happens when you run docker-compose up?FROM php:8.1-fpm RUN apt-get update && apt-get install -y git zip unzip COPY . /var/www/html RUN composer installWhat is the likely cause of the build failure?
composer install.