Files
merchbay/Dockerfile
Frank John Begornia 0052044d6a
Some checks failed
Deploy Development / deploy (push) Failing after 4m26s
Update Dockerfile to use PHP 7.3 and improve compatibility with Laravel 5.0
2025-12-18 13:36:54 +08:00

76 lines
2.2 KiB
Docker
Executable File

# Use PHP 7.3 with Apache (compatible with Laravel 5.0)
FROM php:7.3-apache
# Install system dependencies
RUN apt-get update && apt-get install -y \
git \
curl \
libpng-dev \
libonig-dev \
libxml2-dev \
libzip-dev \
zip \
unzip \
libfreetype6-dev \
libjpeg62-turbo-dev \
openssh-client \
&& docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
&& docker-php-ext-install -j$(nproc) gd
# Install PHP extensions
RUN docker-php-ext-install pdo_mysql mbstring exif pcntl bcmath zip tokenizer
# Install mcrypt via PECL (required for Laravel 5.0)
RUN apt-get install -y libmcrypt-dev \
&& pecl install mcrypt-1.0.4 \
&& docker-php-ext-enable mcrypt
# Enable Apache mod_rewrite
RUN a2enmod rewrite
# Install Composer (version 1.x for better compatibility with Laravel 5.0)
COPY --from=composer:1.10 /usr/bin/composer /usr/bin/composer
# Set working directory
WORKDIR /var/www/html
# Copy existing application directory contents
COPY . /var/www/html
# Create storage directories and set permissions
RUN mkdir -p storage/framework/views \
storage/framework/cache \
storage/framework/sessions \
storage/logs \
bootstrap/cache
# Set proper ownership and permissions
RUN chown -R www-data:www-data /var/www/html \
&& chmod -R 775 /var/www/html/storage \
&& chmod -R 775 /var/www/html/bootstrap/cache
# Create .env file if it doesn't exist
RUN if [ ! -f .env ]; then cp .env.example .env; fi
# Install PHP dependencies (Laravel 5.0 compatible)
RUN composer install --no-dev --no-interaction --prefer-dist
# Generate application key
RUN php artisan key:generate || true
# Run Laravel 5.0 optimization
RUN php artisan clear-compiled && php artisan optimize
# Configure Apache DocumentRoot to point to Laravel's public directory
ENV APACHE_DOCUMENT_ROOT=/var/www/html/public
RUN sed -ri -e 's!/var/www/html!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/sites-available/*.conf
RUN sed -ri -e 's!/var/www/!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/apache2.conf /etc/apache2/conf-available/*.conf
# Suppress Apache ServerName warning
RUN echo "ServerName localhost" >> /etc/apache2/apache2.conf
# Expose port 80
EXPOSE 80
# Start Apache
CMD ["apache2-foreground"]