api/Dockerfile

49 lines
1.4 KiB
Docker
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# -----------------------------
# Étape 1 : build (composer)
# -----------------------------
FROM laravelsail/php84-composer AS build
WORKDIR /var/www/html
# On copie tout le projet (y compris artisan)
COPY . .
# Installation des dépendances PHP en mode production
RUN apt-get update && apt-get install -y libicu-dev \
&& docker-php-ext-configure intl \
&& docker-php-ext-install intl
RUN composer install --no-dev --no-interaction --prefer-dist --optimize-autoloader
# -----------------------------
# Étape 2 : image runtime
# -----------------------------
FROM laravelsail/php84-composer
WORKDIR /var/www/html
# 👉 Installation du driver MySQL pour PDO
RUN docker-php-ext-configure pdo_mysql --with-pdo-mysql=mysqlnd \
&& docker-php-ext-install pdo_mysql \
&& docker-php-ext-enable pdo_mysql \
&& php -m | grep -i pdo_mysql
# 👉 Installation de l'extension intl
RUN apt-get update && apt-get install -y libicu-dev \
&& docker-php-ext-configure intl \
&& docker-php-ext-install intl
# On récupère tout ce qui a été préparé dans létape build
COPY --from=build /var/www/html /var/www/html
# Création du symlink storage
RUN php artisan storage:link
# On désactive l'ENTRYPOINT par défaut de l'image de base
ENTRYPOINT []
# On expose le port HTTP du serveur Laravel
EXPOSE 80
# Commande de démarrage : serveur Laravel
CMD ["php", "artisan", "serve", "--host=0.0.0.0", "--port=80"]