add docker file + change for prod

This commit is contained in:
Fransolet Thomas 2022-09-29 16:54:44 +02:00
parent 1725376623
commit ee021510c8
8 changed files with 97 additions and 13 deletions

View File

@ -86,7 +86,7 @@ namespace ManagerService.Controllers
/// Create an user
/// </summary>
/// <param name="newUser">New user info</param>
[AllowAnonymous]
//[AllowAnonymous]
[ProducesResponseType(typeof(UserDetailDTO), 200)]
[ProducesResponseType(typeof(string), 400)]
[ProducesResponseType(typeof(string), 409)]

24
ManagerService/Dockerfile Normal file
View File

@ -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"]

View File

@ -1,12 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<UserSecretsId>d2e1a747-e204-4b43-bf93-abbd19c46417</UserSecretsId>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="2.1.2" />
<PackageReference Include="Microsoft.IdentityModel.Tokens" Version="6.10.0" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.14.0" />
<PackageReference Include="MongoDB.Driver" Version="2.12.1" />
<PackageReference Include="MQTTnet.AspNetCore" Version="3.0.13" />
<PackageReference Include="NSwag.AspNetCore" Version="13.10.8" />

View File

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
This file is used by the publish/package process of your Web project. You can customize the behavior of this process
by editing this MSBuild file. In order to learn more about this please visit https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project>
<PropertyGroup>
<WebPublishMethod>Custom</WebPublishMethod>
<DockerPublish>true</DockerPublish>
<RegistryUrl>https://registry.unov.be</RegistryUrl>
<UserName>admin</UserName>
<PublishImageTag>latest</PublishImageTag>
<PublishProvider>ContainerRegistry</PublishProvider>
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<ProjectGuid>042e0bc4-8dcf-4eec-8420-c71aa85d4d99</ProjectGuid>
<TargetFramework>net6.0</TargetFramework>
<RuntimeIdentifier>linux-x64</RuntimeIdentifier>
<SelfContained>false</SelfContained>
</PropertyGroup>
</Project>

View File

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
This file is used by the publish/package process of your Web project. You can customize the behavior of this process
by editing this MSBuild file. In order to learn more about this please visit https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project>
<PropertyGroup>
<WebPublishMethod>Custom</WebPublishMethod>
<DockerPublish>true</DockerPublish>
<RegistryUrl>https://registry.unov.be</RegistryUrl>
<UserName />
<PublishImageTag>latest</PublishImageTag>
<PublishProvider>ContainerRegistry</PublishProvider>
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<ProjectGuid>042e0bc4-8dcf-4eec-8420-c71aa85d4d99</ProjectGuid>
</PropertyGroup>
</Project>

View File

@ -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
}
}
}

View File

@ -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<TokensService>();
services.AddScoped<UserDatabaseService>();
@ -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();

View File

@ -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"
}