Skip to content

Commit

Permalink
feat: Auto PFX generation, .net 6 Program.cs, docker ready
Browse files Browse the repository at this point in the history
  • Loading branch information
brunobritodev committed Apr 4, 2022
1 parent 3be6704 commit 8af1e89
Show file tree
Hide file tree
Showing 53 changed files with 373 additions and 814 deletions.
89 changes: 51 additions & 38 deletions docker/docker-compose-local.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,21 @@ version: "3"

services:

rabbitmq:
image: rabbitmq:3-management
devstore-rabbit:
image: rabbitmq:management
container_name: devstore-rabbit
ports:
- 5672:5672
- 15672:15672
environment:
RABBITMQ_DEFAULT_USER: "devstore"
RABBITMQ_DEFAULT_PASS: "devstore"
RABBITMQ_DEFAULT_USER: devstore
RABBITMQ_DEFAULT_PASS: devstore

sql-server:
image: desenvolvedorio/devstore-sql-server:latest
image: mcr.microsoft.com/mssql/server:2017-latest
container_name: devstore-sql-server
build:
context: ../sql
dockerfile: ./Dockerfile
ports:
- 1433:1433
environment:
SA_PASSWORD: "MyDB@123"
ACCEPT_EULA: "Y"
Expand All @@ -27,7 +29,7 @@ services:
dockerfile: ./web/DevStore.WebApp.MVC/Dockerfile
restart: always
environment:
- ASPNETCORE_ENVIRONMENT=Production
- ASPNETCORE_ENVIRONMENT=Docker
- ASPNETCORE_URLS=http://*:5001
- LC_ALL=en_US.UTF-8
- LANG=en_US.UTF-8
Expand All @@ -48,14 +50,14 @@ services:
dockerfile: ./services/DevStore.Identity.API/Dockerfile
restart: always
environment:
- ASPNETCORE_ENVIRONMENT=Production
- ASPNETCORE_ENVIRONMENT=Docker
- ASPNETCORE_URLS=https://+:5101;http://+5102
- ASPNETCORE_Kestrel__Certificates__Default__Password=nerdstore
- ASPNETCORE_Kestrel__Certificates__Default__Path=/https/nerdstore-certificate.pfx
- ASPNETCORE_Kestrel__Certificates__Default__Password=9HoGMnb7Lu8NFdHBz4Vq2rtKivzMhmMXhtvuB4TZcLMmbWfFmDQCjJeLURAJ4GYe
- ASPNETCORE_Kestrel__Certificates__Default__Path=/https/devstore.academy-localhost.pfx
volumes:
- ./certs:/https:ro
depends_on:
- rabbitmq
- devstore-rabbit
- sql-server

api-cart:
Expand All @@ -66,14 +68,14 @@ services:
dockerfile: ./services/DevStore.ShoppingCart.API/Dockerfile
restart: always
environment:
- ASPNETCORE_ENVIRONMENT=Production
- ASPNETCORE_ENVIRONMENT=Docker
- ASPNETCORE_URLS=https://+:5201;http://+5202
- ASPNETCORE_Kestrel__Certificates__Default__Password=nerdstore
- ASPNETCORE_Kestrel__Certificates__Default__Path=/https/nerdstore-certificate.pfx
- ASPNETCORE_Kestrel__Certificates__Default__Password=9HoGMnb7Lu8NFdHBz4Vq2rtKivzMhmMXhtvuB4TZcLMmbWfFmDQCjJeLURAJ4GYe
- ASPNETCORE_Kestrel__Certificates__Default__Path=/https/devstore.academy-localhost.pfx
volumes:
- ./certs:/https:ro
depends_on:
- rabbitmq
- devstore-rabbit
- api-identity
- sql-server

Expand All @@ -85,14 +87,14 @@ services:
dockerfile: ./services/DevStore.Catalog.API/Dockerfile
restart: always
environment:
- ASPNETCORE_ENVIRONMENT=Production
- ASPNETCORE_ENVIRONMENT=Docker
- ASPNETCORE_URLS=https://+:5301;http://+5302
- ASPNETCORE_Kestrel__Certificates__Default__Password=nerdstore
- ASPNETCORE_Kestrel__Certificates__Default__Path=/https/nerdstore-certificate.pfx
- ASPNETCORE_Kestrel__Certificates__Default__Password=9HoGMnb7Lu8NFdHBz4Vq2rtKivzMhmMXhtvuB4TZcLMmbWfFmDQCjJeLURAJ4GYe
- ASPNETCORE_Kestrel__Certificates__Default__Path=/https/devstore.academy-localhost.pfx
volumes:
- ./certs:/https:ro
depends_on:
- rabbitmq
- devstore-rabbit
- sql-server

