Skip to content

Commit

Permalink
Fix local deployment with docker compose
Browse files Browse the repository at this point in the history
  • Loading branch information
fredimachado committed May 15, 2024
1 parent 64a2176 commit 4ebbb4d
Show file tree
Hide file tree
Showing 9 changed files with 71 additions and 15 deletions.
6 changes: 4 additions & 2 deletions .env-local
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
ASPNETCORE_ENVIRONMENT=Development
ASPNETCORE_Kestrel__Certificates__Default__Password=ncafe
ASPNETCORE_Kestrel__Certificates__Default__Path=/https/ncafe-aspnetapp.pfx
CONNECTIONSTRINGS__EVENTSTORE=esdb://eventstore:2113?tls=false
CONNECTIONSTRINGS__RABBITMQ=host=rabbitmq;username=myuser;password=mypassword
ADMIN_BASE_ADDRESS=http://localhost:5010
CASHIER_BASE_ADDRESS=http://localhost:5020
BARISTA_BASE_ADDRESS=http://localhost:5030
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
##
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore

output/

# User-specific files
*.rsuser
*.suo
Expand Down
19 changes: 19 additions & 0 deletions Build.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
$projectPaths = @(
'.\src\Admin\NCafe.Admin.Api'
'.\src\Barista\NCafe.Barista.Api'
'.\src\Cashier\NCafe.Cashier.Api'
'.\src\UI\NCafe.Web'
)

Write-Host "Restoring packages for all projects..."
dotnet restore

foreach ($projectPath in $projectPaths) {
Write-Host "Building project $($projectPath)..."
dotnet build -c Release --no-restore $projectPath
}

foreach ($projectPath in $projectPaths) {
Write-Host "Publishing project $($projectPath)..."
dotnet publish -c Release --no-restore -o "$($projectPath)\output" $projectPath
}
4 changes: 3 additions & 1 deletion NCafe.sln
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
.env-local = .env-local
Build.ps1 = Build.ps1
build.sh = build.sh
Directory.Build.props = Directory.Build.props
Directory.Packages.props = Directory.Packages.props
infrastructure-compose.yaml = infrastructure-compose.yaml
Expand Down Expand Up @@ -73,7 +75,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NCafe.Shared", "src\Common\
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{49528FFA-842E-4853-9B8F-77BCE9970D11}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NCafe.Common.Tests", "src\Common\NCafe.Common.Tests\NCafe.Common.Tests.csproj", "{0203B146-09CB-4350-8375-9759F132BDC2}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NCafe.Common.Tests", "src\Common\NCafe.Common.Tests\NCafe.Common.Tests.csproj", "{0203B146-09CB-4350-8375-9759F132BDC2}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down
19 changes: 19 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash
set -e

projectPaths=("src/Admin/NCafe.Admin.Api" "src/Barista/NCafe.Barista.Api" "src/Cashier/NCafe.Cashier.Api" "src/UI/NCafe.Web")

echo "Restoring packages for all projects..."
dotnet restore

for projectPath in "${projectPaths[@]}"
do
echo "Building project $projectPath..."
dotnet build -c Release --no-restore $projectPath
done

for projectPath in "${projectPaths[@]}"
do
echo "Publishing project $projectPath..."
dotnet publish -c Release --no-restore -o "$projectPath/output" $projectPath
done
5 changes: 5 additions & 0 deletions global.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"sdk": {
"version": "8.0.300"
}
}
2 changes: 0 additions & 2 deletions infrastructure-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version: '3.4'

services:
eventstore:
image: eventstore/eventstore:20.10.0-buster-slim
Expand Down
25 changes: 17 additions & 8 deletions services-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,36 +1,45 @@
version: '3.4'

services:
admin:
build:
dockerfile: src/Admin/NCafe.Admin.Api/Dockerfile
context: src/Admin/NCafe.Admin.Api/
container_name: ncafe-admin
restart: unless-stopped
env_file: .env-local
ports:
- 5010:80
- 5010:8080
networks:
- ncafe

cashier:
build:
dockerfile: src/Cashier/NCafe.Cashier.Api/Dockerfile
context: src/Cashier/NCafe.Cashier.Api/
container_name: ncafe-cashier
restart: unless-stopped
env_file: .env-local
ports:
- 5020:80
- 5020:8080
networks:
- ncafe

barista:
build:
dockerfile: src/Barista/NCafe.Barista.Api/Dockerfile
context: src/Barista/NCafe.Barista.Api/
container_name: ncafe-barista
restart: unless-stopped
env_file: .env-local
ports:
- 5030:80
- 5030:8080
networks:
- ncafe

web-ui:
build:
context: src/UI/NCafe.Web/
container_name: ncafe-ui
restart: unless-stopped
env_file: .env-local
ports:
- 5000:80
networks:
- ncafe

Expand Down
4 changes: 2 additions & 2 deletions src/UI/NCafe.Web/prepare-appsettings.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ set -e
APPSETTINGS=/user/share/nginx/html/appsettings.json

# delete compressed (brotli/gzip) appsettings files
rm "$APPSETTINGS.br"
rm "$APPSETTINGS.gz"
rm -rf "$APPSETTINGS.br"
rm -rf "$APPSETTINGS.gz"

# update base address value using environment variables
sed -i -E "s|(\"AdminBaseAddress\"\:) \"(.*)\"(,)?|\1 \"$ADMIN_BASE_ADDRESS\"\3|g" $APPSETTINGS
Expand Down

0 comments on commit 4ebbb4d

Please sign in to comment.