2026-08-16 00:57:07 +02:00
|
|
|
# Multi-stage build for Laravel + Livewire application
|
2025-07-13 12:10:09 +02:00
|
|
|
FROM node:20-alpine AS frontend-builder
|
|
|
|
|
|
|
|
|
|
WORKDIR /app
|
|
|
|
|
|
|
|
|
|
# Copy package files
|
|
|
|
|
COPY package*.json ./
|
|
|
|
|
|
|
|
|
|
# Install Node dependencies
|
2026-05-02 11:29:26 +02:00
|
|
|
RUN npm ci
|
2025-07-13 12:10:09 +02:00
|
|
|
|
|
|
|
|
# Copy frontend source
|
|
|
|
|
COPY resources/ resources/
|
|
|
|
|
COPY public/ public/
|
|
|
|
|
COPY vite.config.ts ./
|
|
|
|
|
|
|
|
|
|
# Build frontend assets
|
|
|
|
|
RUN npm run build
|
|
|
|
|
|
|
|
|
|
# PHP runtime stage
|
2026-05-02 11:29:26 +02:00
|
|
|
FROM php:8.3-fpm-alpine
|
2025-07-13 12:10:09 +02:00
|
|
|
|
2026-08-16 13:12:25 +02:00
|
|
|
# mysql-client backs the database readiness loop in start-app.sh.
|
2025-07-13 12:10:09 +02:00
|
|
|
RUN apk add --no-cache \
|
|
|
|
|
curl \
|
|
|
|
|
zip \
|
|
|
|
|
unzip \
|
2025-07-15 20:36:49 +02:00
|
|
|
mysql-client \
|
|
|
|
|
nginx \
|
|
|
|
|
supervisor
|
2025-07-13 12:10:09 +02:00
|
|
|
|
2026-08-16 13:12:25 +02:00
|
|
|
# Prebuilt binaries rather than docker-php-ext-install: compiling these under
|
|
|
|
|
# QEMU for the arm64 image dominated the build time.
|
|
|
|
|
COPY --from=mlocati/php-extension-installer:2 /usr/bin/install-php-extensions /usr/local/bin/
|
|
|
|
|
|
|
|
|
|
RUN install-php-extensions \
|
2025-07-13 12:10:09 +02:00
|
|
|
pdo_mysql \
|
|
|
|
|
mbstring \
|
|
|
|
|
pcntl \
|
|
|
|
|
bcmath \
|
|
|
|
|
gd
|
|
|
|
|
|
|
|
|
|
# Install Composer
|
2026-08-16 13:12:25 +02:00
|
|
|
COPY --from=composer:2 /usr/bin/composer /usr/bin/composer
|
2025-07-13 12:10:09 +02:00
|
|
|
|
|
|
|
|
# Set working directory
|
|
|
|
|
WORKDIR /var/www/html
|
|
|
|
|
|
2026-08-16 13:12:25 +02:00
|
|
|
# Dependencies before the source, so a code change does not reinstall vendor.
|
|
|
|
|
# --no-scripts because package discovery needs the full application.
|
|
|
|
|
COPY composer.json composer.lock ./
|
|
|
|
|
RUN composer install --no-dev --optimize-autoloader --no-interaction --no-scripts
|
|
|
|
|
|
2025-07-13 12:10:09 +02:00
|
|
|
COPY . .
|
|
|
|
|
|
2026-08-16 13:12:25 +02:00
|
|
|
# dump-autoload triggers post-autoload-dump, which runs package:discover.
|
|
|
|
|
RUN composer dump-autoload --optimize --no-interaction
|
2025-07-13 12:10:09 +02:00
|
|
|
|
|
|
|
|
# Copy built frontend assets from builder stage
|
|
|
|
|
COPY --from=frontend-builder /app/public/build/ ./public/build/
|
|
|
|
|
|
2025-07-15 20:36:49 +02:00
|
|
|
# Copy nginx and supervisor configurations
|
2026-05-02 11:29:26 +02:00
|
|
|
COPY docker/production/nginx.conf /etc/nginx/http.d/default.conf
|
|
|
|
|
COPY docker/production/supervisord.conf /etc/supervisord.conf
|
|
|
|
|
COPY docker/production/start-app.sh /usr/local/bin/start-app
|
2025-07-15 20:36:49 +02:00
|
|
|
|
2025-07-13 12:10:09 +02:00
|
|
|
# Set proper permissions
|
2025-07-13 19:50:56 +02:00
|
|
|
RUN chown -R www-data:www-data storage bootstrap/cache public/build \
|
2025-07-15 20:36:49 +02:00
|
|
|
&& chmod -R 755 storage bootstrap/cache \
|
2025-07-13 12:10:09 +02:00
|
|
|
&& chmod +x /usr/local/bin/start-app
|
|
|
|
|
|
2025-07-15 20:36:49 +02:00
|
|
|
# Expose port 80 for nginx
|
|
|
|
|
EXPOSE 80
|
2025-07-13 12:10:09 +02:00
|
|
|
|
|
|
|
|
# Health check
|
|
|
|
|
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
|
|
|
|
|
CMD php artisan --version || exit 1
|
|
|
|
|
|
|
|
|
|
# Start the application
|
2025-07-13 19:50:56 +02:00
|
|
|
CMD ["/usr/local/bin/start-app"]
|