73 lines
2 KiB
Docker
73 lines
2 KiB
Docker
# Multi-stage build for Laravel + Vue/Inertia application
|
|
FROM php:8.3-fpm-alpine AS base
|
|
|
|
# Install system dependencies
|
|
RUN apk add --no-cache \
|
|
git \
|
|
curl \
|
|
libpng-dev \
|
|
libzip-dev \
|
|
zip \
|
|
unzip \
|
|
postgresql-dev \
|
|
nodejs \
|
|
npm \
|
|
nginx \
|
|
supervisor
|
|
|
|
# Install PHP extensions
|
|
RUN docker-php-ext-install pdo pdo_pgsql pgsql zip gd
|
|
|
|
# Configure PHP for large file uploads
|
|
RUN echo "upload_max_filesize = 550M" >> /usr/local/etc/php/conf.d/uploads.ini && \
|
|
echo "post_max_size = 550M" >> /usr/local/etc/php/conf.d/uploads.ini && \
|
|
echo "max_execution_time = 300" >> /usr/local/etc/php/conf.d/uploads.ini && \
|
|
echo "max_input_time = 300" >> /usr/local/etc/php/conf.d/uploads.ini && \
|
|
echo "memory_limit = 512M" >> /usr/local/etc/php/conf.d/uploads.ini
|
|
|
|
# Install Composer
|
|
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
|
|
|
|
# Set working directory
|
|
WORKDIR /var/www/html
|
|
|
|
# Copy composer files
|
|
COPY composer.json ./
|
|
|
|
# Install PHP dependencies (generate composer.lock if missing)
|
|
RUN composer install --no-dev --optimize-autoloader --no-scripts --no-interaction
|
|
|
|
# Copy package files
|
|
COPY package.json ./
|
|
|
|
# Install Node dependencies (generate package-lock.json if missing)
|
|
RUN npm install --legacy-peer-deps
|
|
|
|
# Copy application files
|
|
COPY . .
|
|
|
|
# Build frontend assets
|
|
RUN npm run build
|
|
|
|
# Generate optimized autoload files
|
|
RUN composer dump-autoload --optimize
|
|
|
|
# Create log directory for supervisor
|
|
RUN mkdir -p /var/log/supervisor
|
|
|
|
# Set permissions
|
|
RUN chown -R www-data:www-data /var/www/html/storage /var/www/html/bootstrap/cache
|
|
RUN chmod -R 775 /var/www/html/storage /var/www/html/bootstrap/cache
|
|
|
|
# Copy nginx configuration
|
|
COPY docker/nginx.conf /etc/nginx/nginx.conf
|
|
COPY docker/default.conf /etc/nginx/http.d/default.conf
|
|
|
|
# Copy supervisor configuration
|
|
COPY docker/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
|
|
|
|
# Expose port 80
|
|
EXPOSE 80
|
|
|
|
# Start supervisor
|
|
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]
|