Skip to content

Commit

Permalink
Windows Instructions (ivanpaulovich#258)
Browse files Browse the repository at this point in the history
Windows setup scripts
  • Loading branch information
ivanpaulovich authored Jul 5, 2021
1 parent 7d52fa0 commit 9fc48e1
Show file tree
Hide file tree
Showing 33 changed files with 214 additions and 244 deletions.
8 changes: 3 additions & 5 deletions .docker/docker-compose.dcproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,9 @@
<None Include="https\localhost.crt" />
<None Include="https\localhost.key" />
<None Include="https\localhost.pfx" />
<None Include="makecert.sh" />
<None Include="setup.sh" />
<None Include="ssl-selfsigned.cnf" />
<None Include="startup-production.sh" />
<None Include="startup.sh" />
<None Include="trustcert.sh" />
<None Include="trustcert-windows.ps1" />
<None Include="setup.production.sh" />
<None Include="setup.ps1" />
</ItemGroup>
</Project>
7 changes: 0 additions & 7 deletions .docker/hostsadd.sh

This file was deleted.

19 changes: 0 additions & 19 deletions .docker/https/localhost.crt

This file was deleted.

28 changes: 0 additions & 28 deletions .docker/https/localhost.key

This file was deleted.

Binary file removed .docker/https/localhost.pfx
Binary file not shown.
3 changes: 0 additions & 3 deletions .docker/makecert.sh

This file was deleted.

28 changes: 28 additions & 0 deletions .docker/setup.production.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash

# 1. makecert

openssl req -x509 -newkey rsa:2048 -keyout ./https/localhost.key -out ./https/localhost.crt -days 365 -subj "/CN=wallet.local/O=wallet.local/C=US" -config ./ssl-selfsigned.cnf -passout pass:MyCertificatePassword
openssl pkcs12 -export -out ./https/localhost.pfx -inkey ./https/localhost.key -in ./https/localhost.crt -name "Localhost selfsigned certificate" -password pass:MyCertificatePassword -passin pass:MyCertificatePassword
openssl rsa -in ./https/localhost.key -out ./https/localhost.key -passin pass:MyCertificatePassword

# 2. [trustcert](https://gist.github.com/epcim/03f66dfa85ad56604c7b8e6df79614e0)

sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain ./https/localhost.crt

# 3. hostadd

cat << EOF >> /etc/hosts
# To allow the same website for Wallet SPA/IdentityServer and AccountsAPI
127.0.0.1 wallet.local
# End of section
EOF
exit

# 4. build

docker-compose build --no-cache

# 5. run

docker-compose -f docker-compose.yml -f docker-compose.production.yml up -d
21 changes: 21 additions & 0 deletions .docker/setup.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# 1. makecert

openssl req -x509 -newkey rsa:2048 -keyout ./https/localhost.key -out ./https/localhost.crt -days 365 -subj "/CN=wallet.local/O=wallet.local/C=US" -config ./ssl-selfsigned.cnf -passout pass:MyCertificatePassword
openssl pkcs12 -export -out ./https/localhost.pfx -inkey ./https/localhost.key -in ./https/localhost.crt -name "Localhost selfsigned certificate" -password pass:MyCertificatePassword -passin pass:MyCertificatePassword
openssl rsa -in ./https/localhost.key -out ./https/localhost.key -passin pass:MyCertificatePassword

# 2. [trustcert](https://gist.github.com/epcim/03f66dfa85ad56604c7b8e6df79614e0)

certutil -addstore -f "ROOT" ./https/localhost.crt

# 3. hostadd

Add-Content -Path $env:windir\System32\drivers\etc\hosts -Value "`n127.0.0.1`twallet.local" -Force

# 4. build

docker-compose build --no-cache

# 5. run

docker-compose -f docker-compose.yml -f docker-compose.override.yml up -d
28 changes: 28 additions & 0 deletions .docker/setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash

# 1. makecert

openssl req -x509 -newkey rsa:2048 -keyout ./https/localhost.key -out ./https/localhost.crt -days 365 -subj "/CN=wallet.local/O=wallet.local/C=US" -config ./ssl-selfsigned.cnf -passout pass:MyCertificatePassword
openssl pkcs12 -export -out ./https/localhost.pfx -inkey ./https/localhost.key -in ./https/localhost.crt -name "Localhost selfsigned certificate" -password pass:MyCertificatePassword -passin pass:MyCertificatePassword
openssl rsa -in ./https/localhost.key -out ./https/localhost.key -passin pass:MyCertificatePassword

# 2. [trustcert](https://gist.github.com/epcim/03f66dfa85ad56604c7b8e6df79614e0)

sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain ./https/localhost.crt

# 3. hostadd

cat << EOF >> /etc/hosts
# To allow the same website for Wallet SPA/IdentityServer and AccountsAPI
127.0.0.1 wallet.local
# End of section
EOF
exit

# 4. build

docker-compose build --no-cache

# 5. run

docker-compose -f docker-compose.yml -f docker-compose.override.yml up -d
17 changes: 0 additions & 17 deletions .docker/startup-production.sh

This file was deleted.

16 changes: 0 additions & 16 deletions .docker/startup.sh

This file was deleted.

7 changes: 0 additions & 7 deletions .docker/trustcert-windows.ps1

This file was deleted.

3 changes: 0 additions & 3 deletions .docker/trustcert.sh

This file was deleted.

33 changes: 16 additions & 17 deletions Clean-Architecture-Manga.sln
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29519.87
MinimumVisualStudioVersion = 15.0.26124.0
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".github", ".github", "{23ED54A6-81AF-4160-97A6-FD3C25C33E30}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{F6826529-32A9-419B-B7E5-63BE9A0FDA93}"
ProjectSection(SolutionItems) = preProject
.github\workflows\dotnet-core.yml = .github\workflows\dotnet-core.yml
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "accounts-api", "accounts-api", "{51331007-CACA-4676-934B-217999A6B1E2}"
ProjectSection(SolutionItems) = preProject
accounts-api\.editorconfig = accounts-api\.editorconfig
Expand Down Expand Up @@ -54,8 +47,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".vscode", ".vscode", "{02D5
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IdentityServer", "identity-server\IdentityServer.csproj", "{01537DBF-3C0F-4B83-A089-0D12E5CA06C6}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".docker", ".docker", "{FAA0BAC6-0AA8-4908-A287-D550E9F9CBA8}"
EndProject
Project("{E53339B2-1760-4266-BCC7-CA923CBCF16C}") = "docker-compose", ".docker\docker-compose.dcproj", "{A0517AF3-3B35-443A-80DC-FF94F10CF056}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Domain", "accounts-api\src\Domain\Domain.csproj", "{0925FCA6-083A-4478-80F3-2391987AAF2C}"
Expand All @@ -71,16 +62,26 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "accounts-api-seed", "accoun
accounts-api-seed\Dockerfile = accounts-api-seed\Dockerfile
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "wallet-spa", "wallet-spa", "{231C4C02-5F48-45CE-AF73-65B441017D57}"
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{3A9E410D-D37D-469C-BAE3-153943AE70FF}"
ProjectSection(SolutionItems) = preProject
.all-contributorsrc = .all-contributorsrc
.dockerignore = .dockerignore
.gitignore = .gitignore
CHANGELOG.md = CHANGELOG.md
FUNDING.yml = FUNDING.yml
LICENSE = LICENSE
README.md = README.md
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "wallett-spa", "wallett-spa", "{E578FEEE-CF6A-4017-97F1-E5A9B0D2F398}"
ProjectSection(SolutionItems) = preProject
wallet-spa\.dockerignore = wallet-spa\.dockerignore
wallet-spa\.env = wallet-spa\.env
wallet-spa\.env.vs.debug = wallet-spa\.env.vs.debug
wallet-spa\.env.development = wallet-spa\.env.development
wallet-spa\.env.docker = wallet-spa\.env.docker
wallet-spa\.env.localhost = wallet-spa\.env.localhost
wallet-spa\.gitignore = wallet-spa\.gitignore
wallet-spa\Dockerfile = wallet-spa\Dockerfile
wallet-spa\package-lock.json = wallet-spa\package-lock.json
wallet-spa\package.json = wallet-spa\package.json
wallet-spa\README.md = wallet-spa\README.md
wallet-spa\vs.debug.env = wallet-spa\vs.debug.env
EndProjectSection
EndProject
Global
Expand Down Expand Up @@ -134,7 +135,6 @@ Global
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{F6826529-32A9-419B-B7E5-63BE9A0FDA93} = {23ED54A6-81AF-4160-97A6-FD3C25C33E30}
{F4408BAF-2D26-4D97-808C-7A96C4A7F636} = {51331007-CACA-4676-934B-217999A6B1E2}
{54ECA5D5-FCB9-4427-98A1-6915E0C2C71B} = {51331007-CACA-4676-934B-217999A6B1E2}
{B3ABDDAF-9164-4FC4-862D-07A2D9F62F5D} = {51331007-CACA-4676-934B-217999A6B1E2}
Expand All @@ -147,7 +147,6 @@ Global
{BF05183E-699A-43A8-A5F3-1DB71B0F38B0} = {54ECA5D5-FCB9-4427-98A1-6915E0C2C71B}
{02D548DA-5DE0-486E-A5D5-9BEDFFC0CA2A} = {51331007-CACA-4676-934B-217999A6B1E2}
{01537DBF-3C0F-4B83-A089-0D12E5CA06C6} = {5829A64A-52DE-4656-A6C0-C06B1A6195E7}
{A0517AF3-3B35-443A-80DC-FF94F10CF056} = {FAA0BAC6-0AA8-4908-A287-D550E9F9CBA8}
{0925FCA6-083A-4478-80F3-2391987AAF2C} = {F4408BAF-2D26-4D97-808C-7A96C4A7F636}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
Expand Down
81 changes: 18 additions & 63 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@

Sample implementation of the **Clean Architecture Principles with .NET Core**. Use cases as central organizing structure, decoupled from frameworks and technology details. Built by small components that are developed and tested in isolation.

We maintain two versions:
We support two versions:

- [Latest .NET Core 3.1 release](https://github.com/ivanpaulovich/clean-architecture-manga) - Check the .NET Core SDK on `global.json`.
- [.NET 5](https://github.com/ivanpaulovich/clean-architecture-manga/tree/dotnet5) - Experimental features and .NET 5.
- [.NET Core 3.1](https://github.com/ivanpaulovich/clean-architecture-manga) - .NET Core.
- [.NET 5](https://github.com/ivanpaulovich/clean-architecture-manga/tree/dotnet5) - .NET 5 version.

> Hit the `WATCH` button to get the latest Clean Architecture updates. <img src="https://emojis.slackmojis.com/emojis/images/1471045863/884/ninja.gif?1471045863" width="32" height="32" />
Manga is a Virtual Wallet software in which the customer register an account then manage the balance by `Deposits`, `Withdraws` and `Transfers`.
Manga is a Virtual Wallet Solution in which the customer register an account then manage the balance by `Deposits`, `Withdraws` and `Transfers` operations.

The Web API's demo is hosted on Azure servers and there's a beautiful [Swagger Client](https://clean-architecture-manga.azurewebsites.net/swagger/index.html) available.
[![Swagger Demo](https://raw.githubusercontent.com/ivanpaulovich/clean-architecture-manga/docs/docs/clean-architecture-manga-swagger-v2.jpg)](https://clean-architecture-manga.azurewebsites.net/swagger/index.html)
Expand All @@ -19,7 +19,6 @@ We also support the React client:

[![React+Redux Demo](https://raw.githubusercontent.com/ivanpaulovich/clean-architecture-manga/docs/docs/clean-architecture-manga-react.png)](https://clean-architecture-manga.azurewebsites.net)


<p align="center">
Run the Docker container in less than 2 minutes using Play With Docker:
<br>
Expand All @@ -31,73 +30,29 @@ We also support the React client:

To startup the whole solution, execute the following command:

```sh
$ cd .docker; ./makecert.sh && ./trustcert.sh && sudo ./hostsadd.sh; popd;
$ cd .docker; ./startup.sh; popd;
```

Then the following containers should be running `docker ps`:

| Application | URL |
|------------------ | -------------------------------------- |
| NGINX | https://wallet.local:8081 |
| Wallet SPA | https://wallet.local:8081 |
| Accounts API | https://wallet.local:8081/accounts-api |
| Identity Server | https://wallet.local:8081/identity-server |
| SQL Server | Server=localhost;User Id=sa;Password=<YourStrong!Passw0rd>;Database=Accounts; |

Browse to `https://wallet.local:8081` then click on Log In. Trust the [self-signed certificate](https://stackoverflow.com/questions/21397809/create-a-trusted-self-signed-ssl-cert-for-localhost-for-use-with-express-node).

If you prefer dotnet commands then start each service individually:

<details>
<summary>Expand to get the dotnet run steps.</summary>

### Generate Self Signed Certificate

```sh
dotnet dev-certs https --clean
dotnet dev-certs https -ep $env:USERPROFILE\.aspnet\https\aspnetapp.pfx -p MyCertificatePassword
dotnet dev-certs https --trust
```

### Spin up SQL Server in a Docker container
Windows:

```sh
docker pull mcr.microsoft.com/mssql/server:2019-latest
docker run -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=<YourStrong!Passw0rd>' -p 1433:1433 --name sql1 -d mcr.microsoft.com/mssql/server:2019-latest
```ps1
PS cd docker && ./setup.ps1
```

### Create and Seed Accounts Database
MacOS:

```sh
dotnet tool update --global dotnet-ef --version 3.1.6
dotnet ef database update --project accounts-api/src/Infrastructure --startup-project accounts-api/src/WebApi
$ cd docker && ./setup.sh
```

### Running Services
Then the following containers should be running on `docker ps`:

#### Identity Server

```sh
dotnet run --project identity-server/src/IdentityServer.csproj
```
#### Account API

```sh
dotnet run --project accounts-api/src/WebApi/WebApi.csproj
```

#### Wallett SPA

```sh
pushd wallet-spa/src/ClientApp
npm install
popd
dotnet run --project wallet-spa/src/WalletSPA.csproj --launch-profile WalletSPA
```
| Application | URL |
|-------------------- | ----------------------------------------------------------------------------- |
| NGINX | https://wallet.local:8081 |
| Wallet SPA | https://wallet.local:8081 |
| Accounts API | https://wallet.local:8081/accounts-api |
| Identity Server | https://wallet.local:8081/identity-server |
| SQL Server | Server=localhost;User Id=sa;Password=<YourStrong!Passw0rd>;Database=Accounts; |

</details>
Browse to [https://wallet.local:8081](https://wallet.local:8081) then click on Log In. If asked trust the [self-signed certificate](https://stackoverflow.com/questions/21397809/create-a-trusted-self-signed-ssl-cert-for-localhost-for-use-with-express-node).

## Motivation

Expand Down
Loading

0 comments on commit 9fc48e1

Please sign in to comment.