api/Dockerfile

37 lines
1017 B
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 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 apt-get update \
&& apt-get install -y php8.4-mysql \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# On récupère tout ce qui a été préparé dans létape build
COPY --from=build /var/www/html /var/www/html
# 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"]