fix(laravel): align Composer build stage with app PHP version
Use php-cli matching phpVersion instead of composer:2 (PHP 8.5), skip artisan during dump-autoload, and fail loudly on composer install instead of swallowing lock-file/platform errors with || true. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -998,13 +998,15 @@ CMD ["sh", "-c", "if [ \\"$(cat /app/.mode)\\" = \\"standalone\\" ] && [ -f serv
|
|||||||
private laravelDockerfile(app: Application): string {
|
private laravelDockerfile(app: Application): string {
|
||||||
const phpVersion = app.phpVersion || '8.3';
|
const phpVersion = app.phpVersion || '8.3';
|
||||||
const port = app.port || 80;
|
const port = app.port || 80;
|
||||||
return `# --- Build stage ---
|
return `# --- Build stage (match production PHP version for Composer) ---
|
||||||
FROM composer:2 AS composer
|
FROM php:${phpVersion}-cli-alpine AS composer
|
||||||
|
RUN apk add --no-cache git unzip
|
||||||
|
COPY --from=composer:2 /usr/bin/composer /usr/bin/composer
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY composer.json composer.lock* ./
|
COPY composer.json composer.lock* ./
|
||||||
RUN composer install --no-dev --no-scripts --no-autoloader --prefer-dist || true
|
RUN composer install --no-dev --no-scripts --no-autoloader --prefer-dist --ignore-platform-reqs
|
||||||
COPY . .
|
COPY . .
|
||||||
RUN composer dump-autoload --optimize --no-dev
|
RUN composer dump-autoload --optimize --no-dev --no-scripts
|
||||||
|
|
||||||
# --- Production stage ---
|
# --- Production stage ---
|
||||||
FROM php:${phpVersion}-fpm-alpine
|
FROM php:${phpVersion}-fpm-alpine
|
||||||
|
|||||||
Reference in New Issue
Block a user