api-customers:
Expand All @@ -103,14 +105,14 @@ services:
dockerfile: ./services/DevStore.Customers.API/Dockerfile
restart: always
environment:
- ASPNETCORE_ENVIRONMENT=Production
- ASPNETCORE_ENVIRONMENT=Docker
- ASPNETCORE_URLS=https://+:5401;http://+5402
- ASPNETCORE_Kestrel__Certificates__Default__Password=nerdstore
- ASPNETCORE_Kestrel__Certificates__Default__Path=/https/nerdstore-certificate.pfx
- ASPNETCORE_Kestrel__Certificates__Default__Password=9HoGMnb7Lu8NFdHBz4Vq2rtKivzMhmMXhtvuB4TZcLMmbWfFmDQCjJeLURAJ4GYe
- ASPNETCORE_Kestrel__Certificates__Default__Path=/https/devstore.academy-localhost.pfx
volumes:
- ./certs:/https:ro
depends_on:
- rabbitmq
- devstore-rabbit
- api-identity
- sql-server

Expand All @@ -122,14 +124,14 @@ services:
dockerfile: ./api-gateways/DevStore.Bff.Checkout/Dockerfile
restart: always
environment:
- ASPNETCORE_ENVIRONMENT=Production
- ASPNETCORE_ENVIRONMENT=Docker
- ASPNETCORE_URLS=https://+:5501;http://+5502
- ASPNETCORE_Kestrel__Certificates__Default__Password=nerdstore
- ASPNETCORE_Kestrel__Certificates__Default__Path=/https/nerdstore-certificate.pfx
- ASPNETCORE_Kestrel__Certificates__Default__Password=9HoGMnb7Lu8NFdHBz4Vq2rtKivzMhmMXhtvuB4TZcLMmbWfFmDQCjJeLURAJ4GYe
- ASPNETCORE_Kestrel__Certificates__Default__Path=/https/devstore.academy-localhost.pfx
volumes:
- ./certs:/https:ro
depends_on:
- rabbitmq
- devstore-rabbit
- api-identity
- api-cart
- api-billing
Expand All @@ -143,14 +145,14 @@ services:
dockerfile: ./services/DevStore.Billing.API/Dockerfile
restart: always
environment:
- ASPNETCORE_ENVIRONMENT=Production
- ASPNETCORE_ENVIRONMENT=Docker
- ASPNETCORE_URLS=https://+:5601;http://+5602
- ASPNETCORE_Kestrel__Certificates__Default__Password=nerdstore
- ASPNETCORE_Kestrel__Certificates__Default__Path=/https/nerdstore-certificate.pfx
- ASPNETCORE_Kestrel__Certificates__Default__Password=9HoGMnb7Lu8NFdHBz4Vq2rtKivzMhmMXhtvuB4TZcLMmbWfFmDQCjJeLURAJ4GYe
- ASPNETCORE_Kestrel__Certificates__Default__Path=/https/devstore.academy-localhost.pfx
volumes:
- ./certs:/https:ro
depends_on:
- rabbitmq
- devstore-rabbit
- api-identity
- api-order
- sql-server
Expand All @@ -163,14 +165,14 @@ services:
dockerfile: ./services/DevStore.Orders.API/Dockerfile
restart: always
environment:
- ASPNETCORE_ENVIRONMENT=Production
- ASPNETCORE_ENVIRONMENT=Docker
- ASPNETCORE_URLS=https://+:5701;http://+5702
- ASPNETCORE_Kestrel__Certificates__Default__Password=nerdstore
- ASPNETCORE_Kestrel__Certificates__Default__Path=/https/nerdstore-certificate.pfx
- ASPNETCORE_Kestrel__Certificates__Default__Password=9HoGMnb7Lu8NFdHBz4Vq2rtKivzMhmMXhtvuB4TZcLMmbWfFmDQCjJeLURAJ4GYe
- ASPNETCORE_Kestrel__Certificates__Default__Path=/https/devstore.academy-localhost.pfx
volumes:
- ./certs:/https:ro
depends_on:
- rabbitmq
- devstore-rabbit
- sql-server
- api-identity

