Skip to content
This repository was archived by the owner on Aug 1, 2021. It is now read-only.

Commit 33b5ac1

Browse files
committed
docker --checkpoint
1 parent c01d1a2 commit 33b5ac1

File tree

24 files changed

+225
-198
lines changed

24 files changed

+225
-198
lines changed

docker-compose.yml

Lines changed: 70 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -1,110 +1,71 @@
1-
# BUG's at SSL and Issuer Validation
2-
# SSL bug: https://github.com/dotnet/corefx/issues/22996 and https://github.com/dotnet/corefx/issues/31034
3-
# There are a mismatch between Angular Isser Name and Api Issuer Name, so it cant validate it inside docker ambient.
4-
version: "3"
1+
version: "3"
2+
3+
services:
4+
5+
#############################
6+
# Database
7+
#############################
8+
database:
9+
image: mysql
10+
command: --default-authentication-plugin=mysql_native_password
11+
restart: always
12+
environment:
13+
MYSQL_ROOT_PASSWORD: root
14+
MYSQL_USER: jp
15+
MYSQL_DATABASE: jpproject
16+
MYSQL_PASSWORD: 10203040
517

6-
networks:
7-
jpproject_network:
8-
driver: bridge
9-
ipam:
10-
driver: default
11-
config:
12-
- subnet: 172.20.0.0/16
13-
services:
14-
15-
#############################
16-
# Database
17-
#############################
18-
database:
19-
image: "microsoft/mssql-server-linux"
20-
21-
environment:
22-
SA_PASSWORD: "@Password1"
23-
ACCEPT_EULA: "Y"
24-
25-
ports:
26-
- "44274:1433"
27-
28-
healthcheck:
29-
test: [ "CMD", "sqlcmd", "-U", "sa", "-P", "Password1", "-Q", "select 1" ]
30-
interval: 1s
31-
retries: 30
32-
33-
networks:
34-
jpproject_network:
35-
ipv4_address: 172.20.0.5
36-
#############################
37-
# Server SSO
38-
#############################
39-
sso:
40-
image: "jpproject-sso"
41-
42-
build:
43-
context: .
44-
dockerfile: sso.dockerfile
45-
46-
ports:
47-
- "5001:5001"
48-
- "5000:5000"
49-
50-
depends_on:
51-
- database
52-
53-
environment:
54-
DATABASE_CONNECTION: "Server=database,1433;Initial Catalog=JpProject;Persist Security Info=False;User ID=sa;Password=@Password1;MultipleActiveResultSets=False;Connection Timeout=30;"
55-
ASPNETCORE_ENVIRONMENT: "Development"
56-
# ISSUER_URI: "http://localhost:5000"
57-
ASPNETCORE_Kestrel__Certificates__Default__Password: ".pxCpE]yttwC&b&hriw#,7K^_}A7xezRH3=EisJKn3]8.H}^Unzd+ebw]zzv_=d3"
58-
ASPNETCORE_Kestrel__Certificates__Default__Path: "/root/.dotnet/https/jpproject.pfx"
59-
ASPNETCORE_URLS: http://+:5000;http://+:5001
60-
61-
networks:
62-
jpproject_network:
63-
ipv4_address: 172.20.0.6
64-
65-
#############################
66-
# Management API
67-
#############################
68-
user-management-api:
69-
container_name: jpproject-user_management_api
70-
build:
71-
context: .
72-
dockerfile: user-management.dockerfile
73-
74-
ports:
75-
- "5003:443"
76-
- "5002:80"
77-
78-
depends_on:
79-
- database
80-
- sso
81-
82-
environment:
83-
SQLSERVER_CONNECTION: "Server=database,1433;Initial Catalog=JpProject;Persist Security Info=False;User ID=sa;Password=@Password1;MultipleActiveResultSets=False;Connection Timeout=30;"
84-
ASPNETCORE_ENVIRONMENT: "Development"
85-
AUTHORITY: "http://localhost:5000"
86-
ASPNETCORE_Kestrel__Certificates__Default__Password: ".pxCpE]yttwC&b&hriw#,7K^_}A7xezRH3=EisJKn3]8.H}^Unzd+ebw]zzv_=d3"
87-
ASPNETCORE_Kestrel__Certificates__Default__Path: "/root/.dotnet/https/jpproject.pfx"
88-
ASPNETCORE_URLS: "https://+:443;http://+:80"
89-
VALIDATE_ISSUER: "false"
90-
91-
networks:
92-
jpproject_network:
93-
ipv4_address: 172.20.0.7
94-
95-
#############################
96-
# User management UI
97-
#############################
98-
user-management-ui:
99-
container_name: jpproject-user-management-ui
100-
101-
build:
102-
context: .
103-
dockerfile: ui-user-management.dockerfile
104-
105-
ports:
106-
- 4200:80
107-
108-
networks:
109-
jpproject_network:
110-
ipv4_address: 172.20.0.8
18+
#############################
19+
# Server SSO
20+
#############################
21+
sso:
22+
image: "jpproject-sso"
23+
build:
24+
context: .
25+
dockerfile: sso.dockerfile
26+
ports:
27+
- "5001:5001"
28+
- "5000:5000"
29+
links:
30+
- database
31+
depends_on:
32+
- database
33+
environment:
34+
DATABASE_TYPE: "MySql"
35+
CUSTOMCONNSTR_DATABASE_CONNECTION: "server=database,port=3306;database=jpproject;user=jp;password=10203040"
36+
ASPNETCORE_ENVIRONMENT: "Development"
37+
# ISSUER_URI: "http://localhost:5000"
38+
ASPNETCORE_Kestrel__Certificates__Default__Password: ".pxCpE]yttwC&b&hriw#,7K^_}A7xezRH3=EisJKn3]8.H}^Unzd+ebw]zzv_=d3"
39+
ASPNETCORE_Kestrel__Certificates__Default__Path: "/root/.dotnet/https/jpproject.pfx"
40+
ASPNETCORE_URLS: https://+:5000;http://+:5001
41+
42+
#############################
43+
# Management API
44+
#############################
45+
jpproject-api:
46+
container_name: jpproject-api
47+
build:
48+
context: .
49+
dockerfile: user-management.dockerfile
50+
ports:
51+
- "5003:5003"
52+
- "5002:5002"
53+
depends_on:
54+
- database
55+
environment:
56+
DATABASE_TYPE: "MySql"
57+
CUSTOMCONNSTR_DATABASE_CONNECTION: "server=database,port=3306;database=jpproject;user=jp;password=10203040"
58+
ASPNETCORE_ENVIRONMENT: "Development"
59+
AUTHORITY: "http://localhost:5000"
60+
ASPNETCORE_URLS: "https://+:5003;http://+:5002"
61+
62+
#############################
63+
# User management UI
64+
#############################
65+
user-management-ui:
66+
container_name: jpproject-user-management-ui
67+
build:
68+
context: .
69+
dockerfile: ui-user-management.dockerfile
70+
ports:
71+
- 4300:80

