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

Commit 7182766

Browse files
committed
-- checkpoint
1 parent 33b5ac1 commit 7182766

File tree

23 files changed

+2199
-587
lines changed

23 files changed

+2199
-587
lines changed

.dockerignore

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,29 @@
1-
.dockerignore
2-
.env
3-
.git
4-
.gitignore
5-
**/.vs/
6-
.vscode
7-
*/bin
8-
*/obj
9-
**/.toolstarget
1+
[Oo]bj/
2+
[Bb]in/
3+
TestResults/
4+
.nuget/
5+
_ReSharper.*/
6+
packages/
7+
artifacts/
8+
PublishProfiles/
9+
*.user
10+
*.suo
11+
*.cache
12+
*.docstates
13+
_ReSharper.*
14+
nuget.exe
15+
*net45.csproj
16+
*k10.csproj
17+
*.psess
18+
*.vsp
19+
*.pidb
20+
*.userprefs
21+
*DS_Store
22+
*.ncrunchsolution
23+
*.*sdf
24+
*.ipch
25+
.vs/
26+
project.lock.json
27+
28+
bower_components/
1029
node_modules/

admin-ui.dockerfile

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# base image
2+
FROM node:10-alpine as builder
3+
4+
# install and cache app dependencies
5+
COPY ["src/Frontend/Jp.AdminUI/package.json", "./"]
6+
COPY ["src/Frontend/Jp.AdminUI/package-lock.json", "./"]
7+
8+
## Storing node modules on a separate layer will prevent unnecessary npm installs at each build
9+
10+
RUN npm ci && mkdir /app && mv ./node_modules ./app/
11+
12+
WORKDIR /app
13+
14+
# add app
15+
COPY ["src/Frontend/Jp.AdminUI/", "/app"]
16+
17+
# rebuild node
18+
RUN npm rebuild node-sass
19+
# generate build
20+
RUN npm run ng build -- --configuration=docker
21+
22+
##################
23+
### production ###
24+
##################
25+
26+
# base image
27+
FROM nginx:1.13.3-alpine
28+
29+
## Remove default nginx website
30+
RUN rm -rf /usr/share/nginx/html/*
31+
32+
# copy artifact build from the 'build environment'
33+
COPY --from=builder /app/nginx/nginx.conf /etc/nginx/conf.d/
34+
COPY --from=builder /app/dist /usr/share/nginx/html
35+
36+
37+
# expose port 80
38+
EXPOSE 80/tcp
39+
40+
# run nginx
41+
CMD ["nginx", "-g", "daemon off;"]

docker-compose.yml

Lines changed: 32 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ services:
55
#############################
66
# Database
77
#############################
8-
database:
8+
jpdatabase:
99
image: mysql
1010
command: --default-authentication-plugin=mysql_native_password
1111
restart: always
@@ -18,26 +18,25 @@ services:
1818
#############################
1919
# Server SSO
2020
#############################
21-
sso:
21+
jpproject:
2222
image: "jpproject-sso"
2323
build:
2424
context: .
2525
dockerfile: sso.dockerfile
2626
ports:
27-
- "5001:5001"
28-
- "5000:5000"
27+
- "5000:443"
28+
- "5001:80"
2929
links:
30-
- database
30+
- jpdatabase
3131
depends_on:
32-
- database
32+
- jpdatabase
3333
environment:
3434
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"
35+
CUSTOMCONNSTR_DATABASE_CONNECTION: "server=jpdatabase,port=3306;database=jpproject;user=jp;password=10203040"
3836
ASPNETCORE_Kestrel__Certificates__Default__Password: ".pxCpE]yttwC&b&hriw#,7K^_}A7xezRH3=EisJKn3]8.H}^Unzd+ebw]zzv_=d3"
3937
ASPNETCORE_Kestrel__Certificates__Default__Path: "/root/.dotnet/https/jpproject.pfx"
40-
ASPNETCORE_URLS: https://+:5000;http://+:5001
38+
ASPNETCORE_ENVIRONMENT: "Development"
39+
ASPNETCORE_URLS: https://+:443;http://+:80
4140

4241
#############################
4342
# Management API
@@ -51,21 +50,39 @@ services:
5150
- "5003:5003"
5251
- "5002:5002"
5352
depends_on:
54-
- database
53+
- jpdatabase
5554
environment:
5655
DATABASE_TYPE: "MySql"
57-
CUSTOMCONNSTR_DATABASE_CONNECTION: "server=database,port=3306;database=jpproject;user=jp;password=10203040"
56+
CUSTOMCONNSTR_DATABASE_CONNECTION: "server=jpdatabase,port=3306;database=jpproject;user=jp;password=10203040"
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"
5859
ASPNETCORE_ENVIRONMENT: "Development"
59-
AUTHORITY: "http://localhost:5000"
60+
AUTHORITY: "https://jpproject:5000"
6061
ASPNETCORE_URLS: "https://+:5003;http://+:5002"
6162

6263
#############################
6364
# User management UI
6465
#############################
65-
user-management-ui:
66+
user-ui:
6667
container_name: jpproject-user-management-ui
6768
build:
6869
context: .
6970
dockerfile: ui-user-management.dockerfile
71+
depends_on:
72+
- jpproject-api
73+
- jpproject
74+
ports:
75+
- 4200:80
76+
#############################
77+
# Admin Ui
78+
#############################
79+
admin-ui:
80+
container_name: jpproject-admin-ui
81+
build:
82+
context: .
83+
dockerfile: ui-user-management.dockerfile
84+
depends_on:
85+
- jpproject-api
86+
- jpproject
7087
ports:
71-
- 4300:80
88+
- 4300:80

keys/jpproject.cer

-786 Bytes
Binary file not shown.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
server {
2+
3+
listen 80;
4+
5+
sendfile on;
6+
7+
default_type application/octet-stream;
8+
9+
10+
gzip on;
11+
gzip_http_version 1.1;
12+
gzip_disable "MSIE [1-6]\.";
13+
gzip_min_length 1100;
14+
gzip_vary on;
15+
gzip_proxied expired no-cache no-store private auth;
16+
gzip_types text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript;
17+
gzip_comp_level 9;
18+
19+
20+
root /usr/share/nginx/html;
21+
22+
23+
location / {
24+
try_files $uri $uri/ /index.html =404;
25+
}
26+
27+
}

src/Frontend/Jp.AdminUI/package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// The file contents for the current environment will overwrite these during build.
2+
// The build system defaults to the dev environment which uses `environment.ts`, but if you do
3+
// `ng build --env=prod` then `environment.prod.ts` will be used instead.
4+
// The list of which env maps to which file can be found in `.angular-cli.json`.
5+
6+
export const environment = {
7+
production: false,
8+
ResourceServer: "https://localhost:5003/",
9+
IssuerUri: "https://jpproject:5000",
10+
RequireHttps: false,
11+
Uri: "http://localhost:4300"
12+
};
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using Microsoft.EntityFrameworkCore;
2+
using System.Data.Common;
3+
4+
namespace Jp.UI.SSO.Configuration
5+
{
6+
public class DbHealthChecker
7+
{
8+
public bool TestConnection(DbContext context)
9+
{
10+
DbConnection conn = context.Database.GetDbConnection();
11+
try
12+
{
13+
conn.Open(); // Check the database connection
14+
15+
return true;
16+
}
17+
catch
18+
{
19+
return false;
20+
}
21+
}
22+
}
23+
}

src/Frontend/Jp.UI.SSO/Util/DbMigrationHelpers.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
using System.Linq;
1111
using System.Security.Claims;
1212
using System.Threading.Tasks;
13+
using Jp.UI.SSO.Configuration;
1314

1415
namespace Jp.UI.SSO.Util
1516
{
@@ -42,6 +43,7 @@ public static async Task EnsureSeedData(IServiceProvider serviceProvider)
4243
var id4Context = scope.ServiceProvider.GetRequiredService<JpContext>();
4344
var storeDb = scope.ServiceProvider.GetRequiredService<EventStoreContext>();
4445

46+
await WaitForDb(id4Context);
4547
await id4Context.Database.MigrateAsync();
4648
await userContext.Database.MigrateAsync();
4749
await storeDb.Database.MigrateAsync();
@@ -125,5 +127,25 @@ private static async Task EnsureSeedIdentityServerData(JpContext context)
125127
await context.SaveChangesAsync();
126128
}
127129
}
130+
131+
private static async Task WaitForDb(DbContext context)
132+
{
133+
var maxAttemps = 12;
134+
var delay = 5000;
135+
136+
var healthChecker = new DbHealthChecker();
137+
for (int i = 0; i < maxAttemps; i++)
138+
{
139+
if (healthChecker.TestConnection(context))
140+
{
141+
return;
142+
}
143+
await Task.Delay(delay);
144+
}
145+
146+
// after a few attemps we give up
147+
throw new Exception("Error wating database");
148+
149+
}
128150
}
129151
}

src/Frontend/Jp.UI.SSO/jpProject_sso_log.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13287,3 +13287,6 @@ MySql.Data.MySqlClient.MySqlException (0x80004005): Access denied for user 'brun
1328713287
2019-03-26 17:05:45.339 -03:00 [DBG] Using Identity.External as default ASP.NET Core scheme for sign-out
1328813288
2019-03-26 17:05:45.342 -03:00 [DBG] Using Identity.Application as default ASP.NET Core scheme for challenge
1328913289
2019-03-26 17:05:45.343 -03:00 [DBG] Using Identity.Application as default ASP.NET Core scheme for forbid
13290+
2019-03-27 02:38:38.654 -03:00 [INF] SigninCredentialExtension keyType is File
13291+
2019-03-27 02:38:38.773 -03:00 [INF] SigninCredentialExtension adding key from file jpproject.pfx
13292+
2019-03-27 02:38:38.812 -03:00 [INF] SigninCredentialExtension added

0 commit comments

Comments
 (0)