From 5aa2453b794e3be6973c414b4f6f0f6b1015226f Mon Sep 17 00:00:00 2001 From: "lilian.breton" Date: Mon, 19 Dec 2022 09:36:03 +0100 Subject: [PATCH 01/28] add CI/CD --- myBlazorApp/myBlazorApp/.drone.yml | 96 +++++----------------- myBlazorApp/myBlazorApp/Dockerfile | 49 ++++++----- myBlazorApp/myBlazorApp/myBlazorApp.csproj | 2 +- 3 files changed, 46 insertions(+), 101 deletions(-) diff --git a/myBlazorApp/myBlazorApp/.drone.yml b/myBlazorApp/myBlazorApp/.drone.yml index e390d08..96e212d 100644 --- a/myBlazorApp/myBlazorApp/.drone.yml +++ b/myBlazorApp/myBlazorApp/.drone.yml @@ -1,76 +1,24 @@ kind: pipeline type: docker - - -#steps : - -# - name: build -# image: mcr.microsoft.com/dotnet/sdk:6.0 -# commands: -# - cd myBlazorApp/ -# - dotnet restore myBlazorApp.sln -# - dotnet build myBlazorApp.sln -c Release --no-restore - - -# - name: tests -# image: mcr.microsoft.com/dotnet/sdk:6.0 -# commands: -# - cd myBlazorApp/ -# - dotnet restore myBlazorApp.sln -# - dotnet test myBlazorApp.sln --no-restore -# depends_on: [build] - -# - name: code-analysis -# image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-dronesonarplugin-dotnet6 -# commands: -# - cd myBlazorApp/ -# - dotnet restore myBlazorApp.sln -# - dotnet sonarscanner begin /k:$REPO_NAME /d:sonar.host.url=$$$${PLUGIN_SONAR_HOST} /d:sonar.coverageReportPaths="coveragereport/SonarQube.xml" /d:sonar.coverage.exclusions="Tests/**" /d:sonar.login=$$$${PLUGIN_SONAR_TOKEN} -# - dotnet build myBlazorApp.sln -c Release --no-restore -# - dotnet test myBlazorApp.sln --logger trx --no-restore /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura --collect "XPlat Code Coverage" -# - reportgenerator -reports:"**/coverage.cobertura.xml" -reporttypes:SonarQube -targetdir:"coveragereport" -# - dotnet publish myBlazorApp.sln -c Release --no-restore -o $CI_PROJECT_DIR/build/release -# - dotnet sonarscanner end /d:sonar.login=$$$${PLUGIN_SONAR_TOKEN} -# secrets: [ SECRET_SONAR_LOGIN ] -# settings: -# # accessible en ligne de commande par $${PLUGIN_SONAR_HOST} -# sonar_host: https://codefirst.iut.uca.fr/sonar/ -# # accessible en ligne de commande par $${PLUGIN_SONAR_TOKEN} -# sonar_token: -# from_secret: SECRET_SONAR_LOGIN -# depends_on: [tests] - - -## - name: generate-and-deploy-docs -## image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-docdeployer -## failure: ignore -## volumes: -## - name: docs -## path: /docs -## commands: -## - /entrypoint.sh -## when: -## branch: -## - master -## depends_on: [ build ] - -### The volumes declaration appear at the end of the file, after all steps -##volumes: -##- name: docs -## temp: {} - - -# - name: docker-build -# image: plugins/docker -# settings: -# dockerfile: myBlazorApp/myBlazorApp/Dockerfile -# context: . -# registry: hub.codefirst.iut.uca.fr -# repo: hub.codefirst.iut.uca.fr/lucie.bedouret/blazorCourse -# username: -# from_secret: SECRET_REGISTRY_USERNAME -# password: -# from_secret: SECRET_REGISTRY_PASSWORD -# when: -# branch: -# - master \ No newline at end of file +name: blazor + +trigger: + event: + - push + +steps: + - name: build + image: mcr.microsoft.com/dotnet/sdk:6.0 + commands: + - cd ../ + - dotnet restore myBlazorApp.sln + - dotnet build myBlazorApp.sln -c Release --no-restore + + + - name: tests + image: mcr.microsoft.com/dotnet/sdk:6.0 + commands: + - cd ../ + - dotnet restore myBlazorApp.sln + - dotnet test myBlazorApp.sln --no-restore + diff --git a/myBlazorApp/myBlazorApp/Dockerfile b/myBlazorApp/myBlazorApp/Dockerfile index af5bca8..d2ec007 100644 --- a/myBlazorApp/myBlazorApp/Dockerfile +++ b/myBlazorApp/myBlazorApp/Dockerfile @@ -1,26 +1,23 @@ -##See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging. -# -##Depending on the operating system of the host machines(s) that will build or run the containers, the image specified in the FROM statement may need to be changed. -##For more information, please see https://aka.ms/containercompat -# -#FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base -#WORKDIR /app -#EXPOSE 80 -#EXPOSE 443 -# -#FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build -#WORKDIR /src -#COPY ["nuget.config", "."] -#COPY ["myBlazorApp/myBlazorApp.csproj", "myBlazorApp/"] -#RUN dotnet restore "myBlazorApp/myBlazorApp.csproj" -#COPY . . -#WORKDIR "/src/myBlazorApp" -#RUN dotnet build "myBlazorApp.csproj" -c Release -o /app/build -# -#FROM build AS publish -#RUN dotnet publish "myBlazorApp.csproj" -c Release -o /app/publish -# -#FROM base AS final -#WORKDIR /app -#COPY --from=publish /app/publish . -#ENTRYPOINT ["dotnet", "myBlazorApp.dll"] \ No newline at end of file +#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging. + +FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base +WORKDIR /app +EXPOSE 80 +EXPOSE 443 + +FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build +WORKDIR /src +COPY ["nuget.config", "."] +COPY ["myBlazorApp/myBlazorApp.csproj", "myBlazorApp/"] +RUN dotnet restore "myBlazorApp/myBlazorApp.csproj" +COPY . . +WORKDIR "/src/myBlazorApp" +RUN dotnet build "myBlazorApp.csproj" -c Release -o /app/build + +FROM build AS publish +RUN dotnet publish "myBlazorApp.csproj" -c Release -o /app/publish /p:UseAppHost=false + +FROM base AS final +WORKDIR /app +COPY --from=publish /app/publish . +ENTRYPOINT ["dotnet", "myBlazorApp.dll"] \ No newline at end of file diff --git a/myBlazorApp/myBlazorApp/myBlazorApp.csproj b/myBlazorApp/myBlazorApp/myBlazorApp.csproj index a37021c..28142bc 100644 --- a/myBlazorApp/myBlazorApp/myBlazorApp.csproj +++ b/myBlazorApp/myBlazorApp/myBlazorApp.csproj @@ -5,7 +5,7 @@ enable enable 57709e34-c352-46a7-8d9f-219f603ebc3d - Windows + Linux From 24ce700e0fd63213b42b44a13efad0894fc47202 Mon Sep 17 00:00:00 2001 From: "lilian.breton" Date: Mon, 19 Dec 2022 09:38:55 +0100 Subject: [PATCH 02/28] fix .drone.yml file --- myBlazorApp/myBlazorApp/.drone.yml => .drone.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) rename myBlazorApp/myBlazorApp/.drone.yml => .drone.yml (99%) diff --git a/myBlazorApp/myBlazorApp/.drone.yml b/.drone.yml similarity index 99% rename from myBlazorApp/myBlazorApp/.drone.yml rename to .drone.yml index 96e212d..f3b4807 100644 --- a/myBlazorApp/myBlazorApp/.drone.yml +++ b/.drone.yml @@ -1,7 +1,7 @@ -kind: pipeline -type: docker -name: blazor - +kind: pipeline +type: docker +name: blazor + trigger: event: - push From a6ae6b5e796760fe805a86553bfb6645c8563e38 Mon Sep 17 00:00:00 2001 From: Lilian BRETON Date: Mon, 19 Dec 2022 09:40:21 +0100 Subject: [PATCH 03/28] Update '.drone.yml' --- .drone.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.drone.yml b/.drone.yml index f3b4807..f2a12d5 100644 --- a/.drone.yml +++ b/.drone.yml @@ -3,8 +3,8 @@ type: docker name: blazor trigger: - event: - - push + event: + - push steps: - name: build From aa6ba2e04ad7537353a521f77deaacf10fe72b39 Mon Sep 17 00:00:00 2001 From: Lilian BRETON Date: Mon, 19 Dec 2022 09:41:18 +0100 Subject: [PATCH 04/28] Update '.drone.yml' --- .drone.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.drone.yml b/.drone.yml index f2a12d5..246841a 100644 --- a/.drone.yml +++ b/.drone.yml @@ -1,10 +1,9 @@ kind: pipeline type: docker name: blazor - trigger: - event: - - push + - event: + - push steps: - name: build From e82cf089fd89cc4ae3d410b82c1c1b8de0a4f038 Mon Sep 17 00:00:00 2001 From: Lilian BRETON Date: Mon, 19 Dec 2022 09:41:57 +0100 Subject: [PATCH 05/28] Update '.drone.yml' --- .drone.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.drone.yml b/.drone.yml index 246841a..84fd67c 100644 --- a/.drone.yml +++ b/.drone.yml @@ -6,12 +6,12 @@ trigger: - push steps: - - name: build - image: mcr.microsoft.com/dotnet/sdk:6.0 - commands: - - cd ../ - - dotnet restore myBlazorApp.sln - - dotnet build myBlazorApp.sln -c Release --no-restore + - name: build + image: mcr.microsoft.com/dotnet/sdk:6.0 + commands: + - cd ../ + - dotnet restore myBlazorApp.sln + - dotnet build myBlazorApp.sln -c Release --no-restore - name: tests From 4650b006d9958e9a5cc15b0c4ad32c40d44a69de Mon Sep 17 00:00:00 2001 From: Lilian BRETON Date: Mon, 19 Dec 2022 09:42:23 +0100 Subject: [PATCH 06/28] Update '.drone.yml' --- .drone.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.drone.yml b/.drone.yml index 84fd67c..246841a 100644 --- a/.drone.yml +++ b/.drone.yml @@ -6,12 +6,12 @@ trigger: - push steps: - - name: build - image: mcr.microsoft.com/dotnet/sdk:6.0 - commands: - - cd ../ - - dotnet restore myBlazorApp.sln - - dotnet build myBlazorApp.sln -c Release --no-restore + - name: build + image: mcr.microsoft.com/dotnet/sdk:6.0 + commands: + - cd ../ + - dotnet restore myBlazorApp.sln + - dotnet build myBlazorApp.sln -c Release --no-restore - name: tests From 736022e2d5300a2cc6807a1f3bcc45b7babb504c Mon Sep 17 00:00:00 2001 From: Lilian BRETON Date: Mon, 19 Dec 2022 09:43:08 +0100 Subject: [PATCH 07/28] Update '.drone.yml' --- .drone.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.drone.yml b/.drone.yml index 246841a..2bd067a 100644 --- a/.drone.yml +++ b/.drone.yml @@ -7,9 +7,9 @@ trigger: steps: - name: build - image: mcr.microsoft.com/dotnet/sdk:6.0 - commands: - - cd ../ + image: mcr.microsoft.com/dotnet/sdk:6.0 + commands: + - cd ../ - dotnet restore myBlazorApp.sln - dotnet build myBlazorApp.sln -c Release --no-restore From 37708f2bb1b2beaab24ba92ea9fb4b5176e8fbec Mon Sep 17 00:00:00 2001 From: Lilian BRETON Date: Mon, 19 Dec 2022 09:43:34 +0100 Subject: [PATCH 08/28] Update '.drone.yml' --- .drone.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.drone.yml b/.drone.yml index 2bd067a..82adb06 100644 --- a/.drone.yml +++ b/.drone.yml @@ -10,8 +10,8 @@ steps: image: mcr.microsoft.com/dotnet/sdk:6.0 commands: - cd ../ - - dotnet restore myBlazorApp.sln - - dotnet build myBlazorApp.sln -c Release --no-restore + - dotnet restore myBlazorApp.sln + - dotnet build myBlazorApp.sln -c Release --no-restore - name: tests From d6a3ccce5f42f4a36c2a6df5f355d12c40208099 Mon Sep 17 00:00:00 2001 From: Lilian BRETON Date: Mon, 19 Dec 2022 09:44:16 +0100 Subject: [PATCH 09/28] Update '.drone.yml' --- .drone.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.drone.yml b/.drone.yml index 82adb06..e8bb12e 100644 --- a/.drone.yml +++ b/.drone.yml @@ -17,7 +17,6 @@ steps: - name: tests image: mcr.microsoft.com/dotnet/sdk:6.0 commands: - - cd ../ - - dotnet restore myBlazorApp.sln - - dotnet test myBlazorApp.sln --no-restore - + - cd ../ + - dotnet restore myBlazorApp.sln + - dotnet test myBlazorApp.sln --no-restore \ No newline at end of file From ed1178d6b5e88aaeb7693c5a49d2341bc37afdc2 Mon Sep 17 00:00:00 2001 From: Lilian BRETON Date: Mon, 19 Dec 2022 09:45:58 +0100 Subject: [PATCH 10/28] Update '.drone.yml' --- .drone.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.drone.yml b/.drone.yml index e8bb12e..3d26bd7 100644 --- a/.drone.yml +++ b/.drone.yml @@ -5,6 +5,7 @@ trigger: - event: - push +# build image steps: - name: build image: mcr.microsoft.com/dotnet/sdk:6.0 From 7839b15b42503f58ce85f3f20d39646adbf0fe76 Mon Sep 17 00:00:00 2001 From: Lilian BRETON Date: Mon, 19 Dec 2022 09:47:47 +0100 Subject: [PATCH 11/28] Update '.drone.yml' --- .drone.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index 3d26bd7..e8bb12e 100644 --- a/.drone.yml +++ b/.drone.yml @@ -5,7 +5,6 @@ trigger: - event: - push -# build image steps: - name: build image: mcr.microsoft.com/dotnet/sdk:6.0 From 52ab5c1395092e283a59ee129fa0a8da0138efff Mon Sep 17 00:00:00 2001 From: Lilian BRETON Date: Mon, 19 Dec 2022 09:48:20 +0100 Subject: [PATCH 12/28] Update '.drone.yml' --- .drone.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.drone.yml b/.drone.yml index e8bb12e..a6a56dd 100644 --- a/.drone.yml +++ b/.drone.yml @@ -15,8 +15,8 @@ steps: - name: tests - image: mcr.microsoft.com/dotnet/sdk:6.0 - commands: + image: mcr.microsoft.com/dotnet/sdk:6.0 + commands: - cd ../ - dotnet restore myBlazorApp.sln - dotnet test myBlazorApp.sln --no-restore \ No newline at end of file From ce8a676e4bad8dac234438e7503a4c5177b8a6b3 Mon Sep 17 00:00:00 2001 From: Lilian BRETON Date: Mon, 19 Dec 2022 09:48:47 +0100 Subject: [PATCH 13/28] Update '.drone.yml' --- .drone.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index a6a56dd..d97216c 100644 --- a/.drone.yml +++ b/.drone.yml @@ -15,7 +15,7 @@ steps: - name: tests - image: mcr.microsoft.com/dotnet/sdk:6.0 + image: mcr.microsoft.com/dotnet/sdk:6.0 commands: - cd ../ - dotnet restore myBlazorApp.sln From dd8dbedf7070c3dfccdd7d30c0efcf73c9822665 Mon Sep 17 00:00:00 2001 From: Lilian BRETON Date: Mon, 19 Dec 2022 09:49:06 +0100 Subject: [PATCH 14/28] Update '.drone.yml' --- .drone.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index d97216c..91a6853 100644 --- a/.drone.yml +++ b/.drone.yml @@ -16,7 +16,7 @@ steps: - name: tests image: mcr.microsoft.com/dotnet/sdk:6.0 - commands: + commands: - cd ../ - dotnet restore myBlazorApp.sln - dotnet test myBlazorApp.sln --no-restore \ No newline at end of file From ab0713dac671d8962754d9435e0aeed1f3b61645 Mon Sep 17 00:00:00 2001 From: Lilian BRETON Date: Mon, 19 Dec 2022 09:50:02 +0100 Subject: [PATCH 15/28] Update '.drone.yml' --- .drone.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index 91a6853..071a5bc 100644 --- a/.drone.yml +++ b/.drone.yml @@ -9,7 +9,7 @@ steps: - name: build image: mcr.microsoft.com/dotnet/sdk:6.0 commands: - - cd ../ + - cd myBlazorApp/ - dotnet restore myBlazorApp.sln - dotnet build myBlazorApp.sln -c Release --no-restore From 5f2e2350b04ff3b40f932004d802855028ba15ab Mon Sep 17 00:00:00 2001 From: Lilian BRETON Date: Mon, 19 Dec 2022 09:55:00 +0100 Subject: [PATCH 16/28] Update '.drone.yml' --- .drone.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.drone.yml b/.drone.yml index 071a5bc..0b73684 100644 --- a/.drone.yml +++ b/.drone.yml @@ -11,8 +11,7 @@ steps: commands: - cd myBlazorApp/ - dotnet restore myBlazorApp.sln - - dotnet build myBlazorApp.sln -c Release --no-restore - + - dotnet build myBlazorApp.sln -c Release --no-restore - name: tests image: mcr.microsoft.com/dotnet/sdk:6.0 From 197c52b8fcd5b9b12e3e092e9b7af4362a0ae0ee Mon Sep 17 00:00:00 2001 From: Lilian BRETON Date: Mon, 19 Dec 2022 09:55:27 +0100 Subject: [PATCH 17/28] Update '.drone.yml' --- .drone.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index 0b73684..c1e44b4 100644 --- a/.drone.yml +++ b/.drone.yml @@ -2,7 +2,7 @@ type: docker name: blazor trigger: - - event: + event: - push steps: From 3b602d544c0055fc572914386a7e7ba4fa87eb31 Mon Sep 17 00:00:00 2001 From: Lilian BRETON Date: Mon, 19 Dec 2022 09:55:56 +0100 Subject: [PATCH 18/28] Update '.drone.yml' --- .drone.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index c1e44b4..af25148 100644 --- a/.drone.yml +++ b/.drone.yml @@ -16,6 +16,6 @@ steps: - name: tests image: mcr.microsoft.com/dotnet/sdk:6.0 commands: - - cd ../ + - cd myBlazorApp/ - dotnet restore myBlazorApp.sln - dotnet test myBlazorApp.sln --no-restore \ No newline at end of file From 809bb499e2ab1cc16e7fc80799132edd518581cd Mon Sep 17 00:00:00 2001 From: Lilian BRETON Date: Mon, 19 Dec 2022 09:58:16 +0100 Subject: [PATCH 19/28] Update '.drone.yml' --- .drone.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index af25148..feec135 100644 --- a/.drone.yml +++ b/.drone.yml @@ -18,4 +18,5 @@ steps: commands: - cd myBlazorApp/ - dotnet restore myBlazorApp.sln - - dotnet test myBlazorApp.sln --no-restore \ No newline at end of file + - dotnet test myBlazorApp.sln --no-restore + depends_on: [build] \ No newline at end of file From d8a7f9aa1165bdd99d6a563d1ac92189b62ad9dd Mon Sep 17 00:00:00 2001 From: Lilian BRETON Date: Mon, 19 Dec 2022 10:06:02 +0100 Subject: [PATCH 20/28] Update '.drone.yml' --- .drone.yml | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index feec135..cf359ea 100644 --- a/.drone.yml +++ b/.drone.yml @@ -19,4 +19,16 @@ steps: - cd myBlazorApp/ - dotnet restore myBlazorApp.sln - dotnet test myBlazorApp.sln --no-restore - depends_on: [build] \ No newline at end of file + depends_on: [build] + + - name: docker-build + image: plugins/docker + settings: + dockerfile: myBlazorApp/myBlazorApp/Dockerfile + context: . + registry: hub.codefirst.iut.uca.fr + repo: hub.codefirst.iut.uca.fr/libreton/myBlazorApp + username: + libreton + password: + Li17br51&* \ No newline at end of file From 113fcac86ad3ef8db44ab7c90d1b913e8b0d0c32 Mon Sep 17 00:00:00 2001 From: Lilian BRETON Date: Mon, 19 Dec 2022 10:10:37 +0100 Subject: [PATCH 21/28] Update 'myBlazorApp/myBlazorApp/Dockerfile' --- myBlazorApp/myBlazorApp/Dockerfile | 43 +++++++++++++++--------------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/myBlazorApp/myBlazorApp/Dockerfile b/myBlazorApp/myBlazorApp/Dockerfile index d2ec007..557badb 100644 --- a/myBlazorApp/myBlazorApp/Dockerfile +++ b/myBlazorApp/myBlazorApp/Dockerfile @@ -1,23 +1,22 @@ -#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging. - -FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base -WORKDIR /app -EXPOSE 80 -EXPOSE 443 - -FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build -WORKDIR /src -COPY ["nuget.config", "."] -COPY ["myBlazorApp/myBlazorApp.csproj", "myBlazorApp/"] -RUN dotnet restore "myBlazorApp/myBlazorApp.csproj" -COPY . . -WORKDIR "/src/myBlazorApp" -RUN dotnet build "myBlazorApp.csproj" -c Release -o /app/build - -FROM build AS publish -RUN dotnet publish "myBlazorApp.csproj" -c Release -o /app/publish /p:UseAppHost=false - -FROM base AS final -WORKDIR /app -COPY --from=publish /app/publish . +#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging. + +FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base +WORKDIR /app +EXPOSE 80 +EXPOSE 443 + +FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build +WORKDIR /src +COPY ["myBlazorApp/myBlazorApp.csproj", "myBlazorApp/"] +RUN dotnet restore "myBlazorApp/myBlazorApp.csproj" +COPY . . +WORKDIR "/src/myBlazorApp" +RUN dotnet build "myBlazorApp.csproj" -c Release -o /app/build + +FROM build AS publish +RUN dotnet publish "myBlazorApp.csproj" -c Release -o /app/publish /p:UseAppHost=false + +FROM base AS final +WORKDIR /app +COPY --from=publish /app/publish . ENTRYPOINT ["dotnet", "myBlazorApp.dll"] \ No newline at end of file From 75670421651e2eab491e567fad4240c38a61b016 Mon Sep 17 00:00:00 2001 From: Lilian BRETON Date: Mon, 19 Dec 2022 10:11:51 +0100 Subject: [PATCH 22/28] Update 'myBlazorApp/myBlazorApp/Dockerfile' --- myBlazorApp/myBlazorApp/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/myBlazorApp/myBlazorApp/Dockerfile b/myBlazorApp/myBlazorApp/Dockerfile index 557badb..dca60a6 100644 --- a/myBlazorApp/myBlazorApp/Dockerfile +++ b/myBlazorApp/myBlazorApp/Dockerfile @@ -7,8 +7,8 @@ EXPOSE 443 FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build WORKDIR /src -COPY ["myBlazorApp/myBlazorApp.csproj", "myBlazorApp/"] -RUN dotnet restore "myBlazorApp/myBlazorApp.csproj" +COPY ["myBlazorApp.csproj", "myBlazorApp/"] +RUN dotnet restore "myBlazorApp.csproj" COPY . . WORKDIR "/src/myBlazorApp" RUN dotnet build "myBlazorApp.csproj" -c Release -o /app/build From 850fd70c147fa62db9c8d2a0f2148168e088fe00 Mon Sep 17 00:00:00 2001 From: Lilian BRETON Date: Mon, 19 Dec 2022 10:12:50 +0100 Subject: [PATCH 23/28] Update 'myBlazorApp/myBlazorApp/Dockerfile' --- myBlazorApp/myBlazorApp/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/myBlazorApp/myBlazorApp/Dockerfile b/myBlazorApp/myBlazorApp/Dockerfile index dca60a6..82c0a3e 100644 --- a/myBlazorApp/myBlazorApp/Dockerfile +++ b/myBlazorApp/myBlazorApp/Dockerfile @@ -1,12 +1,12 @@ #See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging. FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base -WORKDIR /app +WORKDIR . EXPOSE 80 EXPOSE 443 FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build -WORKDIR /src +WORKDIR . COPY ["myBlazorApp.csproj", "myBlazorApp/"] RUN dotnet restore "myBlazorApp.csproj" COPY . . From 70b8e5c76ba4ebf1b33450c6cb4e7362464d2bb0 Mon Sep 17 00:00:00 2001 From: Lilian BRETON Date: Mon, 19 Dec 2022 10:14:18 +0100 Subject: [PATCH 24/28] Update 'myBlazorApp/myBlazorApp/Dockerfile' --- myBlazorApp/myBlazorApp/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/myBlazorApp/myBlazorApp/Dockerfile b/myBlazorApp/myBlazorApp/Dockerfile index 82c0a3e..0fea46a 100644 --- a/myBlazorApp/myBlazorApp/Dockerfile +++ b/myBlazorApp/myBlazorApp/Dockerfile @@ -6,7 +6,7 @@ EXPOSE 80 EXPOSE 443 FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build -WORKDIR . +WORKDIR ./ COPY ["myBlazorApp.csproj", "myBlazorApp/"] RUN dotnet restore "myBlazorApp.csproj" COPY . . @@ -17,6 +17,6 @@ FROM build AS publish RUN dotnet publish "myBlazorApp.csproj" -c Release -o /app/publish /p:UseAppHost=false FROM base AS final -WORKDIR /app +WORKDIR ./ COPY --from=publish /app/publish . ENTRYPOINT ["dotnet", "myBlazorApp.dll"] \ No newline at end of file From be342a4496e95fb8cfed2024d0fccee0c4624cd2 Mon Sep 17 00:00:00 2001 From: Lilian BRETON Date: Mon, 19 Dec 2022 10:18:16 +0100 Subject: [PATCH 25/28] Update 'myBlazorApp/myBlazorApp/Dockerfile' --- myBlazorApp/myBlazorApp/Dockerfile | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/myBlazorApp/myBlazorApp/Dockerfile b/myBlazorApp/myBlazorApp/Dockerfile index 0fea46a..74532fe 100644 --- a/myBlazorApp/myBlazorApp/Dockerfile +++ b/myBlazorApp/myBlazorApp/Dockerfile @@ -1,22 +1,22 @@ #See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging. FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base -WORKDIR . +WORKDIR /app EXPOSE 80 EXPOSE 443 FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build -WORKDIR ./ -COPY ["myBlazorApp.csproj", "myBlazorApp/"] -RUN dotnet restore "myBlazorApp.csproj" +WORKDIR . +COPY ["myBlazorApp/myBlazorApp.csproj", "myBlazorApp/"] +RUN dotnet restore "myBlazorApp/myBlazorApp.csproj" COPY . . -WORKDIR "/src/myBlazorApp" +WORKDIR "myBlazorApp" RUN dotnet build "myBlazorApp.csproj" -c Release -o /app/build FROM build AS publish RUN dotnet publish "myBlazorApp.csproj" -c Release -o /app/publish /p:UseAppHost=false FROM base AS final -WORKDIR ./ +WORKDIR . COPY --from=publish /app/publish . ENTRYPOINT ["dotnet", "myBlazorApp.dll"] \ No newline at end of file From dae771f6cf3a34ad2365c9fcb94023c7327201a6 Mon Sep 17 00:00:00 2001 From: Lilian BRETON Date: Mon, 19 Dec 2022 10:19:24 +0100 Subject: [PATCH 26/28] Update 'myBlazorApp/myBlazorApp/Dockerfile' --- myBlazorApp/myBlazorApp/Dockerfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/myBlazorApp/myBlazorApp/Dockerfile b/myBlazorApp/myBlazorApp/Dockerfile index 74532fe..ab289f5 100644 --- a/myBlazorApp/myBlazorApp/Dockerfile +++ b/myBlazorApp/myBlazorApp/Dockerfile @@ -7,10 +7,10 @@ EXPOSE 443 FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build WORKDIR . -COPY ["myBlazorApp/myBlazorApp.csproj", "myBlazorApp/"] -RUN dotnet restore "myBlazorApp/myBlazorApp.csproj" +COPY ["myBlazorApp/myBlazorApp/myBlazorApp.csproj", "myBlazorApp/"] +RUN dotnet restore "myBlazorApp/myBlazorApp/myBlazorApp.csproj" COPY . . -WORKDIR "myBlazorApp" +WORKDIR "myBlazorApp/myBlazorApp" RUN dotnet build "myBlazorApp.csproj" -c Release -o /app/build FROM build AS publish From e63e2851561c1a7c962f26b3eeddcd503e2f98ee Mon Sep 17 00:00:00 2001 From: "lilian.breton" Date: Mon, 19 Dec 2022 10:21:57 +0100 Subject: [PATCH 27/28] Update: dockerfile --- myBlazorApp/myBlazorApp/Dockerfile | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/myBlazorApp/myBlazorApp/Dockerfile b/myBlazorApp/myBlazorApp/Dockerfile index ab289f5..557badb 100644 --- a/myBlazorApp/myBlazorApp/Dockerfile +++ b/myBlazorApp/myBlazorApp/Dockerfile @@ -6,17 +6,17 @@ EXPOSE 80 EXPOSE 443 FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build -WORKDIR . -COPY ["myBlazorApp/myBlazorApp/myBlazorApp.csproj", "myBlazorApp/"] -RUN dotnet restore "myBlazorApp/myBlazorApp/myBlazorApp.csproj" +WORKDIR /src +COPY ["myBlazorApp/myBlazorApp.csproj", "myBlazorApp/"] +RUN dotnet restore "myBlazorApp/myBlazorApp.csproj" COPY . . -WORKDIR "myBlazorApp/myBlazorApp" +WORKDIR "/src/myBlazorApp" RUN dotnet build "myBlazorApp.csproj" -c Release -o /app/build FROM build AS publish RUN dotnet publish "myBlazorApp.csproj" -c Release -o /app/publish /p:UseAppHost=false FROM base AS final -WORKDIR . +WORKDIR /app COPY --from=publish /app/publish . ENTRYPOINT ["dotnet", "myBlazorApp.dll"] \ No newline at end of file From 6d18ec1dd768620b5faf9e92de2571ffebe28178 Mon Sep 17 00:00:00 2001 From: "lilian.breton" Date: Tue, 20 Dec 2022 12:54:02 +0100 Subject: [PATCH 28/28] comment the list functions --- .drone.yml | 34 -------------- .../Data/inventory.json | 18 ++++---- .../Components/MyInventory.razor.cs | 44 ++++++++++++++++++- myBlazorApp/myBlazorApp/Dockerfile | 22 ---------- 4 files changed, 53 insertions(+), 65 deletions(-) delete mode 100644 .drone.yml delete mode 100644 myBlazorApp/myBlazorApp/Dockerfile diff --git a/.drone.yml b/.drone.yml deleted file mode 100644 index cf359ea..0000000 --- a/.drone.yml +++ /dev/null @@ -1,34 +0,0 @@ -kind: pipeline -type: docker -name: blazor -trigger: - event: - - push - -steps: - - name: build - image: mcr.microsoft.com/dotnet/sdk:6.0 - commands: - - cd myBlazorApp/ - - dotnet restore myBlazorApp.sln - - dotnet build myBlazorApp.sln -c Release --no-restore - - - name: tests - image: mcr.microsoft.com/dotnet/sdk:6.0 - commands: - - cd myBlazorApp/ - - dotnet restore myBlazorApp.sln - - dotnet test myBlazorApp.sln --no-restore - depends_on: [build] - - - name: docker-build - image: plugins/docker - settings: - dockerfile: myBlazorApp/myBlazorApp/Dockerfile - context: . - registry: hub.codefirst.iut.uca.fr - repo: hub.codefirst.iut.uca.fr/libreton/myBlazorApp - username: - libreton - password: - Li17br51&* \ No newline at end of file diff --git a/myBlazorApp/Minecraft.Crafting.Api/Data/inventory.json b/myBlazorApp/Minecraft.Crafting.Api/Data/inventory.json index 8851dab..5eb43fe 100644 --- a/myBlazorApp/Minecraft.Crafting.Api/Data/inventory.json +++ b/myBlazorApp/Minecraft.Crafting.Api/Data/inventory.json @@ -8,30 +8,32 @@ { "itemName": "Grass Block", "position": 2, - "number": 3, + "number": 4, "stackSize": 64 }, { "itemName": "Cobblestone", "position": 3, - "number": 3, + "number": 5, "stackSize": 64 }, { - "itemName": "Sapling", + "itemName": "Dirt", "position": 4, - "number": 1, + "number": 3, "stackSize": 64 }, { - "itemName": "Dirt", + "itemName": "Sapling", "position": 5, - "number": 2, + "number": 1, "stackSize": 64 }, { - "itemName": "null", - "position": 6 + "itemName": "Bedrock", + "position": 6, + "number": 1, + "stackSize": 64 }, { "itemName": "null", diff --git a/myBlazorApp/myBlazorApp/Components/MyInventory.razor.cs b/myBlazorApp/myBlazorApp/Components/MyInventory.razor.cs index 61f5f9b..62297b0 100644 --- a/myBlazorApp/myBlazorApp/Components/MyInventory.razor.cs +++ b/myBlazorApp/myBlazorApp/Components/MyInventory.razor.cs @@ -83,7 +83,18 @@ namespace myBlazorApp.Components } - + /* + * Name: OnReadData + * Function: Set up all the variables depending on what we want. + * totalItem : total number of items in the list + * items: my default list, containing alll the items printed 10 by 10 + * full: another list, loading all the items on one page + * currentPage: current page of the list + * pageSize: numper of items on the page + * choix: list binded on the datagrid that will change when needed + * isSorted: boolean turning true when we click on sort + * searchText: String binded on the search bar input + */ private async Task OnReadData(DataGridReadDataEventArgs e) { @@ -122,16 +133,26 @@ namespace myBlazorApp.Components } } + + /* + * Name: choseList + * Function: change the list choix when we type something in the search bar + */ private List choseList() { + // If the search bar is empty, we don't need to use a special list, we use the default one if (SearchText.IsNullOrEmpty()) { choix = items; totalItem = full.Count(); NavigationManager.NavigateTo("inventory", false); } + + // Else, we change the list choix and we filter the items using the Filtered list else { + // This line allows us to adapt pageSize depending on the number of items on it. + // If there is only 7 items, we don't want to print 10 on our page if (Filtered.Count() < (currentPage - 1) * 10 + pageSize) { pageSize = Filtered.Count() - (currentPage - 1) * 10; @@ -144,13 +165,23 @@ namespace myBlazorApp.Components return choix; } + /* + * Name: inputValue + * Function: When we type on the search bar, this function is called to initialize the Filtered list and call our function + */ private void inputValue() { + // We filter the items with the search bar if their name contain what we are typing Filtered = full.Where( itm => itm.DisplayName.ToLower().Contains(SearchText.ToLower())).ToList(); choseList(); } + + /* + * Name: OnPress + * Function: This function is binded on the Sort button. It changes our boolean value and call our SortList function + */ private void OnPress() { if (isSorted == true) @@ -161,13 +192,24 @@ namespace myBlazorApp.Components SortList(); } + + /* + * Name: SortList + * Function: When we press the sort button, this function will hange the items in the list choix + */ private List SortList() { + // If our boolean is false, it means that the list was sorted and we pressed the button to unsort it. + // So, it takes the default list for our dataGrid + // The navigateTo allows to be on the first page of the list when we unsort it if (isSorted == false) { choix = items; NavigationManager.NavigateTo("inventory", true); } + + // Else, we put the full list into the Sorted one, and we sort the items by name. + // We check for the number of items in the page and we give the Sorted list to choix with the pageSize we want else { if (Sorted.IsNullOrEmpty()) diff --git a/myBlazorApp/myBlazorApp/Dockerfile b/myBlazorApp/myBlazorApp/Dockerfile deleted file mode 100644 index 557badb..0000000 --- a/myBlazorApp/myBlazorApp/Dockerfile +++ /dev/null @@ -1,22 +0,0 @@ -#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging. - -FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base -WORKDIR /app -EXPOSE 80 -EXPOSE 443 - -FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build -WORKDIR /src -COPY ["myBlazorApp/myBlazorApp.csproj", "myBlazorApp/"] -RUN dotnet restore "myBlazorApp/myBlazorApp.csproj" -COPY . . -WORKDIR "/src/myBlazorApp" -RUN dotnet build "myBlazorApp.csproj" -c Release -o /app/build - -FROM build AS publish -RUN dotnet publish "myBlazorApp.csproj" -c Release -o /app/publish /p:UseAppHost=false - -FROM base AS final -WORKDIR /app -COPY --from=publish /app/publish . -ENTRYPOINT ["dotnet", "myBlazorApp.dll"] \ No newline at end of file