Refactor Docker setup for Laravel 5.0 compatibility and optimize deployment process

- Updated Dockerfile configurations for various environments (alpine, basic, cloudrun, minimal, simple, test) to ensure compatibility with Laravel 5.0 and PHP 5.6.
- Added PHP compatibility documentation outlining mcrypt requirements and upgrade paths.
- Created cloudbuild.yaml for Google Cloud Build integration to streamline deployment to Cloud Run.
- Introduced docker-compose.local.yml for local development with MySQL and Redis services.
- Enhanced rebuild.sh script for easier local development and migration handling.
- Updated Laravel Blade views to correct asset paths.
- Added start-local.sh script for quick local setup and service management.
This commit is contained in:
Frank John Begornia
2025-08-11 23:14:31 +08:00
parent 70496dc874
commit 02c7f4e2aa
17 changed files with 1285 additions and 38 deletions

86
Dockerfile.minimal Normal file
View File

@@ -0,0 +1,86 @@
# Minimal Dockerfile for Laravel 5.0 with PHP 5.6
FROM php:5.6-apache
# Set working directory
WORKDIR /var/www/html
# Install only essential system dependencies
RUN apt-get update && apt-get install -y \
libmcrypt-dev \
libpng-dev \
libjpeg62-turbo-dev \
libfreetype6-dev \
zlib1g-dev \
zip \
unzip \
git \
curl \
&& docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
&& docker-php-ext-install \
pdo \
pdo_mysql \
mcrypt \
gd \
zip \
mbstring \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Install Composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
# Enable Apache modules
RUN a2enmod rewrite
RUN echo "ServerName localhost" >> /etc/apache2/apache2.conf
# Configure Apache document root for Laravel
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
# Simple Apache configuration
RUN echo '<VirtualHost *:80>\n\
DocumentRoot /var/www/html/public\n\
<Directory /var/www/html/public>\n\
AllowOverride All\n\
Require all granted\n\
</Directory>\n\
</VirtualHost>' > /etc/apache2/sites-available/000-default.conf
# Copy application files
COPY . /var/www/html/
# Fix Git ownership issue
RUN git config --global --add safe.directory /var/www/html || true
# Install PHP dependencies
RUN composer install --no-dev --optimize-autoloader --no-interaction
# Set proper permissions
RUN chown -R www-data:www-data /var/www/html \
&& chmod -R 755 /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 /var/www/html/.env ]; then \
cp /var/www/html/.env.example /var/www/html/.env; \
fi
# Switch to www-data for Laravel commands
USER www-data
RUN php artisan key:generate || true
USER root
# Create simple startup script
RUN echo '#!/bin/bash\n\
set -e\n\
echo "Starting Laravel application..."\n\
exec apache2-foreground' > /usr/local/bin/start.sh \
&& chmod +x /usr/local/bin/start.sh
# Expose port 80
EXPOSE 80
# Start Apache
CMD ["/usr/local/bin/start.sh"]