Skip to content

fernetowac/settlechat

Repository files navigation

1. Setup

1.1. Database setup

1.1.1. Run docker SQL Server

Create folder C:\SettleChat\SqlVolume where subfolders for container volumes will be mapped

.\Installation\01_Database\01_RunDockerSqlServer.cmd

[Extra] Command for removal of docker SQL Server (in case needed to restart with clean DB)**

.\Installation\01_Database\__01_RemoveDockerSqlServer.cmd

1.1.2. Prepare DB

This will create:

  1. login
  2. database
  3. user
.\Installation\01_Database\02_PrepareDB.cmd

1.1.3. Initialize empty DB schema

There are 2 options:

  1. Using SQL scripts (using source codes)
  2. Executing SettleChat.exe with argument (no source codes needed - usefull for migrations in CI/CD)

1.1.3.1. Initialize DB schema using SQL scripts

Make sure latests schema is generated by executing

.\Development\GenerateSchemaCreateScript.cmd

Then execute creation of schema in DB

.\Installation\01_Database\03_CreateDBSchema.cmd

1.1.3.2. Initialize DB schema by executing SettleChat.exe with argument

Take a look how to migrate DB schema to latest at Deployment section

1.2. How to connect to DB:

Host: localhost,1433
Login: SettleAdmin
Password: mUtLw5i4YL/oo/S4JnzNPP0ImZ7K5fx5grTC+dXMjZA=

1.3. Logging setup

1.3.1. Run docker SEQ server

Create empty folder for persisting Seq data: C:\SettleChatSecrets\seq

.\Installation\02_Logging\01_RunDockerSeq.cmd

Go to http://127.0.0.1:5340 and enable authentication under Settings -> USERS

1.3.2. Sentry

Update Sentry DSN in .\SettleChat\ClientApp\src\index.tsx


1.4. Configuration

1.4.1. Create Google ClientId and ClientSecret:

1.4.2. Create configuration files:

  • C:\SettleChatSecrets\appsettings.json (optional, can contain common secret settings)
  • C:\SettleChatSecrets\appsettings.Development.json (optional, can contain secret settings for development)
  • C:\SettleChatSecrets\appsettings.Production.json (optional, can contain secret settings for production)

Content of appsettings.Production.json:

{
  "IdentityServer": {    
    "Key": {
      "Type": "File",
      "FilePath": "C:\\SettleChatSecrets\\MyIdentityServerCert.pfx",
      "Password": "<password used by .pfx>"
    }
  },
  "GoogleOAuth:ClientId":"<client id from google developer console>",
  "GoogleOAuth:ClientSecret":"<client secret from google developer console>"
}

Note: Certificate configuration for IdentityServer is read by AddSigningCredentials() inside of AddApiAuthorization()

C:\SettleChatSecrets\MyIdentityServerCert.pfx (optional - needed for IdentityServer for production - google how to create certificate for .NET Core app, e.g. https://benjii.me/2017/06/creating-self-signed-certificate-identity-server-azure/)

2. Development

2.1. Visual Studio

Make sure Typescript 4.2 for Visual Studio is installed

Typescript 4.2 is referenced in .csproj in order to make tsconfig.json setting "--jsx":"react-jsx" (which is forced by Create-React-App npm run start command) work in Visual Studio

Install JavaScript Prettier VS extension

[Optional] set it to format on save

2.2. Database migrations:

  1. when model changed, create migration by executing in VS Package Manager Console
Add-Migration <MigrationName>
  1. propagate changes to DB>
    1. in VS Package Manager Console select Default project SettleChat.Migrations
    2. Update-Database
      

3. Publish

Publish using VisualStudio publish profile called FolderProfile

4. Run for Production

(when published using FolderProfile Visual Studio publish profile)

.\SettleChat\bin\Release\netcoreapp3.1\publish\RunProduction.bat

5. Deployment

5.1. Migrate DB schema to latest

Make sure latest SettleChat.exe is built

[Extra] It's possible to check if there are pending DB migrations to be applied by running

.\Deployment\DBMigrationPendingCheck.cmd

Then execute

.\Deployment\DBMigration.cmd

6. Postman

Exported Postman configuration is here: .\SettleChat local development.postman_collection.json

7. Bundle analysis

  1. Build

     npm run build
    
  2. Analyze

     npm run analyze
    

8. Troubleshooting

8.1. Cannot login with user SettleAdmin after DB restore

Execute on SQL Server

USE [SettleChat] 
ALTER USER [SettleAdmin] WITH LOGIN = SettleAdmin
GO

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published