diff --git a/.github/workflows/deploy-identity.yml b/.github/workflows/deploy-identity.yml
new file mode 100644
index 0000000..8337e73
--- /dev/null
+++ b/.github/workflows/deploy-identity.yml
@@ -0,0 +1,23 @@
+name: Deploy Identity Service
+
+on:
+ workflow_dispatch:
+ push:
+ branches:
+ - main
+ paths:
+ - 'src/IdentityService/**'
+
+jobs:
+ build:
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout the code
+ uses: actions/checkout@v3
+ - name: Build and push the Docker image
+ uses: knphilip/actions/dockerfile-push@main
+ with:
+ tags: knphilip/bidwheels-identity-svc:latest
+ file: src/IdentityService/Dockerfile
+ username: ${{ secrets.DOCKERHUB_USERNAME }}
+ password: ${{ secrets.DOCKERHUB_TOKEN }}
\ No newline at end of file
diff --git a/K8S/local-pvc.yml b/K8S/local-pvc.yml
new file mode 100644
index 0000000..22061c8
--- /dev/null
+++ b/K8S/local-pvc.yml
@@ -0,0 +1,11 @@
+apiVersion: v1
+kind: PersistentVolumeClaim
+metadata:
+ name: postgres-claim
+spec:
+ resources:
+ requests:
+ storage: 200Mi
+ volumeMode: Filesystem
+ accessModes:
+ - ReadWriteOnce
diff --git a/K8S/postgres-depl.yml b/K8S/postgres-depl.yml
new file mode 100644
index 0000000..cca7a36
--- /dev/null
+++ b/K8S/postgres-depl.yml
@@ -0,0 +1,28 @@
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+ name: postgres
+spec:
+ selector:
+ matchLabels:
+ app: postgres
+ template:
+ metadata:
+ labels:
+ app: postgres
+ spec:
+ containers:
+ - name: postgres
+ image: postgres
+ env:
+ - name: POSTGRES_PASSWORD
+ value: postgrespw
+ ports:
+ - containerPort: 5432
+ volumeMounts:
+ - mountPath: /var/data/postgresql
+ name: postgresdata
+ volumes:
+ - name: postgresdata
+ persistentVolumeClaim:
+ claimName: postgres-claim
diff --git a/src/AuctionService/AuctionService.csproj b/src/AuctionService/AuctionService.csproj
index 8f1eea8..aedfd9a 100644
--- a/src/AuctionService/AuctionService.csproj
+++ b/src/AuctionService/AuctionService.csproj
@@ -17,6 +17,7 @@
all
+
diff --git a/src/AuctionService/Program.cs b/src/AuctionService/Program.cs
index fd9452b..6885462 100644
--- a/src/AuctionService/Program.cs
+++ b/src/AuctionService/Program.cs
@@ -5,6 +5,9 @@
using MassTransit;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.EntityFrameworkCore;
+using Npgsql;
+using Polly;
+using Polly.Retry;
WebApplicationBuilder builder = WebApplication.CreateBuilder(args);
@@ -37,6 +40,11 @@
config.UsingRabbitMq((context, cfg) =>
{
+ cfg.UseMessageRetry(r => {
+ r.Handle();
+ r.Interval(5, TimeSpan.FromSeconds(10));
+ });
+
cfg.Host(builder.Configuration["RabbitMQ:Host"], "/", host =>
{
host.Username(builder.Configuration.GetValue("RabbitMQ:Username", "guest"));
@@ -65,6 +73,12 @@
app.MapGrpcService();
+RetryPolicy retryPolicy = Policy
+ .Handle()
+ .WaitAndRetry(5, retryAttempt => TimeSpan.FromSeconds(10));
+
+retryPolicy.ExecuteAndCapture(() => DbInitializer.InitDb(app));
+
try
{
DbInitializer.InitDb(app);
diff --git a/src/BiddingService/BiddingService.csproj b/src/BiddingService/BiddingService.csproj
index b06a7d4..fa54797 100644
--- a/src/BiddingService/BiddingService.csproj
+++ b/src/BiddingService/BiddingService.csproj
@@ -18,6 +18,7 @@
+
diff --git a/src/BiddingService/Program.cs b/src/BiddingService/Program.cs
index ecc3a80..520c991 100644
--- a/src/BiddingService/Program.cs
+++ b/src/BiddingService/Program.cs
@@ -4,6 +4,7 @@
using Microsoft.AspNetCore.Authentication.JwtBearer;
using BiddingService.Consumers;
using BiddingService.Services;
+using Polly;
WebApplicationBuilder builder = WebApplication.CreateBuilder(args);
@@ -16,6 +17,12 @@
config.UsingRabbitMq((context, cfg) =>
{
+ cfg.UseMessageRetry(r =>
+ {
+ r.Handle();
+ r.Interval(5, TimeSpan.FromSeconds(10));
+ });
+
cfg.Host(builder.Configuration["RabbitMQ:Host"], "/", host =>
{
host.Username(builder.Configuration.GetValue("RabbitMQ:Username", "guest"));
@@ -46,7 +53,12 @@
app.MapControllers();
-await DB.InitAsync("BidDb", MongoClientSettings
- .FromConnectionString(builder.Configuration.GetConnectionString("BidDbConnection")));
+await Policy.Handle()
+ .WaitAndRetryAsync(5, retryAttempt => TimeSpan.FromSeconds(10))
+ .ExecuteAndCaptureAsync(async () =>
+ {
+ await DB.InitAsync("BidDb", MongoClientSettings
+ .FromConnectionString(builder.Configuration.GetConnectionString("BidDbConnection")));
+ });
app.Run();
diff --git a/src/IdentityService/IdentityService.csproj b/src/IdentityService/IdentityService.csproj
index e561150..11b6297 100644
--- a/src/IdentityService/IdentityService.csproj
+++ b/src/IdentityService/IdentityService.csproj
@@ -11,6 +11,8 @@
+
+
diff --git a/src/IdentityService/Program.cs b/src/IdentityService/Program.cs
index abd89bf..94be5cf 100644
--- a/src/IdentityService/Program.cs
+++ b/src/IdentityService/Program.cs
@@ -1,4 +1,7 @@
using IdentityService;
+using Npgsql;
+using Polly;
+using Polly.Retry;
using Serilog;
Log.Logger = new LoggerConfiguration()
@@ -22,7 +25,11 @@
// this seeding is only for the template to bootstrap the DB and users.
// in production you will likely want a different approach.
- SeedData.EnsureSeedData(app);
+ RetryPolicy retryPolicy = Policy
+ .Handle()
+ .WaitAndRetry(5, retryAttempt => TimeSpan.FromSeconds(10));
+
+ retryPolicy.ExecuteAndCapture(() => SeedData.EnsureSeedData(app));
app.Run();
}
diff --git a/src/NotificationService/Program.cs b/src/NotificationService/Program.cs
index 46f2ba4..8709941 100644
--- a/src/NotificationService/Program.cs
+++ b/src/NotificationService/Program.cs
@@ -16,6 +16,12 @@
config.UsingRabbitMq((context, cfg) =>
{
+ cfg.UseMessageRetry(r =>
+ {
+ r.Handle();
+ r.Interval(5, TimeSpan.FromSeconds(10));
+ });
+
cfg.Host(builder.Configuration["RabbitMQ:Host"], "/", host =>
{
host.Username(builder.Configuration.GetValue("RabbitMQ:Username", "guest"));
diff --git a/src/SearchService/Program.cs b/src/SearchService/Program.cs
index c337eb5..a6522f2 100644
--- a/src/SearchService/Program.cs
+++ b/src/SearchService/Program.cs
@@ -22,6 +22,11 @@
config.UsingRabbitMq((context, cfg) =>
{
+ cfg.UseMessageRetry(r => {
+ r.Handle();
+ r.Interval(5, TimeSpan.FromSeconds(10));
+ });
+
cfg.Host(builder.Configuration["RabbitMQ:Host"], "/", host =>
{
host.Username(builder.Configuration.GetValue("RabbitMQ:Username", "guest"));
@@ -44,15 +49,11 @@
app.MapControllers();
-app.Lifetime.ApplicationStarted.Register(async () => {
- try
- {
- await DbInitializer.InitDb(app);
- }
- catch (Exception ex)
- {
- Console.WriteLine($"--> Something went wrong: {ex}");
- }
+app.Lifetime.ApplicationStarted.Register(async () =>
+{
+ await Policy.Handle()
+ .WaitAndRetryAsync(5, retryAttempt => TimeSpan.FromSeconds(5))
+ .ExecuteAndCaptureAsync(async () => await DbInitializer.InitDb(app));
});
app.Run();
diff --git a/src/SearchService/SearchService.csproj b/src/SearchService/SearchService.csproj
index f43bea9..3e946c5 100644
--- a/src/SearchService/SearchService.csproj
+++ b/src/SearchService/SearchService.csproj
@@ -12,6 +12,7 @@
+