Skip to content

Commit 9014fb6

Browse files
authored
Fix missing bootstrap in image, enable google auth (#455)
* Add missing wwwroot * Improve README and CONTRIBUTING * Make home general * Enable google auth * Remove leading space in CONTRIBUTING * Update github workflow ref * Split long line in azure devops ci
1 parent 5f01304 commit 9014fb6

60 files changed

Lines changed: 59829 additions & 148 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.azure/pipelines/ci.yml

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ variables:
2020
value: "Keeptrack.slnx"
2121
- name: "TestProjects"
2222
value: "test/*Tests/*.csproj"
23-
- name: "UnitTestProjects"
24-
value: "test/*UnitTests/*.csproj"
2523

2624
stages:
2725
- stage: "unit_testing"
@@ -46,13 +44,18 @@ stages:
4644
env:
4745
DOTNET_CLI_TELEMETRY_OPTOUT: 1
4846
DOTNET_NOLOGO: 1
49-
- task: DotNetCoreCLI@2
50-
displayName: "Run .NET unit tests"
47+
- task: CmdLine@2
48+
displayName: "Run .NET test projects"
5149
inputs:
52-
command: "test"
53-
projects: "$(UnitTestProjects)"
54-
arguments: "--configuration $(BuildConfiguration)"
50+
script: >
51+
dotnet test
52+
--configuration $(BuildConfiguration)
53+
-- --filter-query "/[Category=UnitTests]"
5554
env:
55+
AllowedOrigins__0: "5207"
56+
Features__IsScalarEnabled: true
57+
Features__IsHttpsRedirectionEnabled: false
58+
ASPNETCORE_ENVIRONMENT: Development
5659
DOTNET_CLI_TELEMETRY_OPTOUT: 1
5760
DOTNET_NOLOGO: 1
5861

@@ -104,27 +107,17 @@ stages:
104107
inputs:
105108
command: "test"
106109
projects: "$(TestProjects)"
107-
arguments: '--configuration $(BuildConfiguration) --report-xunit-trx --coverage --coverage-output-format cobertura -- --filter-query "/[(Category=UnitTests)|(Mode=Readonly)]"'
110+
arguments: |
111+
--configuration $(BuildConfiguration)
112+
--report-xunit-trx --coverage --coverage-output-format cobertura
113+
-- --filter-query "/[(Category=UnitTests)|(Mode=Readonly)]"
108114
env:
109115
AllowedOrigins__0: "5207"
110116
Features__IsScalarEnabled: true
111117
Features__IsHttpsRedirectionEnabled: false
112118
ASPNETCORE_ENVIRONMENT: Development
113119
DOTNET_CLI_TELEMETRY_OPTOUT: 1
114120
DOTNET_NOLOGO: 1
115-
# - task: CmdLine@2
116-
# displayName: "Run .NET test projects"
117-
# inputs:
118-
# script: >
119-
# dotnet test
120-
# --configuration $(BuildConfiguration)
121-
# --report-xunit-trx
122-
# --coverage
123-
# --coverage-output-format cobertura
124-
# -- --filter-query "/[(Category=UnitTests)|(Mode=Readonly)]"
125-
# env:
126-
# DOTNET_CLI_TELEMETRY_OPTOUT: 1
127-
# DOTNET_NOLOGO: 1
128121
- task: PublishBuildArtifacts@1
129122
displayName: "Publish artifacts"
130123
condition: failed()

.dockerignore

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
1-
**/.dockerignore
2-
**/.env
3-
**/.git
4-
**/.gitignore
5-
**/.project
6-
**/.settings
7-
**/.toolstarget
8-
**/.vs
9-
**/.vscode
10-
**/.idea
11-
**/*.*proj.user
12-
**/*.dbmdl
13-
**/*.jfm
14-
**/azds.yaml
15-
**/bin
16-
**/charts
17-
**/docker-compose*
18-
**/Dockerfile*
19-
**/node_modules
20-
**/npm-debug.log
21-
**/obj
22-
**/secrets.dev.yaml
23-
**/values.dev.yaml
24-
LICENSE
25-
README.md
1+
**/.dockerignore
2+
**/.env
3+
**/.git
4+
**/.gitignore
5+
**/.project
6+
**/.settings
7+
**/.toolstarget
8+
**/.vs
9+
**/.vscode
10+
**/.idea
11+
**/*.*proj.user
12+
**/*.dbmdl
13+
**/*.jfm
14+
**/azds.yaml
15+
**/bin
16+
**/charts
17+
**/docker-compose*
18+
**/Dockerfile*
19+
**/node_modules
20+
**/npm-debug.log
21+
**/obj
22+
**/secrets.dev.yaml
23+
**/values.dev.yaml
24+
LICENSE
25+
README.md

.github/workflows/ci.yaml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44

55
on:
66
push:
7-
branches: [main]
7+
branches: [ main ]
88
pull_request:
9-
branches: [main]
9+
branches: [ main ]
1010
workflow_dispatch:
1111
inputs:
1212
run-code-quality:
@@ -37,13 +37,13 @@ jobs:
3737

3838
markup-lint:
3939
name: Markup
40-
uses: devpro/github-workflow-parts/.github/workflows/reusable-markup-lint.yml@b5937db15c2a060f3c9dd989ca06bac7eccc75a7
40+
uses: devpro/github-workflow-parts/.github/workflows/reusable-markup-lint.yml@62dbf6e833e49230ab34ef3c44093ebb727a095f
4141

4242
code-quality:
4343
name: Code
4444
needs: git-check
4545
if: needs.git-check.outputs.app_changed == 'true' || (github.event_name == 'workflow_dispatch' && inputs.run-code-quality)
46-
uses: devpro/github-workflow-parts/.github/workflows/reusable-dotnet-quality.yml@b5937db15c2a060f3c9dd989ca06bac7eccc75a7
46+
uses: devpro/github-workflow-parts/.github/workflows/reusable-dotnet-quality.yml@62dbf6e833e49230ab34ef3c44093ebb727a095f
4747
with:
4848
custom-commands: |
4949
./scripts/mongodb-install.sh
@@ -58,10 +58,11 @@ jobs:
5858
Infrastructure__MongoDB__DatabaseName=keeptrack_ci
5959
fossa-enabled: true
6060
sonar-enabled: true
61+
sonar-exclusions: "samples/**"
6162
sonar-organization: ${{ vars.SONAR_ORG }}
6263
sonar-project-key: ${{ vars.SONAR_PROJECT_KEY }}
6364
sonar-project-name: Keeptrack
64-
workflow-parts-version: b5937db15c2a060f3c9dd989ca06bac7eccc75a7
65+
workflow-parts-version: 62dbf6e833e49230ab34ef3c44093ebb727a095f
6566
secrets:
6667
fossa-api-key: ${{ secrets.FOSSA_API_KEY }}
6768
sonar-token: ${{ secrets.SONAR_TOKEN }}
@@ -89,7 +90,7 @@ jobs:
8990
- name: "Web Api"
9091
image-name: "keeptrack-webapi"
9192
image-definition: "src/WebApi/Dockerfile"
92-
uses: devpro/github-workflow-parts/.github/workflows/reusable-container-scan.yml@b5937db15c2a060f3c9dd989ca06bac7eccc75a7
93+
uses: devpro/github-workflow-parts/.github/workflows/reusable-container-scan.yml@62dbf6e833e49230ab34ef3c44093ebb727a095f
9394
with:
9495
image-definition: ${{ matrix.image-definition }}
9596
image-name: ${{ matrix.image-name }}

.github/workflows/pkg.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
permissions:
2929
id-token: write
3030
contents: read
31-
uses: devpro/github-workflow-parts/.github/workflows/reusable-container-publication.yml@b5937db15c2a060f3c9dd989ca06bac7eccc75a7
31+
uses: devpro/github-workflow-parts/.github/workflows/reusable-container-publication.yml@62dbf6e833e49230ab34ef3c44093ebb727a095f
3232
with:
3333
create-latest: ${{ github.ref_name == 'main' }}
3434
image-definition: ${{ matrix.image-definition }}

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,3 @@ Local.runsettings
1717
# NPM
1818
firebase.config.js
1919
node_modules/
20-
dist/

CONTRIBUTING.md

Lines changed: 75 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,64 @@
1-
# Contibutor guide
1+
# Contributor guide
22

33
[![GitLab Pipeline Status](https://gitlab.com/devpro-labs/software/keeptrack/badges/main/pipeline.svg)](https://gitlab.com/devpro-labs/software/keeptrack/-/pipelines)
44
[![Build Status](https://dev.azure.com/devprofr/open-source/_apis/build/status/keeptrack-ci?branchName=main)](https://dev.azure.com/devprofr/open-source/_build/latest?definitionId=26&branchName=main)
55

6-
## Design
6+
Follow this steps to run/debug/develop the application on your machine.
77

8-
This design of API has been inspired by the [Hexagonal Architecture](https://blog.octo.com/en/hexagonal-architecture-three-principles-and-an-implementation-example/).
8+
For an environment, look at [operations.md](docs/operations.md).
99

10-
NuGet Packages:
10+
## Design
1111

12-
- [MongoDB C# Driver](https://www.mongodb.com/docs/drivers/csharp/current/)
12+
The application source code is in the following .NET projects:
1313

14-
## Requirements
14+
Project name | Technology | Project type
15+
---------------------------|------------|------------------------------
16+
`BlazorApp` | ASP.NET 10 | Blazor Server web application
17+
`Common.System` | .NET 10 | Library
18+
`Domain` | .NET 10 | Library
19+
`Infrastructure.MongoDb` | .NET 10 | Library
20+
`WebApi` | ASP.NET 10 | Web application (REST API)
21+
`WebApi.Contracts` | .NET 10 | Library
1522

16-
- [.NET 10.0 SDK](https://dotnet.microsoft.com/download)
17-
- MongoDB 8.2 database
18-
- Local server
23+
The application is using the following .NET packages (via NuGet):
1924

20-
```bash
21-
cd D:/Programs/mongodb-8.2/bin
22-
md log
23-
md data
24-
mongod --logpath log/mongod.log --dbpath data --port 27017
25-
```
25+
Name | Description
26+
--------------------|--------------------
27+
`FirebaseAdmin` | Firebase
28+
`MongoDB.Bson` | MongoDB BSON
29+
`MongoDB.Driver` | MongoDB .NET Driver
30+
`Scalar.AspNetCore` | OpenAPI web UI
2631

27-
- [Docker](https://hub.docker.com/_/mongo/)
32+
## Requirements
33+
34+
1. [.NET 10.0 SDK](https://dotnet.microsoft.com/download)
2835

29-
```bash
30-
docker run --name mongodb -d -p 27017:27017 mongo:8.2
31-
```
36+
2. MongoDB database
3237

33-
- [MongoDB Atlas](https://cloud.mongodb.com/) cluster
38+
Several options:
3439

35-
- Database indexes
40+
- Local server
41+
42+
```bash
43+
cd D:/Programs/mongodb-8.2/bin
44+
md log
45+
md data
46+
mongod --logpath log/mongod.log --dbpath data --port 27017
47+
```
48+
49+
- [Docker](https://hub.docker.com/_/mongo/)
50+
51+
```bash
52+
docker run --name mongodb -d -p 27017:27017 mongo:8.2
53+
```
54+
55+
- [MongoDB Atlas](https://cloud.mongodb.com/) cluster
3656

37-
```bash
38-
docker run --rm --link mongodb -v "$(pwd)/scripts":/home/scripts mongo:8.2 bash -c "mongo mongodb://mongodb:27017/keeptrack /home/scripts/mongo-create-index.js"
39-
```
57+
3. IDE: Rider, Visual Studio, Visual Studio Code
4058

41-
## How to configure
59+
## Configuration
4260

43-
### Web API
61+
### Web API appsettings
4462

4563
Key | Description
4664
------------------------------------------|--------------------------
@@ -49,10 +67,14 @@ Key | Description
4967

5068
This values can be easily provided as environment variables (replace ":" by "__") or by configuration (json).
5169

52-
Template for `src/Api/appsettings.Development.json`:
70+
Template for `src/WebApi/appsettings.Development.json`:
5371

5472
```json
5573
{
74+
"AllowedOrigins": [
75+
"http://localhost:5207",
76+
"https://localhost:7042"
77+
],
5678
"Authentication": {
5779
"JwtBearer": {
5880
"Authority": "https://securetoken.google.com/<firebase-project-id>",
@@ -62,43 +84,54 @@ Template for `src/Api/appsettings.Development.json`:
6284
}
6385
}
6486
},
87+
"Features": {
88+
"IsScalarEnabled": true,
89+
"IsHttpsRedirectionEnabled": false
90+
},
6591
"Infrastructure": {
6692
"MongoDB": {
6793
"ConnectionString": "mongodb://localhost:27017",
68-
"DatabaseName": "keeptrack"
94+
"DatabaseName": "keeptrack_dev"
6995
}
7096
},
7197
"Logging": {
7298
"LogLevel": {
73-
"KeepTrack": "Debug",
74-
"Withywoods": "Debug"
99+
"Default": "Debug",
100+
"KeepTrack": "Debug"
75101
}
76102
}
77103
}
78104
```
79105

80-
### Blazor Server App
106+
### Blazor Server App appsettings
81107

82-
TODO
108+
Key | Required | Default value
109+
----------------------------------------|----------|--------------
110+
AllowedHosts | false | "*"
111+
Features:IsHttpsRedirectionEnabled | false | true
112+
Firebase:WebAppConfiguration:ApiKey | true | ""
113+
Firebase:WebAppConfiguration:AuthDomain | true | ""
114+
Firebase:WebAppConfiguration:ProjectId | true | ""
115+
Firebase:ServiceAccount | true | ""
116+
Logging:LogLevel:Default | false | "Information"
117+
Logging:LogLevel:Microsoft.AspNetCore | false | "Warning"
118+
WebApi:BaseUrl | true | ""
83119

84-
## How to build
120+
## Run
85121

86122
```bash
87123
dotnet restore
88-
dotnet build
89-
```
90124
91-
## How to debug
125+
dotnet build
92126
93-
```bash
94127
# run the API (https://localhost:5011/)
95128
dotnet run --project src/WebApi
96129
97130
# run the Blazor WebAssembly web app (https://localhost:5021)
98131
dotnet run --project src/BlazorApp
99132
```
100133

101-
## How to test
134+
## Tests
102135

103136
For integration tests, to manage the configuration (secrets) you can create a file at the root directory called `Local.runsettings` or define them as environment variables:
104137

@@ -107,7 +140,7 @@ For integration tests, to manage the configuration (secrets) you can create a fi
107140
<RunSettings>
108141
<RunConfiguration>
109142
<EnvironmentVariables>
110-
<AllowedOrigins__0>http://localhost:4200</AllowedOrigins__0>
143+
<AllowedOrigins__0>http://localhost:5207</AllowedOrigins__0>
111144
<Infrastructure__MongoDB__ConnectionString>mongodb://localhost:27017</Infrastructure__MongoDB__ConnectionString>
112145
<Infrastructure__MongoDB__DatabaseName>keeptrack_integrationtests</Infrastructure__MongoDB__DatabaseName>
113146
<Authentication__JwtBearer__Authority></Authentication__JwtBearer__Authority>
@@ -130,31 +163,9 @@ Or in Rider, in "File | Settings | Build, Execution, Deployment | Unit Testing |
130163

131164
Set KESTREL_WEBAPP_URL to target a specific instance (not use web app test instance).
132165

133-
And execute all tests (unit and integration ones):
134-
135-
```bash
136-
dotnet test --settings Local.runsettings
137-
```
138-
139-
## How to deploy
140-
141-
- Add the outbound IP to the MongoDB Atlas cluster
142-
- Add the application url to Firebase domains
143-
- Create web project in Firebase and grab ids to be set to environment.ts file
144-
- Create a GitHub OAuth application ([firebase.google.com](https://firebase.google.com/docs/auth/web/github-auth),
145-
[github.com](https://github.com/settings/applications/new))
146-
- Add URLs in Azure web app CORS page
147-
148-
## How to operate
149-
150-
- Backup MongoDB database
151-
152-
```bash
153-
docker run --rm -it --workdir=/data --volume $(pwd):/data mongo:8.2 /bin/sh -c "mongodump --uri mongodb+srv://<USER>:<PASSWORD>@<CLUSTER>.<PROJECT>.mongodb.net/test"
154-
```
155-
156-
- Restore MongoDB database
166+
## Container images
157167

158168
```bash
159-
docker run --rm -it --workdir=/data --volume $(pwd):/data mongo:8.2 /bin/sh -c "mongorestore --uri mongodb+srv://<USER>:<PASSWORD>@<CLUSTER>.<PROJECT>.mongodb.net"
169+
docker build . -t devprofr/keeptrack-blazorapp:local -f src/BlazorApp/Dockerfile
170+
docker build . -t devprofr/keeptrack-webapi:local -f src/WebApi/Dockerfile
160171
```

0 commit comments

Comments
 (0)