++ fix e controlli
This commit is contained in:
@@ -19,7 +19,26 @@ RUN composer install \
|
||||
--ignore-platform-reqs
|
||||
|
||||
# =============================================================================
|
||||
# Stage 2 — Frontend assets (Vite + Tailwind)
|
||||
# Stage 2 — PHP dependencies WITH dev (solo per la suite di test)
|
||||
#
|
||||
# Stesso composer.lock dello stage sopra, senza --no-dev: e' l'unico posto in
|
||||
# cui phpunit esiste. L'immagine di runtime non lo contiene di proposito, e non
|
||||
# deve iniziare a contenerlo — questo stage finisce solo nell'immagine `test`.
|
||||
# =============================================================================
|
||||
FROM composer:2 AS vendor-dev
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY composer.json composer.lock ./
|
||||
RUN composer install \
|
||||
--no-interaction \
|
||||
--prefer-dist \
|
||||
--no-progress \
|
||||
--no-scripts \
|
||||
--ignore-platform-reqs
|
||||
|
||||
# =============================================================================
|
||||
# Stage 3 — Frontend assets (Vite + Tailwind)
|
||||
# =============================================================================
|
||||
FROM node:20-alpine AS assets
|
||||
|
||||
@@ -40,15 +59,19 @@ COPY config ./config
|
||||
RUN npm run build
|
||||
|
||||
# =============================================================================
|
||||
# Stage 3 — Runtime
|
||||
# Stage 4 — Base di sistema (PHP + estensioni + nginx/supervisor)
|
||||
#
|
||||
# Condivisa da `runtime` e da `test`, cosi' la suite gira sulle stesse
|
||||
# estensioni e sullo stesso php.ini della produzione: un test che passa qui
|
||||
# non puo' passare grazie a un ambiente diverso da quello vero.
|
||||
# =============================================================================
|
||||
FROM php:8.3-fpm AS runtime
|
||||
FROM php:8.3-fpm AS base
|
||||
|
||||
# nginx + supervisor run in-image alongside php-fpm: a separate nginx container
|
||||
# would need its own copy of public/ plus the storage volume just to serve
|
||||
# static files, which is more moving parts than this app warrants.
|
||||
# poppler-utils provides pdftoppm/pdfinfo used by TerritorioThumbnailService.
|
||||
# Node is deliberately absent here: assets are built in stage 2.
|
||||
# Node is deliberately absent here: assets are built in the `assets` stage.
|
||||
# The -dev packages are kept rather than purged. Their runtime counterparts
|
||||
# are named per Debian release (libicu72 vs libicu76, libzip4 vs libzip5), so
|
||||
# purging means pinning package names that break whenever the php base image
|
||||
@@ -93,6 +116,56 @@ COPY docker/supervisor/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
|
||||
|
||||
WORKDIR /var/www/html
|
||||
|
||||
# =============================================================================
|
||||
# Stage 5 — Immagine di test
|
||||
#
|
||||
# Uguale al runtime tranne per il vendor, che qui include phpunit. Non monta
|
||||
# nessun volume: la suite gira su SQLite in memoria e cache `array`, quindi non
|
||||
# ha bisogno ne' di MariaDB ne' di Redis (vedi phpunit.xml).
|
||||
#
|
||||
# Si usa dal compose:
|
||||
# docker compose --profile test run --rm test
|
||||
# docker compose --profile test run --rm test --filter BackupArchiveTest
|
||||
# =============================================================================
|
||||
FROM base AS test
|
||||
|
||||
COPY --chown=www-data:www-data . .
|
||||
COPY --from=vendor-dev --chown=www-data:www-data /app/vendor ./vendor
|
||||
|
||||
RUN mkdir -p \
|
||||
storage/framework/cache/data \
|
||||
storage/framework/sessions \
|
||||
storage/framework/views \
|
||||
storage/logs \
|
||||
storage/app/public \
|
||||
bootstrap/cache \
|
||||
&& chown -R www-data:www-data storage bootstrap/cache \
|
||||
&& chmod -R 775 storage bootstrap/cache
|
||||
|
||||
# --optimize non e' un vezzo: senza classmap ogni risoluzione di classe diventa
|
||||
# un file_exists sul sorgente, che nel container di test arriva da un bind mount
|
||||
# (lento su Docker Desktop, lentissimo se il progetto sta in una cartella
|
||||
# sincronizzata). Misurato: 74s contro 13s sulla stessa suite. Le classi
|
||||
# aggiunte dopo il build non finiscono nella mappa ma restano raggiungibili dal
|
||||
# PSR-4, quindi un test nuovo non obbliga a ricostruire l'immagine.
|
||||
RUN composer dump-autoload --optimize --no-interaction \
|
||||
&& php artisan package:discover --ansi
|
||||
|
||||
# Sostituisce ENTRYPOINT/CMD di php:8.3-fpm: questo container non serve
|
||||
# richieste, esegue la suite e esce con il codice di phpunit. Gli argomenti
|
||||
# passati a `docker compose run test` arrivano direttamente a phpunit.
|
||||
ENTRYPOINT ["php", "vendor/bin/phpunit"]
|
||||
|
||||
# =============================================================================
|
||||
# Stage 6 — Runtime
|
||||
#
|
||||
# DEVE RESTARE L'ULTIMO STAGE DEL FILE. `docker build` senza --target costruisce
|
||||
# l'ultimo, ed e' cosi' che lo invocano sia docker-compose.yml (i tre servizi
|
||||
# non dichiarano `target`) sia Dokploy. Uno stage aggiunto qui sotto diventa in
|
||||
# silenzio l'immagine di produzione.
|
||||
# =============================================================================
|
||||
FROM base AS runtime
|
||||
|
||||
# Everything the app needs is baked into the image. Runtime containers do NOT
|
||||
# bind-mount the source, so there is no composer/npm work at boot.
|
||||
COPY --chown=www-data:www-data . .
|
||||
|
||||
Reference in New Issue
Block a user