laravel_initial/Dockerfile

79 lines
1.9 KiB
Docker

# Use official PHP 8.2 FPM image
FROM php:8.2-fpm
# Set working directory
WORKDIR /var/www/html
# Install dependencies
RUN apt-get update && apt-get install -y \
libpng-dev \
libjpeg-dev \
libfreetype6-dev \
netcat-openbsd \
zip \
unzip \
curl \
git \
libonig-dev \
libxml2-dev \
procps \
&& docker-php-ext-configure gd --with-freetype --with-jpeg \
&& docker-php-ext-install gd pdo pdo_mysql
# Copy the rest of Laravel files
COPY laravel/ .
# Install Composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
# Copy only essential files for better build caching
COPY laravel/composer.json laravel/composer.lock ./
RUN composer install --no-dev --optimize-autoloader
# Set permissions
RUN chown -R www-data:www-data /var/www/html
RUN chmod -R 775 /var/www/html/storage /var/www/html/bootstrap/cache
# Copy entrypoint script and make it executable
COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
# Set entrypoint script
ENTRYPOINT ["/entrypoint.sh"]
# Start PHP-FPM
CMD ["php-fpm"]
# FROM php:8.2-fpm
# RUN apt-get update && apt-get install -y \
# git \
# curl \
# libpng-dev \
# libonig-dev \
# libxml2-dev \
# zip \
# unzip \
# procps
# RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
# WORKDIR /var/www/html
# COPY ./laravel .
# RUN composer install --no-scripts --no-interaction
# RUN chown -R www-data:www-data /var/www/html
# RUN chmod -R 775 /var/www/html/storage
# # Install PDO MySQL (Fix for "Could not find driver" error)
# RUN docker-php-ext-install pdo pdo_mysql
# COPY entrypoint.sh /usr/local/bin/entrypoint.sh
# RUN chmod +x /usr/local/bin/entrypoint.sh
# ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
# CMD ["php-fpm"]