diff --git a/Dockerfile b/Dockerfile index 378b020..f5f7358 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,18 @@ # Utiliser une image de base légère FROM nginx:alpine +# Installer Git +RUN apk add --no-cache git + +# Cloner le dépôt GitLab dans le dossier /usr/share/nginx/html +RUN git clone http://lab.canguidev.fr/cangui/canguidev.git /usr/share/nginx/html + +# Copier le script d'update +COPY update.sh /usr/local/bin/update.sh +RUN chmod +x /usr/local/bin/update.sh + # Exposer le port 80 EXPOSE 80 -# Démarrer Nginx -CMD ["nginx", "-g", "daemon off;"] +# Mettre à jour le dépôt à chaque démarrage et lancer Nginx +CMD ["/bin/sh", "-c", "/usr/local/bin/update.sh && nginx -g 'daemon off;'"] diff --git a/docker-compose.yml b/docker-compose.yml index 13bc158..3da0aff 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,11 +4,10 @@ services: ports: - "8084:80" volumes: - - ./src:/usr/share/nginx/html # Synchroniser les modifications du dossier src + - ./src:/usr/share/nginx/html # Synchronisation locale (si nécessaire) networks: - npm-network networks: npm-network: external: true - diff --git a/update.sh b/update.sh new file mode 100644 index 0000000..bf39d44 --- /dev/null +++ b/update.sh @@ -0,0 +1,9 @@ +#!/bin/sh +cd /usr/share/nginx/html +if [ -d ".git" ]; then + echo "Updating repository..." + git pull origin main # Met à jour les fichiers à partir du dépôt GitLab +else + echo "Cloning repository..." + git clone https://gitlab.com/ton-utilisateur/ton-depot.git /usr/share/nginx/html +fi