FROM alpine:3.23

RUN apk add apache2

LABEL MAINTAINER="srivastava" VERSION="1.8" TP="3" 
# Ajout de métadonnées pour le mainteneur, la version et le numéro du TP

ENV SCHOOL="IUT" LEVEL="1.8" 
# Définition de variables d environnement pour l école et le niveau

EXPOSE 80
# Exposition du port 80 pour le serveur web

RUN apk add git && git clone https://github.com/MaximePIERRONT/beforeStage.git /tmp/repo && cp /tmp/repo/static-site.html /var/www/localhost/htdocs/static-site.html && rm -rf /tmp/repo && apk del git 
# Installation de git, clonage du dépôt, copie du fichier HTML dans le répertoire de l hôte web, suppression du dépôt et désinstallation de git

RUN sed -i 's/NOM PRENOM/SRIVASTAVA Emmanuel/g' /var/www/localhost/htdocs/static-site.html 
# Modification du fichier HTML pour remplacer "NOM PRENOM" par "SRIVASTAVA Emmanuel"

HEALTHCHECK --interval=1m --timeout=1s CMD wget --no-verbose --tries=1 --spider http://localhost/ || exit 1

CMD ["/usr/sbin/httpd", "-D", "FOREGROUND"]
# Commande pour démarrer le serveur Apache en mode premier plan