From 9603dbbb53c66ea826263663e2173374a5b9b728 Mon Sep 17 00:00:00 2001 From: "maxime.rocher" Date: Tue, 4 Feb 2025 10:30:14 +0100 Subject: [PATCH] test CI 3 --- .drone.yml | 59 +++++++++++++++++++++++++++++++++-------------- Docker/Dockerfile | 17 ++++++++++++++ 2 files changed, 59 insertions(+), 17 deletions(-) create mode 100644 Docker/Dockerfile diff --git a/.drone.yml b/.drone.yml index 0d42970..4e44234 100644 --- a/.drone.yml +++ b/.drone.yml @@ -1,23 +1,48 @@ kind: pipeline type: docker -name: deploy - -steps: - - name: Pull, tag and push existing Docker image - image: docker - environment: - DOCKER_USERNAME: - from_secret: docker_username - DOCKER_PASSWORD: - from_secret: docker_password - commands: - - docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD hub.codefirst.iut.uca.fr - - docker pull hub.codefirst.iut.uca.fr/marc.chevaldonne/codefirst-dotnet7-maui:latest - - docker tag hub.codefirst.iut.uca.fr/marc.chevaldonne/codefirst-dotnet7-maui:latest hub.codefirst.iut.uca.fr/marc.chevaldonne/codefirst-dotnet7-maui:deploy - - docker push hub.codefirst.iut.uca.fr/marc.chevaldonne/codefirst-dotnet7-maui:deploy +name: CI trigger: - branch: - - main event: - push + +steps: + - name: build + image: mcr.microsoft.com/dotnet/sdk:7.0 + commands: + - cd Sources/ + - dotnet restore MySolution.sln + - dotnet build MySolution.sln -c Release --no-restore + - dotnet publish WF-WebAdmin/WF-WebAdmin.csproj -c Release --no-restore -o $CI_PROJECT_DIR/build/publish + + - name: tests + image: mcr.microsoft.com/dotnet/sdk:7.0 + commands: + - cd Sources/ + - dotnet restore MySolution.sln + - dotnet test MySolution.sln --no-restore + depends_on: [build] + + - name: analyze + image: mcr.microsoft.com/dotnet/sdk:7.0 + commands: + - cd Sources/ + # Lancer l'analyse statique en forçant l'exécution des analyzers + - dotnet build MySolution.sln -c Release --no-restore /p:RunAnalyzers=true + depends_on: [build] + + - name: docker_build + image: plugins/docker + settings: + # Nom de l'image Docker qui hébergera votre application Blazor + repo: hub.codefirst.iut.uca.fr/marc.chevaldonne/your-blazor-app + # Dockerfile pour construire l'image (placé à la racine de votre dépôt) + dockerfile: Dockerfile + tags: + - latest + # Secrets pour l'authentification sur votre registry (à configurer dans Drone) + username: + from_secret: docker_username + password: + from_secret: docker_password + depends_on: [build, tests, analyze] diff --git a/Docker/Dockerfile b/Docker/Dockerfile new file mode 100644 index 0000000..8b30a39 --- /dev/null +++ b/Docker/Dockerfile @@ -0,0 +1,17 @@ +# Étape de base avec l'image runtime ASP.NET +FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS base +WORKDIR /app +EXPOSE 80 + +# Étape de build pour publier l'application +FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build +WORKDIR /src +COPY . . +RUN dotnet restore "YourBlazorApp/YourBlazorApp.csproj" +RUN dotnet publish "YourBlazorApp/YourBlazorApp.csproj" -c Release -o /app/publish + +# Étape finale : copie des fichiers publiés et définition du point d'entrée +FROM base AS final +WORKDIR /app +COPY --from=build /app/publish . +ENTRYPOINT ["dotnet", "YourBlazorApp.dll"]