From 39a21a151960a5cf362ad6acc0036f4d96b779fe Mon Sep 17 00:00:00 2001
From: Noan07 <84435602+Noan07@users.noreply.github.com>
Date: Mon, 27 Feb 2023 16:47:51 +0100
Subject: [PATCH] :hammer: Ajout dockerFile + Ajout tests
---
code/server/.dockerignore | 25 +++++++++++++++++++
code/server/ApiLeapHit/ApiLeapHit.csproj | 3 +++
code/server/ApiLeapHit/Dockerfile | 24 ++++++++++++++++++
.../ApiLeapHit/Properties/launchSettings.json | 17 +++++++++----
code/server/Server.sln | 11 ++++++++
.../TestControleurs/TestControleurs.csproj | 17 +++++++++++++
code/server/TestControleurs/UnitTestGames.cs | 13 ++++++++++
7 files changed, 105 insertions(+), 5 deletions(-)
create mode 100644 code/server/.dockerignore
create mode 100644 code/server/ApiLeapHit/Dockerfile
create mode 100644 code/server/TestControleurs/TestControleurs.csproj
create mode 100644 code/server/TestControleurs/UnitTestGames.cs
diff --git a/code/server/.dockerignore b/code/server/.dockerignore
new file mode 100644
index 0000000..3729ff0
--- /dev/null
+++ b/code/server/.dockerignore
@@ -0,0 +1,25 @@
+**/.classpath
+**/.dockerignore
+**/.env
+**/.git
+**/.gitignore
+**/.project
+**/.settings
+**/.toolstarget
+**/.vs
+**/.vscode
+**/*.*proj.user
+**/*.dbmdl
+**/*.jfm
+**/azds.yaml
+**/bin
+**/charts
+**/docker-compose*
+**/Dockerfile*
+**/node_modules
+**/npm-debug.log
+**/obj
+**/secrets.dev.yaml
+**/values.dev.yaml
+LICENSE
+README.md
\ No newline at end of file
diff --git a/code/server/ApiLeapHit/ApiLeapHit.csproj b/code/server/ApiLeapHit/ApiLeapHit.csproj
index 56b0e8b..ce88455 100644
--- a/code/server/ApiLeapHit/ApiLeapHit.csproj
+++ b/code/server/ApiLeapHit/ApiLeapHit.csproj
@@ -4,10 +4,13 @@
net6.0
enable
enable
+ e2f60cb9-96bb-44ca-88f5-a122ae9c5dea
+ Linux
+
diff --git a/code/server/ApiLeapHit/Dockerfile b/code/server/ApiLeapHit/Dockerfile
new file mode 100644
index 0000000..ab1f7af
--- /dev/null
+++ b/code/server/ApiLeapHit/Dockerfile
@@ -0,0 +1,24 @@
+#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 ["ApiLeapHit/ApiLeapHit.csproj", "ApiLeapHit/"]
+COPY ["DTO/DTO.csproj", "DTO/"]
+COPY ["DataBase/DataBase.csproj", "DataBase/"]
+RUN dotnet restore "ApiLeapHit/ApiLeapHit.csproj"
+COPY . .
+WORKDIR "/src/ApiLeapHit"
+RUN dotnet build "ApiLeapHit.csproj" -c Release -o /app/build
+
+FROM build AS publish
+RUN dotnet publish "ApiLeapHit.csproj" -c Release -o /app/publish
+
+FROM base AS final
+WORKDIR /app
+COPY --from=publish /app/publish .
+ENTRYPOINT ["dotnet", "ApiLeapHit.dll"]
\ No newline at end of file
diff --git a/code/server/ApiLeapHit/Properties/launchSettings.json b/code/server/ApiLeapHit/Properties/launchSettings.json
index eaba764..e3a5e83 100644
--- a/code/server/ApiLeapHit/Properties/launchSettings.json
+++ b/code/server/ApiLeapHit/Properties/launchSettings.json
@@ -1,4 +1,4 @@
-{
+{
"$schema": "https://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
@@ -11,13 +11,13 @@
"profiles": {
"ApiLeapHit": {
"commandName": "Project",
- "dotnetRunMessages": true,
"launchBrowser": true,
"launchUrl": "swagger",
- "applicationUrl": "https://localhost:7153;http://localhost:5153",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
- }
+ },
+ "applicationUrl": "https://localhost:7153;http://localhost:5153",
+ "dotnetRunMessages": true
},
"IIS Express": {
"commandName": "IISExpress",
@@ -26,6 +26,13 @@
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
+ },
+ "Docker": {
+ "commandName": "Docker",
+ "launchBrowser": true,
+ "launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/swagger",
+ "publishAllPorts": true,
+ "useSSL": true
}
}
-}
+}
\ No newline at end of file
diff --git a/code/server/Server.sln b/code/server/Server.sln
index 14b6b0a..164c901 100644
--- a/code/server/Server.sln
+++ b/code/server/Server.sln
@@ -11,6 +11,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DTO", "DTO\DTO.csproj", "{B
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DataBase", "DataBase\DataBase.csproj", "{FCCE7DEC-1F7B-4C66-8C61-3FCB668F9008}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestControleurs", "TestControleurs\TestControleurs.csproj", "{A9DFF203-7F27-44BA-A460-F65C01D0EDFD}"
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{12A97D16-34BB-4D4F-9F76-D74061A9BA77}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -33,10 +37,17 @@ Global
{FCCE7DEC-1F7B-4C66-8C61-3FCB668F9008}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FCCE7DEC-1F7B-4C66-8C61-3FCB668F9008}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FCCE7DEC-1F7B-4C66-8C61-3FCB668F9008}.Release|Any CPU.Build.0 = Release|Any CPU
+ {A9DFF203-7F27-44BA-A460-F65C01D0EDFD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {A9DFF203-7F27-44BA-A460-F65C01D0EDFD}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {A9DFF203-7F27-44BA-A460-F65C01D0EDFD}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {A9DFF203-7F27-44BA-A460-F65C01D0EDFD}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
+ GlobalSection(NestedProjects) = preSolution
+ {A9DFF203-7F27-44BA-A460-F65C01D0EDFD} = {12A97D16-34BB-4D4F-9F76-D74061A9BA77}
+ EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {4BE2DC93-D511-4DA9-9C47-F286E71354BA}
EndGlobalSection
diff --git a/code/server/TestControleurs/TestControleurs.csproj b/code/server/TestControleurs/TestControleurs.csproj
new file mode 100644
index 0000000..f72bee8
--- /dev/null
+++ b/code/server/TestControleurs/TestControleurs.csproj
@@ -0,0 +1,17 @@
+
+
+
+ net6.0
+ enable
+
+ false
+
+
+
+
+
+
+
+
+
+
diff --git a/code/server/TestControleurs/UnitTestGames.cs b/code/server/TestControleurs/UnitTestGames.cs
new file mode 100644
index 0000000..5421357
--- /dev/null
+++ b/code/server/TestControleurs/UnitTestGames.cs
@@ -0,0 +1,13 @@
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+namespace TestControleurs
+{
+ [TestClass]
+ public class UnitTestGames
+ {
+ [TestMethod]
+ public void TestMethod1()
+ {
+ }
+ }
+}
\ No newline at end of file