1- # Stage 1: Compile Frontend Assets
2- FROM node:20-alpine AS node_builder
3-
4- WORKDIR /app/frontend
5-
6- # Copy package files and install dependencies
7- COPY package.json package-lock.json* ./
8- # Copy build configuration files
9- COPY webpack.mix.js tailwind.config.js postcss.config.js* .babelrc* ./
10- # Ensure postcss.config.js and .babelrc are optional by using *
11-
12- # Install dependencies for building assets
13- # Using npm ci for cleaner installs if package-lock.json is present and up-to-date
14- RUN npm ci --production
15-
16- # Copy frontend source code
17- COPY resources/js ./resources/js
18- COPY resources/css ./resources/css
19- COPY resources/img ./resources/img
20- # Add other resource directories if you have them (e.g., resources/fonts)
21-
22- # Compile assets
23- RUN npm run production
24-
25- # Stage 2: Setup PHP Application Environment
26- FROM webdevops/php-nginx:8.2-alpine AS app
27-
28- # Set working directory
29- # The webdevops images often use /app as the default document root for Nginx.
30- # We will set our application root to /var/www/html and ensure Nginx config reflects this.
31- WORKDIR /var/www/html
32-
33- # Install system dependencies and PHP extensions
34- # webdevops images are comprehensive. Many extensions are pre-installed or can be enabled via env vars.
35- # We'll ensure pdo_mysql, gd, zip, bcmath, exif, opcache, intl are available.
36- # The `docker-php-ext-install` approach should still work for missing extensions.
37- # $PHPIZE_DEPS are build dependencies for compiling extensions.
38- USER root
39- RUN apk add --no-cache --virtual .build-deps \
40- $PHPIZE_DEPS \
41- libzip-dev \
42- libpng-dev \
43- jpeg-dev \
44- freetype-dev \
45- && docker-php-ext-configure gd --with-freetype --with-jpeg \
46- && docker-php-ext-install -j$(nproc) gd pdo_mysql zip bcmath exif opcache intl \
47- && apk del .build-deps \
48- && rm -rf /var/cache/apk/*
49-
50- # Install Composer globally
51- COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
52-
53- # Copy application files (respecting .dockerignore)
54- COPY . .
55-
56- # Copy compiled assets from the node_builder stage
57- COPY --chown=www-data:www-data --from=node_builder /app/frontend/public ./public
58-
59- # Set permissions for Laravel storage and bootstrap cache
60- # Ensure these directories exist before chown/chmod if copying doesn't create them fully.
61- RUN mkdir -p storage/framework/sessions storage/framework/cache/data storage/framework/views storage/logs \
62- && chown -R www-data:www-data storage bootstrap/cache \
63- && chmod -R 775 storage bootstrap/cache
64-
65- # Copy Nginx site configuration
66- # webdevops images typically load *.conf from /etc/nginx/conf.d/
67- # Or their main vhost config (which includes /app as root) is often in /etc/nginx/vhost.conf or part of the main nginx.conf
68- # We will place our specific Laravel config in conf.d to be included.
69- # Ensure our nginx-site.conf sets the root to /var/www/html/public.
70- COPY nginx-site.conf /etc/nginx/conf.d/app.conf
71-
72- # Copy and set permissions for the deploy script
73- COPY deploy.sh /usr/local/bin/deploy.sh
74- RUN chmod +x /usr/local/bin/deploy.sh
75-
76- # Expose port 80
77- EXPOSE 80
1+ FROM php:8.4-fpm
2+ LABEL org.opencontainers.image.authors="stephen@stephenneal.net"
3+
4+ # Update OS && install utilities
5+ RUN apt-get update -y \
6+ && apt-get install -y \
7+ expect-dev \
8+ g++ \
9+ git \
10+ imagemagick \
11+ libgmp-dev \
12+ libfreetype6-dev \
13+ libicu-dev \
14+ libjpeg62-turbo-dev \
15+ libzip-dev \
16+ openssl \
17+ procps \
18+ sudo \
19+ supervisor \
20+ unzip \
21+ zip \
22+ zlib1g-dev
23+
24+ # Install Docker PHP extensions
25+ RUN docker-php-ext-configure intl \
26+ && docker-php-ext-configure gd \
27+ --with-freetype=/usr/include/ \
28+ --with-jpeg=/usr/include/ \
29+ && docker-php-ext-install -j$(nproc) gd \
30+ && docker-php-ext-install \
31+ gmp \
32+ intl \
33+ pcntl \
34+ pdo \
35+ pdo_mysql \
36+ zip
37+
38+ # Copy PHP configuration files
39+ COPY local.ini /usr/local/etc/php/conf.d/local.ini
40+ COPY www.conf /usr/local/etc/php-fpm.d/www.conf
0 commit comments