From 0af5d9587870c4874af3e7e6dae6b41b92f3aeb8 Mon Sep 17 00:00:00 2001 From: "maxime.rocher" Date: Wed, 5 Feb 2025 09:34:57 +0100 Subject: [PATCH] deploiement 7 --- .drone.yml | 9 ++++----- Docker/Dockerfile | 40 +++++++++++++++++++--------------------- 2 files changed, 23 insertions(+), 26 deletions(-) diff --git a/.drone.yml b/.drone.yml index 736c9f8..1e9ad41 100644 --- a/.drone.yml +++ b/.drone.yml @@ -25,7 +25,7 @@ steps: - dotnet test WF-WebAdmin.csproj --no-restore depends_on: [ build ] - # 3. CODE ANALYSIS (SONARQUBE) + # 3. CODE ANALYSIS (SONARQUBE) - Exemple, si tu utilises Sonar - name: code-analysis image: hub.codefirst.iut.uca.fr/marc.chevaldonne/codefirst-dronesonarplugin-dotnet8 commands: @@ -46,7 +46,7 @@ steps: coverage_exclusions: "Tests/**" depends_on: [ tests ] - # 4. GENERATION ET DEPLOIEMENT DE DOCS (OPTIONNEL) + # 4. GÉNÉRATION ET DÉPLOIEMENT DE DOCS (optionnel) - name: generate-and-deploy-docs image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-docdeployer failure: ignore @@ -60,7 +60,7 @@ steps: - master depends_on: [ build ] - # 5. CONSTRUCTION DE L'IMAGE DOCKER + # 5. BUILD DE L'IMAGE DOCKER ET PUSH - name: docker_build image: plugins/docker settings: @@ -75,9 +75,8 @@ steps: from_secret: docker_password depends_on: [ build, tests, code-analysis ] - # 6. DEPLOIEMENT + # 6. DEPLOY - name: deploy - # On réutilise l'image que l'on vient de builder et de pousser image: hub.codefirst.iut.uca.fr/whatthefantasy/wf-webadmin:latest commands: - ls /app diff --git a/Docker/Dockerfile b/Docker/Dockerfile index 11f153c..055b3a2 100644 --- a/Docker/Dockerfile +++ b/Docker/Dockerfile @@ -1,29 +1,27 @@ -# Étape 1 : Image de base ASP.NET pour le runtime -FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base -WORKDIR /app -EXPOSE 80 -EXPOSE 443 - -# Étape 2 : Build de l'application +# 1. Étape de build (SDK .NET 6) FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build WORKDIR /src -# Copier le fichier projet et restaurer les dépendances -COPY ["WF-WebAdmin/WF-WebAdmin/WF-WebAdmin.csproj", "./"] -RUN dotnet restore "WF-WebAdmin.csproj" - -# Copier tout le reste des fichiers et compiler -COPY WF-WebAdmin/WF-WebAdmin/. . -RUN dotnet build "WF-WebAdmin.csproj" -c Release -o /app/build +# Copier le csproj et restaurer les dépendances +COPY WF-WebAdmin/WF-WebAdmin/WF-WebAdmin.csproj ./ +RUN dotnet restore WF-WebAdmin.csproj -# Étape 3 : Publication de l'application -FROM build AS publish -RUN dotnet publish "WF-WebAdmin.csproj" -c Release -o /app/publish +# Copier le reste du code et compiler +COPY WF-WebAdmin/WF-WebAdmin/ ./ +RUN dotnet publish WF-WebAdmin.csproj -c Release -o /app/publish -# Étape 4 : Préparer l'image finale pour exécution -FROM base AS final +# 2. Étape finale (runtime .NET 6) +FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS final WORKDIR /app -COPY --from=publish /app/publish . -# Lancer l'application +# Désactiver le rechargement de config pour éviter les erreurs inotify +ENV ASPNETCORE_HOSTBUILDER__RELOADCONFIGONCHANGE=false + +# Copier les binaires publiés +COPY --from=build /app/publish ./ + +# Exposer le port HTTP (80) ; adapte si besoin +EXPOSE 80 + +# Lancement ENTRYPOINT ["dotnet", "WF-WebAdmin.dll"]