83 lines
2.1 KiB
Docker
83 lines
2.1 KiB
Docker
FROM php:8.3-fpm
|
|
|
|
# System dependencies
|
|
RUN apt-get update && apt-get install -y \
|
|
git \
|
|
curl \
|
|
netcat-openbsd \
|
|
libpng-dev \
|
|
libjpeg62-turbo-dev \
|
|
libfreetype6-dev \
|
|
libonig-dev \
|
|
libxml2-dev \
|
|
libzip-dev \
|
|
libicu-dev \
|
|
zip \
|
|
unzip \
|
|
supervisor \
|
|
&& docker-php-ext-configure gd --with-freetype --with-jpeg \
|
|
&& docker-php-ext-install \
|
|
pdo_mysql \
|
|
mbstring \
|
|
exif \
|
|
pcntl \
|
|
bcmath \
|
|
gd \
|
|
intl \
|
|
zip \
|
|
opcache \
|
|
&& pecl install redis \
|
|
&& docker-php-ext-enable redis \
|
|
&& apt-get clean \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# Install Composer
|
|
COPY --from=composer:2 /usr/bin/composer /usr/bin/composer
|
|
|
|
# Install Node.js 20 LTS
|
|
RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
|
|
&& apt-get install -y nodejs \
|
|
&& apt-get clean \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# Build application in staging area
|
|
WORKDIR /app-src
|
|
|
|
# Install PHP dependencies first for better Docker layer caching
|
|
COPY composer.json composer.lock ./
|
|
RUN composer install --no-interaction --prefer-dist --no-progress --no-scripts
|
|
|
|
# Install Node dependencies first for better Docker layer caching
|
|
COPY package.json package-lock.json* ./
|
|
RUN if [ -f package-lock.json ]; then \
|
|
npm ci --no-audit --no-fund; \
|
|
else \
|
|
npm install --no-audit --no-fund; \
|
|
fi
|
|
|
|
# Copy full source and build frontend assets
|
|
COPY . .
|
|
RUN mkdir -p bootstrap/cache storage/framework/cache storage/framework/sessions storage/framework/views storage/logs storage/app
|
|
RUN if [ ! -f .env ] && [ -f .env.example ]; then cp .env.example .env; fi
|
|
RUN date -u +%Y%m%d%H%M%S > .image-build-id
|
|
RUN composer dump-autoload --optimize --no-interaction
|
|
RUN npm run build
|
|
|
|
# Runtime working directory
|
|
WORKDIR /var/www/html
|
|
|
|
# Copy PHP configuration
|
|
COPY docker/php/php.ini /usr/local/etc/php/conf.d/custom.ini
|
|
|
|
# Copy PHP-FPM pool config
|
|
COPY docker/php/www.conf /usr/local/etc/php-fpm.d/www.conf
|
|
|
|
# Copy entrypoint
|
|
COPY docker/php/entrypoint.sh /usr/local/bin/entrypoint.sh
|
|
RUN chmod +x /usr/local/bin/entrypoint.sh
|
|
|
|
EXPOSE 9000
|
|
|
|
ENTRYPOINT ["entrypoint.sh"]
|
|
CMD ["php-fpm"]
|