keys/jpproject.cer

0 Bytes
Binary file not shown.

src/.dockerignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
.dockerignore
2+
.env
3+
.git
4+
.gitignore
5+
.vs
6+
.vscode
7+
*/bin
8+
*/obj
9+
**/.toolstarget

src/Backend/Jp.Infra.CrossCutting.Identity/Services/UserService.cs

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,22 +29,20 @@ public class UserService : IUserService
2929
private readonly IEmailSender _emailSender;
3030
private readonly IMediatorHandler _bus;
3131
private readonly ILogger _logger;
32-
private readonly IConfigurationRoot _config;
32+
private readonly IConfiguration _config;
3333

3434
public UserService(
3535
UserManager<UserIdentity> userManager,
3636
IEmailSender emailSender,
3737
IMediatorHandler bus,
38-
ILoggerFactory loggerFactory)
38+
ILoggerFactory loggerFactory,
39+
IConfiguration config)
3940
{
4041
_userManager = userManager;
4142
_emailSender = emailSender;
4243
_bus = bus;
44+
_config = config;
4345
_logger = loggerFactory.CreateLogger<UserService>(); ;
44-
_config = new ConfigurationBuilder()
45-
.SetBasePath(Directory.GetCurrentDirectory())
46-
.AddJsonFile("appsettings.json")
47-
.Build();
4846
}
4947

5048
public Task<Guid?> CreateUserWithPass(IDomainUser user, string password)
@@ -161,15 +159,11 @@ public async Task<User> FindByLoginAsync(string provider, string providerUserId)
161159
if (user == null)
162160
return null;
163161

