Files
hub/Dockerfile
CI Trigger 04f09f2cd4
Some checks failed
ci/woodpecker/push/ci Pipeline failed
ci: use local registry for all base images
Switch from mirror.gcr.io to local registry (10.100.9.70:5000):
- All CI step images now pull from local registry
- Dockerfile base images pull from local registry
- No more external pulls during builds
- Daily cron job updates local cache from Google mirror

Images cached locally:
- node:22-alpine, node:22-slim, node:20-alpine
- php:8.4-cli-alpine, php:8.3-fpm-alpine
- composer:2.8, nginx:alpine, busybox
- laravel-test-runner, drone-cache, kubectl, kaniko
2025-12-15 18:33:05 -07:00

156 lines
4.7 KiB
Docker

# ============================================
# Production Laravel Dockerfile (Multi-stage)
# ============================================
# ==================== Stage 1: Node Builder ====================
FROM 10.100.9.70:5000/library/node:22-alpine AS node-builder
WORKDIR /app
# Accept Vite environment variables as build arguments
ARG VITE_REVERB_APP_KEY
ARG VITE_REVERB_HOST
ARG VITE_REVERB_PORT=443
ARG VITE_REVERB_SCHEME=https
# Export as environment variables for Vite build
ENV VITE_REVERB_APP_KEY=${VITE_REVERB_APP_KEY}
ENV VITE_REVERB_HOST=${VITE_REVERB_HOST}
ENV VITE_REVERB_PORT=${VITE_REVERB_PORT}
ENV VITE_REVERB_SCHEME=${VITE_REVERB_SCHEME}
# Copy package files
COPY package*.json ./
# Install ALL dependencies (including dev) for building
RUN npm ci
# Copy frontend assets
COPY resources ./resources
COPY vite.config.js tailwind.config.js ./
COPY public ./public
# Build frontend assets (Vite will inline VITE_* env vars)
RUN npm run build
# ==================== Stage 2: Composer Builder ====================
# Pin to PHP 8.4 - composer:2 uses latest PHP which may not be supported by dependencies yet
FROM 10.100.9.70:5000/library/php:8.4-cli-alpine AS composer-builder
# Install Composer
COPY --from=10.100.9.70:5000/library/composer:2.8 /usr/bin/composer /usr/bin/composer
WORKDIR /app
# Install required PHP extensions for Filament and Horizon
RUN apk add --no-cache icu-dev libpng-dev libjpeg-turbo-dev freetype-dev libzip-dev \
&& docker-php-ext-configure gd --with-freetype --with-jpeg \
&& docker-php-ext-install intl gd pcntl zip
# Copy composer files
COPY composer.json composer.lock ./
# Install dependencies (production only, optimized autoloader)
RUN composer install \
--no-dev \
--no-interaction \
--no-scripts \
--no-progress \
--prefer-dist \
--optimize-autoloader
# ==================== Stage 3: Production Runtime ====================
FROM 10.100.9.70:5000/library/php:8.3-fpm-alpine
LABEL maintainer="CannaBrands Team"
# Install system dependencies
RUN apk add --no-cache \
nginx \
supervisor \
postgresql-dev \
libpng-dev \
libjpeg-turbo-dev \
freetype-dev \
libzip-dev \
icu-dev \
icu-data-full \
zip \
unzip \
git \
curl \
bash
# Install build dependencies for PHP extensions
RUN apk add --no-cache --virtual .build-deps \
autoconf \
g++ \
make
# Install PHP extensions
RUN docker-php-ext-configure gd --with-freetype --with-jpeg \
&& docker-php-ext-install -j$(nproc) \
pdo_pgsql \
pgsql \
gd \
zip \
intl \
pcntl \
bcmath \
opcache
# Install Redis extension
RUN pecl install redis \
&& docker-php-ext-enable redis \
&& apk del .build-deps
# Accept build arguments for version tracking
ARG GIT_COMMIT_SHA=unknown
ARG APP_VERSION=dev
# Set working directory
WORKDIR /var/www/html
# Copy application code
COPY --chown=www-data:www-data . .
# Copy built assets from node-builder
COPY --from=node-builder --chown=www-data:www-data /app/public/build ./public/build
# Copy vendor from composer-builder
COPY --from=composer-builder --chown=www-data:www-data /app/vendor ./vendor
# Note: Asset publishing runs in init container at runtime (not build time)
# Artisan commands require environment variables which aren't available during build
# Create version metadata file
RUN echo "VERSION=${APP_VERSION}" > /var/www/html/version.env && \
echo "COMMIT=${GIT_COMMIT_SHA}" >> /var/www/html/version.env && \
chown www-data:www-data /var/www/html/version.env
# Copy production configurations
COPY docker/production/nginx/default.conf /etc/nginx/http.d/default.conf
COPY docker/production/supervisor/supervisord.conf /etc/supervisor/supervisord.conf
COPY docker/production/php/php.ini /usr/local/etc/php/conf.d/99-custom.ini
# Remove default PHP-FPM pool config and use our custom one
RUN rm -f /usr/local/etc/php-fpm.d/www.conf /usr/local/etc/php-fpm.d/www.conf.default
COPY docker/production/php/php-fpm.conf /usr/local/etc/php-fpm.d/www.conf
# Create directories
RUN mkdir -p /var/www/html/storage/framework/{sessions,views,cache} \
&& mkdir -p /var/www/html/storage/logs \
&& mkdir -p /var/www/html/bootstrap/cache \
&& mkdir -p /var/log/supervisor \
&& chown -R www-data:www-data /var/www/html/storage /var/www/html/bootstrap/cache \
&& chmod -R 775 /var/www/html/storage /var/www/html/bootstrap/cache
# Note: Skip Laravel caching at build time since runtime config will be different
# Cache will be generated at runtime with actual environment variables
# Expose port
EXPOSE 80
# Start supervisor (manages nginx + php-fpm + queue workers)
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/supervisord.conf"]