Skip to content

Commit 5747a59

Browse files
authored
Initial commit
0 parents  commit 5747a59

File tree

123 files changed

+69093
-0
lines changed

Some content is hidden

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

123 files changed

+69093
-0
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#workspace Think you are a Consultant from Microsoft and suggest a App Architecture using Microsoft UI tool and ASP.NET C# as backend services
2+
3+
# use .net 9.0.0 version and Suggest a Proffesional App Architecture

.env

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
POSTGRES_USER=postgres
2+
POSTGRES_PASSWORD=YourStrong@Passw0rd
3+
POSTGRES_DB=ShippingRulesDb
4+
ASPNETCORE_ENVIRONMENT=Development
5+
ASPNETCORE_URLS=http://+:8080

.github/dependabot.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
version: 2
2+
updates:
3+
# Enable version updates for NuGet
4+
- package-ecosystem: "nuget"
5+
directory: "/"
6+
schedule:
7+
interval: "weekly"
8+
open-pull-requests-limit: 10
9+
labels:
10+
- "dependencies"
11+
- "security"
12+
# Allow both direct and indirect dependencies
13+
allow:
14+
- dependency-type: "all"

.github/workflows/docker-cicd.yml

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
# GitHub Actions Workflow for ShippingApp CI/CD
2+
#
3+
# This workflow automates the build, test, and deployment process for the ShippingApp.
4+
# It is triggered on push and pull request events to ensure code quality and facilitate
5+
# continuous integration and delivery.
6+
#
7+
# Workflow Overview:
8+
# - Triggers: Runs on push to master/main branches and on pull requests
9+
# - Jobs: Build, test, and optionally deploy the application
10+
# - Environment: Configurable for different deployment targets (dev, staging, production)
11+
#
12+
# Prerequisites:
13+
# - Repository secrets should be configured for sensitive data (API keys, credentials)
14+
# - Node.js/Java/Python runtime environment (depending on your app stack)
15+
# - Test frameworks and dependencies properly configured in the project
16+
#
17+
# Customization:
18+
# - Modify trigger branches as needed for your branching strategy
19+
# - Add additional jobs for security scanning, code quality checks, etc.
20+
# - Configure deployment steps based on your infrastructure (AWS, Azure, GCP, etc.)
21+
name: Docker CI/CD Pipeline
22+
23+
on:
24+
push:
25+
branches: [ feature/manuals]
26+
27+
env:
28+
DOCKER_REGISTRY: docker.io
29+
IMAGE_NAME: easternshipping/api
30+
DOTNET_VERSION: '9.0.x'
31+
32+
jobs:
33+
# Stage 1: Build & Test
34+
build-and-test:
35+
name: 🏗️ Build & Test Application
36+
runs-on: ubuntu-latest
37+
38+
steps:
39+
- name: 📥 Checkout code
40+
uses: actions/checkout@v4
41+
42+
- name: 🔧 Setup .NET
43+
uses: actions/setup-dotnet@v4
44+
with:
45+
dotnet-version: ${{ env.DOTNET_VERSION }}
46+
47+
- name: 📦 Restore dependencies
48+
run: dotnet restore ShippingRules.Api.slnf
49+
50+
- name: 🏗️ Build solution
51+
run: dotnet build ShippingRules.Api.slnf --configuration Release --no-restore
52+
53+
- name: 🧪 Run tests
54+
run: |
55+
if [ -d "tests" ]; then
56+
dotnet test tests/**/*.csproj --configuration Release --verbosity normal --logger trx
57+
else
58+
echo "No tests found, skipping test step"
59+
fi
60+
61+
- name: 📊 Upload test results
62+
if: always()
63+
uses: actions/upload-artifact@v4
64+
with:
65+
name: test-results
66+
path: '**/TestResults/**/*.trx'
67+
68+
- name: ✅ Build Summary
69+
run: |
70+
echo "### 🏗️ Build Complete" >> $GITHUB_STEP_SUMMARY
71+
echo "- .NET Version: ${{ env.DOTNET_VERSION }}" >> $GITHUB_STEP_SUMMARY
72+
echo "- Build Status: ✅ Success" >> $GITHUB_STEP_SUMMARY
73+
74+
# Stage 2: Deploy to Production
75+
deploy-production:
76+
name: 🚀 Deploy to Production
77+
runs-on: ubuntu-latest
78+
needs: build-and-test
79+
if: github.event.inputs.environment == 'production' || startsWith(github.ref, 'refs/tags/v')
80+
environment:
81+
name: production
82+
url: ${{ steps.deploy.outputs.url }}
83+
84+
steps:
85+
- name: 📥 Checkout code
86+
uses: actions/checkout@v4
87+
88+
- name: 🔐 Azure Login
89+
uses: azure/login@v1
90+
with:
91+
creds: ${{ secrets.AZURE_CREDENTIALS }}
92+
93+
- name: 🚀 Deploy to Azure App Service
94+
id: deploy
95+
uses: azure/webapps-deploy@v3
96+
with:
97+
app-name: ${{ vars.AZURE_WEBAPP_NAME }}
98+
images: ${{ env.DOCKER_REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}
99+
100+
- name: 🏥 Health Check
101+
run: |
102+
sleep 30
103+
curl --fail --retry 5 --retry-delay 10 ${{ steps.deploy.outputs.webapp-url }}/health || exit 1
104+
105+
- name: 📢 Notify Teams
106+
if: always()
107+
uses: jdcargile/[email protected]
108+
with:
109+
github-token: ${{ github.token }}
110+
ms-teams-webhook-uri: ${{ secrets.MS_TEAMS_WEBHOOK_URI }}
111+
notification-summary: "Production Deployment ${{ job.status }}"
112+
notification-color: ${{ job.status == 'success' && '28a745' || 'dc3545' }}
113+
114+
- name: ✅ Production Deployment Summary
115+
run: |
116+
echo "### 🚀 Production Deployment Complete" >> $GITHUB_STEP_SUMMARY
117+
echo "- Environment: Production" >> $GITHUB_STEP_SUMMARY
118+
echo "- URL: ${{ steps.deploy.outputs.webapp-url }}" >> $GITHUB_STEP_SUMMARY
119+
echo "- Status: ✅ Live" >> $GITHUB_STEP_SUMMARY

.gitignore

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
## Ignore Visual Studio temporary files, build results, and
2+
## files generated by popular Visual Studio add-ons.
3+
4+
# User-specific files
5+
*.rsuser
6+
*.suo
7+
*.user
8+
*.userosscache
9+
*.sln.docstates
10+
11+
# Build results
12+
[Dd]ebug/
13+
[Dd]ebugPublic/
14+
[Rr]elease/
15+
[Rr]eleases/
16+
x64/
17+
x86/
18+
[Ww][Ii][Nn]32/
19+
[Aa][Rr][Mm]/
20+
[Aa][Rr][Mm]64/
21+
bld/
22+
[Bb]in/
23+
[Oo]bj/
24+
[Ll]og/
25+
[Ll]ogs/
26+
27+
# Visual Studio cache/options directory
28+
.vs/
29+
30+
# Visual Studio Code
31+
.vscode/
32+
.history/
33+
34+
# .NET Core
35+
project.lock.json
36+
project.fragment.lock.json
37+
artifacts/
38+
39+
# ASP.NET Scaffolding
40+
ScaffoldingReadMe.txt
41+
42+
# Files built by Visual Studio
43+
*_i.c
44+
*_p.c
45+
*_h.h
46+
*.ilk
47+
*.meta
48+
*.obj
49+
*.iobj
50+
*.pch
51+
*.pdb
52+
*.ipdb
53+
*.pgc
54+
*.pgd
55+
*.rsp
56+
*.sbr
57+
*.tlb
58+
*.tli
59+
*.tlh
60+
*.tmp
61+
*.tmp_proj
62+
*_wpftmp.csproj
63+
*.log
64+
*.tlog
65+
*.vspscc
66+
*.vssscc
67+
.builds
68+
*.pidb
69+
*.svclog
70+
*.scc
71+
72+
# NuGet Packages
73+
*.nupkg
74+
*.snupkg
75+
**/packages/*
76+
!**/packages/build/
77+
*.nuget.props
78+
*.nuget.targets
79+
80+
# Database files
81+
*.mdf
82+
*.ldf
83+
*.ndf
84+
85+
# SQL Server files
86+
*.bak
87+
88+
# JetBrains Rider
89+
.idea/
90+
*.sln.iml
91+
92+
# User-specific files (MonoDevelop/Xamarin Studio)
93+
*.userprefs
94+
95+
# Mono auto generated files
96+
mono_crash.*
97+
98+
# Windows image file caches
99+
Thumbs.db
100+
ehthumbs.db
101+
102+
# Folder config file
103+
Desktop.ini
104+
105+
# Recycle Bin used on file shares
106+
$RECYCLE.BIN/
107+
108+
# Mac files
109+
.DS_Store
110+
111+
# MAUI specific
112+
**/Resources/obj/
113+
**/Resources/bin/
114+
115+
# Logs
116+
logs/
117+
*.txt
118+
119+
# Publishing
120+
publish/
121+
*.pubxml
122+
*.publishsettings
123+
124+
# Azure
125+
*.azurePubxml
126+
127+
# Build logs
128+
*.binlog
129+
130+
# Web-only focus: ignore MAUI app project
131+
src/ShippingRules.MAUI/
132+
src/ShippingRules.MAUI.sln

.swp

12 KB
Binary file not shown.

Dockerfile

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# Build Stage
2+
FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build
3+
ARG BUILD_CONFIGURATION=Release
4+
WORKDIR /src
5+
6+
# Copy solution file
7+
COPY ["ShippingRules.sln", "./"]
8+
9+
# Copy project files
10+
COPY ["src/ShippingRules.API/ShippingRules.API.csproj", "src/ShippingRules.API/"]
11+
COPY ["src/ShippingRules.Application/ShippingRules.Application.csproj", "src/ShippingRules.Application/"]
12+
COPY ["src/ShippingRules.Domain/ShippingRules.Domain.csproj", "src/ShippingRules.Domain/"]
13+
COPY ["src/ShippingRules.Infrastructure/ShippingRules.Infrastructure.csproj", "src/ShippingRules.Infrastructure/"]
14+
15+
# Restore dependencies
16+
RUN dotnet restore "src/ShippingRules.API/ShippingRules.API.csproj"
17+
18+
# Copy all source code
19+
COPY src/ src/
20+
21+
# Build
22+
WORKDIR "/src/src/ShippingRules.API"
23+
RUN dotnet build "ShippingRules.API.csproj" -c $BUILD_CONFIGURATION -o /app/build --no-restore
24+
25+
# Publish Stage
26+
FROM build AS publish
27+
ARG BUILD_CONFIGURATION=Release
28+
RUN dotnet publish "ShippingRules.API.csproj" \
29+
-c $BUILD_CONFIGURATION \
30+
-o /app/publish \
31+
--no-restore \
32+
--no-build \
33+
/p:UseAppHost=false
34+
35+
# Runtime Stage
36+
FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS final
37+
WORKDIR /app
38+
39+
# Create non-root user
40+
RUN groupadd -r appuser && useradd -r -g appuser appuser
41+
42+
# Copy published files
43+
COPY --from=publish /app/publish .
44+
45+
# Create logs directory with proper permissions
46+
RUN mkdir -p /app/logs && chown -R appuser:appuser /app
47+
48+
# Switch to non-root user
49+
USER appuser
50+
51+
# Environment variables
52+
ENV ASPNETCORE_URLS=http://+:8080 \
53+
ASPNETCORE_ENVIRONMENT=Production \
54+
DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=false
55+
56+
# Health check
57+
HEALTHCHECK --interval=30s --timeout=3s --start-period=10s --retries=3 \
58+
CMD curl --fail http://localhost:8080/health || exit 1
59+
60+
EXPOSE 8080
61+
62+
ENTRYPOINT ["dotnet", "ShippingRules.API.dll"]

0 commit comments

Comments
 (0)