164-
// get the configuration from the app settings
165-
var configuration = new ConfigurationBuilder()
166-
.SetBasePath(Directory.GetCurrentDirectory())
167-
.AddJsonFile("appsettings.json")
168-
.Build();
162+
169163
// For more information on how to enable account confirmation and password reset please
170164
// visit https://go.microsoft.com/fwlink/?LinkID=532713
171165
var code = await _userManager.GeneratePasswordResetTokenAsync(user);
172-
var callbackUrl = $"{configuration.GetSection("WebAppUrl").Value}/reset-password?email={user.Email.UrlEncode()}&code={code.UrlEncode()}";
166+
var callbackUrl = $"{_config.GetSection("WebAppUrl").Value}/reset-password?email={user.Email.UrlEncode()}&code={code.UrlEncode()}";
173167

174168
await _emailSender.SendEmailAsync(user.Email, "Reset Password", $"Please reset your password by clicking here: <a href='{callbackUrl}'>link</a>");
175169

src/Backend/Jp.Infra.CrossCutting.IoC/IdentityBootStrapper.cs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,9 @@ namespace Jp.Infra.CrossCutting.IoC
1111
{
1212
internal class IdentityBootStrapper
1313
{
14-
public static void RegisterServices(IServiceCollection services)
14+
public static void RegisterServices(IServiceCollection services, IConfiguration config)
1515
{
16-
// get the configuration from the app settings
17-
var config = new ConfigurationBuilder()
18-
.SetBasePath(Directory.GetCurrentDirectory())
19-
.AddJsonFile("appsettings.json")
20-
.Build();
21-
22-
// Infra - Identity Services
16+
// Infra - Identity Services
2317
services.AddTransient<IEmailSender, AuthEmailMessageSender>();
2418
services.AddTransient<ISmsSender, AuthSMSMessageSender>();
2519
services.AddTransient<IUserService, UserService>();

src/Backend/Jp.Infra.CrossCutting.IoC/NativeInjectorBootStrapper.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@
55
using Jp.Infra.CrossCutting.Tools.Serializer;
66
using Microsoft.AspNetCore.Authorization;
77
using Microsoft.AspNetCore.Http;
8+
using Microsoft.Extensions.Configuration;
89
using Microsoft.Extensions.DependencyInjection;
910

1011
namespace Jp.Infra.CrossCutting.IoC
1112
{
1213
public class NativeInjectorBootStrapper
1314
{
14-
public static void RegisterServices(IServiceCollection services)
15+
public static void RegisterServices(IServiceCollection services, IConfiguration configuration)
1516
{
1617
// ASP.NET HttpContext dependency
1718
services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
@@ -36,7 +37,7 @@ public static void RegisterServices(IServiceCollection services)
3637

3738

3839
// Infra - Identity Services
39-
IdentityBootStrapper.RegisterServices(services);
40+
IdentityBootStrapper.RegisterServices(services, configuration);
4041

4142
// Infra Tools
4243
// ASP.NET Authorization Polices

src/Backend/Jp.Infra.CrossCutting.Tools/CloudServices/Storage/AzureImageStoreService.cs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
1-
using System;
2-
using System.IO;
3-
using System.Threading.Tasks;
4-
using Jp.Application.Interfaces;
1+
using Jp.Application.Interfaces;
52
using Jp.Application.ViewModels;
63
using Microsoft.Extensions.Configuration;
74
using Microsoft.WindowsAzure.Storage;
85
using Microsoft.WindowsAzure.Storage.Auth;
96
using Microsoft.WindowsAzure.Storage.Blob;
7+
using System;
8+
using System.IO;
9+
using System.Threading.Tasks;
1010

1111
namespace Jp.Infra.CrossCutting.Tools.CloudServices.Storage
1212
{
1313
public class AzureImageStoreService : IImageStorage
1414
{
15-
private IConfiguration _configuration;
16-
private IConfiguration Configuration => _configuration ?? (_configuration = new ConfigurationBuilder()
17-
.SetBasePath(Directory.GetCurrentDirectory())
18-
.AddJsonFile("appsettings.json")
19-
.Build());
15+
private readonly IConfiguration _configuration;
16+
17+
public AzureImageStoreService(IConfiguration configuration)
18+
{
19+
_configuration = configuration;
20+
}
2021

2122

2223
public async Task<string> SaveAsync(ProfilePictureViewModel image)
@@ -32,7 +33,7 @@ public async Task<string> SaveAsync(ProfilePictureViewModel image)
3233

3334
private async Task<CloudBlobContainer> GetBlobContainer()
3435
{
35-
var storageCredentials = new StorageCredentials(Configuration.GetSection("Storage").GetSection("AccountName").Value, Configuration.GetSection("Storage").GetSection("AccountKey").Value);
36+
var storageCredentials = new StorageCredentials(_configuration.GetSection("Storage").GetSection("AccountName").Value, _configuration.GetSection("Storage").GetSection("AccountKey").Value);
3637
var cloudStorageAccount = new CloudStorageAccount(storageCredentials, true);
3738
var cloudBlobClient = cloudStorageAccount.CreateCloudBlobClient();
3839
var container = cloudBlobClient.GetContainerReference("images");

src/Backend/Jp.Infra.CrossCutting.Tools/DefaultConfig/JpProjectConfiguration.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public static class JpProjectConfiguration
1212
private static IConfiguration _configuration;
1313
private static IConfiguration Configuration => _configuration ?? (_configuration = new ConfigurationBuilder()
1414
.SetBasePath(Directory.GetCurrentDirectory())
15-
.AddJsonFile("appsettings.json")
15+
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
1616
.Build());
1717

1818

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
FROM microsoft/dotnet:2.2-aspnetcore-runtime AS base
2+
WORKDIR /app
3+
EXPOSE 5003
4+
EXPOSE 5002
5+
6+
FROM microsoft/dotnet:2.2-sdk AS build
7+
WORKDIR /src
8+
COPY ["Backend/Jp.UserManagement/Jp.Management.csproj", "Backend/Jp.UserManagement/"]
9+
COPY ["Backend/Jp.Infra.Migrations.Sql.Identity/Jp.Infra.Migrations.Sql.csproj", "Backend/Jp.Infra.Migrations.Sql.Identity/"]
10+
COPY ["Backend/Jp.Infra.Data/Jp.Infra.Data.csproj", "Backend/Jp.Infra.Data/"]
11+
COPY ["Backend/Jp.Domain.Core/Jp.Domain.Core.csproj", "Backend/Jp.Domain.Core/"]
12+
COPY ["Backend/Jp.Domain/Jp.Domain.csproj", "Backend/Jp.Domain/"]
13+
COPY ["Backend/Jp.Infra.CrossCutting.Bus/Jp.Infra.CrossCutting.Bus.csproj", "Backend/Jp.Infra.CrossCutting.Bus/"]
14+
COPY ["Backend/Jp.Infra.CrossCutting.Identity/Jp.Infra.CrossCutting.Identity.csproj", "Backend/Jp.Infra.CrossCutting.Identity/"]
15+
COPY ["Backend/Jp.Application/Jp.Application.csproj", "Backend/Jp.Application/"]
16+
COPY ["Backend/Jp.Infra.CrossCutting.IoC/Jp.Infra.CrossCutting.IoC.csproj", "Backend/Jp.Infra.CrossCutting.IoC/"]
17+
COPY ["Backend/Jp.Infra.CrossCutting.Tools/Jp.Infra.CrossCutting.Tools.csproj", "Backend/Jp.Infra.CrossCutting.Tools/"]
18+
COPY ["Backend/Jp.Infra.Migrations.MySql.Identity/Jp.Infra.Migrations.MySql.csproj", "Backend/Jp.Infra.Migrations.MySql.Identity/"]
19+
RUN dotnet restore "Backend/Jp.UserManagement/Jp.Management.csproj"
20+
COPY . .
21+
WORKDIR "/src/Backend/Jp.UserManagement"
22+
RUN dotnet build "Jp.Management.csproj" -c Release -o /app
23+
24+
FROM build AS publish
25+
RUN dotnet publish "Jp.Management.csproj" -c Release -o /app
26+
27+
FROM base AS final
28+
WORKDIR /app
29+
COPY --from=publish /app .
30+
ENTRYPOINT ["dotnet", "Jp.Management.dll"]

src/Backend/Jp.UserManagement/Jp.Management.csproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,10 @@
3232
<ProjectReference Include="..\Jp.Infra.Migrations.Sql.Identity\Jp.Infra.Migrations.Sql.csproj" />
3333
</ItemGroup>
3434

35+
<ItemGroup>
36+
<Content Update="appsettings.json">
37+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
38+
<CopyToPublishDirectory>Always</CopyToPublishDirectory>
39+
</Content>
40+
</ItemGroup>
3541
</Project>

0 commit comments

Comments
 (0)