From ee021510c83840dcb98ea5020d949f1b3cdd9dcb Mon Sep 17 00:00:00 2001 From: Fransolet Thomas Date: Thu, 29 Sep 2022 16:54:44 +0200 Subject: [PATCH] add docker file + change for prod --- ManagerService/Controllers/UserController.cs | 2 +- ManagerService/Dockerfile | 24 +++++++++++++++++++ ManagerService/ManagerService.csproj | 5 +++- .../PublishProfiles/registry.unov.be.pubxml | 21 ++++++++++++++++ .../PublishProfiles/registry.unov.be1.pubxml | 18 ++++++++++++++ ManagerService/Properties/launchSettings.json | 22 ++++++++++++++--- ManagerService/Startup.cs | 11 +++++---- ManagerService/appsettings.json | 7 +++--- 8 files changed, 97 insertions(+), 13 deletions(-) create mode 100644 ManagerService/Dockerfile create mode 100644 ManagerService/Properties/PublishProfiles/registry.unov.be.pubxml create mode 100644 ManagerService/Properties/PublishProfiles/registry.unov.be1.pubxml diff --git a/ManagerService/Controllers/UserController.cs b/ManagerService/Controllers/UserController.cs index ea2ca10..5f1e16b 100644 --- a/ManagerService/Controllers/UserController.cs +++ b/ManagerService/Controllers/UserController.cs @@ -86,7 +86,7 @@ namespace ManagerService.Controllers /// Create an user /// /// New user info - [AllowAnonymous] + //[AllowAnonymous] [ProducesResponseType(typeof(UserDetailDTO), 200)] [ProducesResponseType(typeof(string), 400)] [ProducesResponseType(typeof(string), 409)] diff --git a/ManagerService/Dockerfile b/ManagerService/Dockerfile new file mode 100644 index 0000000..826f062 --- /dev/null +++ b/ManagerService/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 +VOLUME ["/etc/managerservice"] + +FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build +WORKDIR /src +COPY ["ManagerService/ManagerService.csproj", "ManagerService/"] +COPY ["Manager.Interfaces/Manager.Interfaces.csproj", "Manager.Interfaces/"] +COPY ["Manager.Framework/Manager.Framework.csproj", "Manager.Framework/"] +RUN dotnet restore "ManagerService/ManagerService.csproj" +COPY . . +WORKDIR "/src/ManagerService" +RUN dotnet build "ManagerService.csproj" -c Release -o /app/build + +FROM build AS publish +RUN dotnet publish "ManagerService.csproj" -c Release -o /app/publish + +FROM base AS final +WORKDIR /app +COPY --from=publish /app/publish . +ENTRYPOINT ["dotnet", "ManagerService.dll"] \ No newline at end of file diff --git a/ManagerService/ManagerService.csproj b/ManagerService/ManagerService.csproj index 60117dd..e809caa 100644 --- a/ManagerService/ManagerService.csproj +++ b/ManagerService/ManagerService.csproj @@ -1,12 +1,15 @@ - + net6.0 + Linux + d2e1a747-e204-4b43-bf93-abbd19c46417 + diff --git a/ManagerService/Properties/PublishProfiles/registry.unov.be.pubxml b/ManagerService/Properties/PublishProfiles/registry.unov.be.pubxml new file mode 100644 index 0000000..a0dae9e --- /dev/null +++ b/ManagerService/Properties/PublishProfiles/registry.unov.be.pubxml @@ -0,0 +1,21 @@ + + + + + Custom + true + https://registry.unov.be + admin + latest + ContainerRegistry + Release + Any CPU + 042e0bc4-8dcf-4eec-8420-c71aa85d4d99 + net6.0 + linux-x64 + false + + \ No newline at end of file diff --git a/ManagerService/Properties/PublishProfiles/registry.unov.be1.pubxml b/ManagerService/Properties/PublishProfiles/registry.unov.be1.pubxml new file mode 100644 index 0000000..aabcf11 --- /dev/null +++ b/ManagerService/Properties/PublishProfiles/registry.unov.be1.pubxml @@ -0,0 +1,18 @@ + + + + + Custom + true + https://registry.unov.be + + latest + ContainerRegistry + Release + Any CPU + 042e0bc4-8dcf-4eec-8420-c71aa85d4d99 + + \ No newline at end of file diff --git a/ManagerService/Properties/launchSettings.json b/ManagerService/Properties/launchSettings.json index 10e675e..c33aac8 100644 --- a/ManagerService/Properties/launchSettings.json +++ b/ManagerService/Properties/launchSettings.json @@ -1,4 +1,5 @@ { + "$schema": "http://json.schemastore.org/launchsettings.json", "iisSettings": { "windowsAuthentication": false, "anonymousAuthentication": true, @@ -7,15 +8,14 @@ "sslPort": 0 } }, - "$schema": "http://json.schemastore.org/launchsettings.json", "profiles": { "IIS Express": { "commandName": "IISExpress", "launchBrowser": true, "launchUrl": "swagger", "environmentVariables": { - "ASPNETCORE_URLS": "http://*:5000/", - "ASPNETCORE_ENVIRONMENT": "Development" + "ASPNETCORE_ENVIRONMENT": "Development", + "ASPNETCORE_URLS": "http://*:5000/" } }, "ManagerService": { @@ -26,6 +26,22 @@ "ASPNETCORE_ENVIRONMENT": "Development" }, "applicationUrl": "https://localhost:5001;http://localhost:5000" + }, + "WSL": { + "commandName": "WSL2", + "launchBrowser": true, + "launchUrl": "https://localhost:5001/weatherforecast", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development", + "ASPNETCORE_URLS": "https://localhost:5001;http://localhost:5000" + }, + "distributionName": "" + }, + "Docker": { + "commandName": "Docker", + "launchBrowser": true, + "launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/swagger", + "publishAllPorts": true } } } \ No newline at end of file diff --git a/ManagerService/Startup.cs b/ManagerService/Startup.cs index e2492af..243042c 100644 --- a/ManagerService/Startup.cs +++ b/ManagerService/Startup.cs @@ -40,7 +40,7 @@ namespace ManagerService { Configuration = configuration; - MapConfiguration(); + //MapConfiguration(); } public IConfiguration Configuration { get; } @@ -132,7 +132,7 @@ namespace ManagerService }; }); - services.AddMqttClientHostedService(); + //services.AddMqttClientHostedService(); services.AddScoped(typeof(ProfileLogic)); services.AddScoped(); services.AddScoped(); @@ -152,11 +152,12 @@ namespace ManagerService if (env.IsDevelopment()) { - //app.UseDeveloperExceptionPage(); - app.UseExceptionHandler(HandleError); + app.UseDeveloperExceptionPage(); } - app.UseHttpsRedirection(); + app.UseExceptionHandler(HandleError); + + //app.UseHttpsRedirection(); app.UseRouting(); app.UseAuthentication(); diff --git a/ManagerService/appsettings.json b/ManagerService/appsettings.json index 1b96860..6c4d2e4 100644 --- a/ManagerService/appsettings.json +++ b/ManagerService/appsettings.json @@ -3,7 +3,8 @@ //"TabletDb": "mongodb://admin:MioTech4ever!@localhost:27017" //DEV //"TabletDb": "mongodb://admin:MioTech4ever!@localhost:27017", //PROD - Thomas //"TabletDb": "mongodb://admin:MioTech4ever!@192.168.31.140:27017" //PROD - Thomas - "TabletDb": "mongodb://admin:mdlf2021!@localhost:27017" //PROD + //"TabletDb": "mongodb://admin:mdlf2021!@localhost:27017" //PROD MDLF + "TabletDb": "mongodb://admin:MyMuseum2022!@51.77.222.154:27017" //PROD MyMuseum }, "Logging": { "LogLevel": { @@ -34,6 +35,6 @@ "UserName": "admin", "Password": "mdlf2021!" }, - "SupportedLanguages": [ "FR", "NL", "EN", "DE", "IT", "ES", "PL", "CN" ], - "Urls": "http://localhost:5002" + "SupportedLanguages": [ "FR", "NL", "EN", "DE", "IT", "ES", "PL", "CN" ] + //"Urls": "http://[::]:80" }