- Add comprehensive .dockerignore file to exclude unnecessary files - Update Dockerfile to install required system dependencies and PHP extensions - Set proper working directory and user permissions - Use multi-stage build for Composer installation
36 lines
770 B
Docker
36 lines
770 B
Docker
FROM php:8.4-fpm
|
|
|
|
# Install system dependencies
|
|
RUN apt-get update && apt-get install -y \
|
|
git \
|
|
curl \
|
|
libpng-dev \
|
|
libonig-dev \
|
|
libxml2-dev \
|
|
zip \
|
|
unzip \
|
|
libzip-dev \
|
|
libicu-dev
|
|
|
|
# Clear cache
|
|
RUN apt-get clean && rm -rf /var/lib/apt/lists/*
|
|
|
|
# Install PHP extensions
|
|
RUN docker-php-ext-install pdo_mysql mbstring exif pcntl bcmath gd zip intl
|
|
|
|
# Get latest Composer
|
|
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
|
|
|
|
# Set working directory
|
|
WORKDIR /var/www
|
|
|
|
# Copy existing application directory contents
|
|
COPY --chown=www-data:www-data . /var/www
|
|
|
|
# Change current user to www
|
|
USER www-data
|
|
|
|
# Expose port 8000 and start php-fpm server
|
|
EXPOSE 8000
|
|
CMD ["php", "artisan", "serve", "--host=0.0.0.0", "--port=8000"]
|