Expand All @@ -187,5 +189,16 @@ services:
depends_on:
- web-mvc

generate-pfx:
image: emberstack/openssl
container_name: generate-pfx
volumes:
- ./certs:/https:rw
command: >
sh -c "[ -e "./https/devstore.academy-localhost.pfx" ] && echo File Already exist || (openssl genrsa -out devstore.rsa 2048 &&
openssl req -sha256 -new -key devstore.rsa -out devstore.csr -subj '/CN=localhost' &&
openssl x509 -req -sha256 -days 1825 -in devstore.csr -signkey devstore.rsa -out devstore.crt &&
openssl pkcs12 -export -out /https/devstore.academy-localhost.pfx -inkey devstore.rsa -in devstore.crt -password pass:9HoGMnb7Lu8NFdHBz4Vq2rtKivzMhmMXhtvuB4TZcLMmbWfFmDQCjJeLURAJ4GYe)"
volumes:
dpkeys:
dpkeys:
Binary file added docker/pfx/devstore.academy.localhost
Binary file not shown.
17 changes: 17 additions & 0 deletions docker/pfx/devstore.crt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
-----BEGIN CERTIFICATE-----
MIICrzCCAZcCFAWxMLTPB0q8Ora4PRrIRz2KwZUEMA0GCSqGSIb3DQEBCwUAMBQx
EjAQBgNVBAMMCWxvY2FsaG9zdDAeFw0yMjA0MDQwMzEzMDNaFw0yNzA0MDMwMzEz
MDNaMBQxEjAQBgNVBAMMCWxvY2FsaG9zdDCCASIwDQYJKoZIhvcNAQEBBQADggEP
ADCCAQoCggEBAMSAbs5JB+0mZL1etOSClVSVSe5OnRzzd3jXI1v0uD++3LLFAbOh
KwKAvLC/fnn5bonhrlpr6wH+3JziGDdW0kknO1OvJGoXdosIZTT6OcBvl/O/q+5F
agvQiA7aXuE12DT9JA3JjMGoOd+0Q+6dwXiFE3q9RgmvoOHmzZVm/2E9g+WAAU9m
Uqks5CD2NXI3xokiArMeMkFxYV6od4AswtDMx8YQseDTh87NB+r2RfubJ8xpYYNe
OyEOzXto6UVUEPvOau/wwxO/urSbPkkjvy0aeysrTCY2LUE1wbPiPp0HpowYiEJU
or4mEbI+YgD5ydXitNheGxdLGcBPjV+AuAECAwEAATANBgkqhkiG9w0BAQsFAAOC
AQEAbmrIDyYQdgwSfP3qYc2DNpExjln+jOmnIH7kSqdMzV48KzBf3/Si50Y8IvMt
+wDN2z77OjhttePC4+kdUVmjRzGVktly+1gLb++fJVvZqT0wV6Ui8SE7xRqA/oL6
bUqkjHKgrL6VuSj0ruJ5X++Ue0hXBxM+e4O4Umt6qfj2t5IcO0t+slxeO6Cyo1u/
ZHzy7DDxOXExeEJ48xI1E8lVp7dxDT7Gm92vfhKzkvF6YGMlXCoiFDjYFd07d+8D
xofnYUD507nkNz60IRGWtEHzpBCONrAykCeBnEX0gB05O/BG+NrLSSCdYLS4DmkU
4cpVtbQ1VbeoGhfxFuE1syVwKQ==
-----END CERTIFICATE-----
15 changes: 15 additions & 0 deletions docker/pfx/devstore.csr
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
-----BEGIN CERTIFICATE REQUEST-----
MIICWTCCAUECAQAwFDESMBAGA1UEAwwJbG9jYWxob3N0MIIBIjANBgkqhkiG9w0B
AQEFAAOCAQ8AMIIBCgKCAQEAxIBuzkkH7SZkvV605IKVVJVJ7k6dHPN3eNcjW/S4
P77cssUBs6ErAoC8sL9+efluieGuWmvrAf7cnOIYN1bSSSc7U68kahd2iwhlNPo5
wG+X87+r7kVqC9CIDtpe4TXYNP0kDcmMwag537RD7p3BeIUTer1GCa+g4ebNlWb/
YT2D5YABT2ZSqSzkIPY1cjfGiSICsx4yQXFhXqh3gCzC0MzHxhCx4NOHzs0H6vZF
+5snzGlhg147IQ7Ne2jpRVQQ+85q7/DDE7+6tJs+SSO/LRp7KytMJjYtQTXBs+I+
nQemjBiIQlSiviYRsj5iAPnJ1eK02F4bF0sZwE+NX4C4AQIDAQABoAAwDQYJKoZI
hvcNAQELBQADggEBAEYYlcxafY3+Dx9vbbSpQRRh7iHPMQwUOdB3d3+XOK7Fh/N0
6LXVJBiNzQIprcM4LzatFXnTcCjjJc7WsLMK8ZzH+by3npUijQGA6Ns75J5erIQl
4r9WB5THGFONZOFazSBGWesWB1Oq1me7CK92C+TnOn7OIp8TSV+qT2iNHqgPnFRb
e2UayAiKg3EiVw4f0WpYT+CgbBONgjtfvnL+e01LH4XTCgeI2ppkRv+lQM1EhBhx
6Dl/DdCmqnA+IE+7GcrdMHut/QBSYxrita19sXxotlznpwjbfPjUSd2veUgPtHS5
Ed8b2FmNViNRoDGA1vMbXlS5bf8XMMr+7NQmjls=
-----END CERTIFICATE REQUEST-----
27 changes: 27 additions & 0 deletions docker/pfx/devstore.rsa
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
-----BEGIN RSA PRIVATE KEY-----
MIIEpAIBAAKCAQEAxIBuzkkH7SZkvV605IKVVJVJ7k6dHPN3eNcjW/S4P77cssUB
s6ErAoC8sL9+efluieGuWmvrAf7cnOIYN1bSSSc7U68kahd2iwhlNPo5wG+X87+r
7kVqC9CIDtpe4TXYNP0kDcmMwag537RD7p3BeIUTer1GCa+g4ebNlWb/YT2D5YAB
T2ZSqSzkIPY1cjfGiSICsx4yQXFhXqh3gCzC0MzHxhCx4NOHzs0H6v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9WdbTfQzZU7TCGCoTCpqZTJliV1JTYqko5mwzS2r1R
WEMgnSpyjF+A4Ln8At3MhoUpsvBo3SzfScPK4wzV7BxL/ZtkLMpnV8ekkVsWLIqi
M/lmzQKBgQCCzyUfHPXhlX66lV6fPb8cLcoHKz3U/UiPGL2J+wd5lOWp0tp/qV/V
FGWaxDptl1IGeb7TPNm5tsXppFOPk/ixzYHc/b9c3U9efISCRLeT3rYBdfXZpyw6
bqj9s4CgzmY/H3IKWTH6FzxMiKVsw/eh+/O+F9qy5nMht2wzDh1BXg==
-----END RSA PRIVATE KEY-----
17 changes: 17 additions & 0 deletions docker/teste.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
version: "3"

services:

genpfx:
image: emberstack/openssl
container_name: genpfx
volumes:
- ./certs:/certs:rw
command: >
sh -c "[ -e "./certs/devstore.academy.localhost" ] && echo File Already exist || openssl genrsa -out devstore.rsa 2048 &&
openssl req -sha256 -new -key devstore.rsa -out devstore.csr -subj '/CN=localhost' &&
openssl x509 -req -sha256 -days 1825 -in devstore.csr -signkey devstore.rsa -out devstore.crt &&
openssl pkcs12 -export -out /certs/devstore.academy.localhost -inkey devstore.rsa -in devstore.crt -password pass:9HoGMnb7Lu8NFdHBz4Vq2rtKivzMhmMXhtvuB4TZcLMmbWfFmDQCjJeLURAJ4GYe"
volumes:
certs:
8 changes: 0 additions & 8 deletions sql/Dockerfile

This file was deleted.

1 change: 0 additions & 1 deletion sql/entrypoint.sh

This file was deleted.

Loading

0 comments on commit 8af1e89

Please sign in to comment.