Add CI/CD workflows for building and deploying Docker images
Some checks failed
Deploy Development / deploy (push) Failing after 17s

This commit is contained in:
Frank John Begornia
2025-12-18 13:30:00 +08:00
parent f197490606
commit d6a98811eb
5 changed files with 379 additions and 67 deletions

View File

@@ -1,46 +1,71 @@
# Use the official PHP image based on Alpine Linux
FROM php:5.6-fpm-alpine
# Use PHP 7.4 with Apache (compatible with Laravel 5.2 and ARM64)
FROM php:7.4-apache
# Install system dependencies and PHP extensions
RUN apk --update --no-cache add \
nginx \
# Install system dependencies
RUN apt-get update && apt-get install -y \
git \
curl \
libpng-dev \
libjpeg-turbo-dev \
freetype-dev \
libonig-dev \
libxml2-dev \
libzip-dev \
zip \
unzip \
libmcrypt-dev \
libfreetype6-dev \
libjpeg62-turbo-dev \
openssh-client \
&& docker-php-ext-configure gd --with-freetype --with-jpeg \
&& docker-php-ext-install gd pdo pdo_mysql zip mcrypt
&& docker-php-ext-install -j$(nproc) gd
# Set the working directory in the container
WORKDIR /var/www
# Install PHP extensions
RUN docker-php-ext-install pdo_mysql mbstring exif pcntl bcmath zip
# Clear cache
# RUN apt-get clean && rm -rf /var/lib/apt/lists/*
# Copy the Laravel application files to the container
COPY . .
# Set appropriate permissions for Laravel storage and bootstrap cache
RUN chown -R www-data:www-data storage bootstrap
# Enable Apache mod_rewrite
RUN a2enmod rewrite
# Install Composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
COPY --from=composer:1.10 /usr/bin/composer /usr/bin/composer
# Install Laravel dependencies
RUN composer install --no-plugins --no-scripts
# Set working directory
WORKDIR /var/www/html
# Generate Laravel application key
# 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 without running post-install scripts
RUN composer install --no-dev --no-scripts --no-interaction
# Generate application key
RUN php artisan key:generate
# Create directory for the socket and set permissions
RUN mkdir -p /run/php && chown www-data:www-data /run/php
# Optimize autoloader
RUN composer dump-autoload --optimize --no-dev
# Copy the www.conf file to PHP-FPM pool.d directory
# COPY www.conf /usr/local/etc/php-fpm.d/www.conf
# 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
# Expose port 9000 and start php-fpm server
EXPOSE 9000
CMD ["php-fpm"]
# Suppress Apache ServerName warning
RUN echo "ServerName localhost" >> /etc/apache2/apache2.conf
# Expose port 80
EXPOSE 80
# Start Apache
CMD ["apache2-foreground"]