diff --git a/.github/workflows/createrelease.yml b/.github/workflows/createrelease.yml
index 9a7d021..4a772fd 100644
--- a/.github/workflows/createrelease.yml
+++ b/.github/workflows/createrelease.yml
@@ -53,7 +53,7 @@ jobs:
- name: Publish API
if: ${{ github.event.release.prerelease == false }}
- run: dotnet publish "MessagingService\MessagingService.csproj" --configuration Release --output publishOutput -r win-x64 --self-contained
+ run: dotnet publish "MessagingService\MessagingService.csproj" --configuration Release --output publishOutput -r linux-x64 --self-contained
- name: Build Release Package
run: |
@@ -79,7 +79,7 @@ jobs:
dotnet nuget push Nugets/MessagingService.IntegrationTesting.Helpers.${{ steps.get_version.outputs.VERSION }}.nupkg --api-key ${{ secrets.PRIVATEFEED_APIKEY }} --source ${{ secrets.PRIVATEFEED_URL }} --skip-duplicate
deploystaging:
- runs-on: stagingserver
+ runs-on: [stagingserver, linux]
needs: buildlinux
environment: staging
name: "Deploy to Staging"
@@ -88,31 +88,77 @@ jobs:
- name: Download the artifact
uses: actions/download-artifact@v4.1.8
with:
- name: messagingservice
-
- - name: Remove existing Windows service
+ name: securityservice
+ path: /tmp/securityservice # Download to a temporary directory
+
+ - name: Remove existing service (if applicable)
run: |
- $serviceName = "Transaction Processing - Messaging Service"
- # Check if the service exists
- if (Get-Service -Name $serviceName -ErrorAction SilentlyContinue) {
- Stop-Service -Name $serviceName
- sc.exe delete $serviceName
- }
-
+ SERVICE_NAME="securityservice"
+ if systemctl is-active --quiet "$SERVICE_NAME"; then
+ echo "Stopping existing service..."
+ sudo systemctl stop "$SERVICE_NAME"
+ fi
+ if systemctl is-enabled --quiet "$SERVICE_NAME"; then
+ echo "Disabling existing service..."
+ sudo systemctl disable "$SERVICE_NAME"
+ fi
+ if [ -f "/etc/systemd/system/${SERVICE_NAME}.service" ]; then
+ echo "Removing existing service unit file..."
+ sudo rm "/etc/systemd/system/${SERVICE_NAME}.service"
+ sudo systemctl daemon-reload
+ fi
+
- name: Unzip the files
run: |
- Expand-Archive -Path messagingservice.zip -DestinationPath "C:\txnproc\transactionprocessing\messagingservice" -Force
-
- - name: Install as a Windows service
+ sudo mkdir -p /opt/txnproc/transactionprocessing/securityservice
+ sudo unzip -o /tmp/securityservice/securityservice.zip -d /opt/txnproc/transactionprocessing/securityservice
+
+ # IMPORTANT: Add a step to ensure the .NET runtime is installed on the server
+ # This assumes it's not already there. If your base image already has it, you can skip this.
+ - name: Install .NET Runtime
+ run: |
+ # Example for Ubuntu. Adjust based on your .NET version (e.g., 8.0, 7.0)
+ # and if you need the SDK or just the runtime.
+ # This uses Microsoft's package repository for the latest versions.
+ wget https://packages.microsoft.com/config/ubuntu/$(lsb_release -rs)/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
+ sudo dpkg -i packages-microsoft-prod.deb
+ rm packages-microsoft-prod.deb
+ sudo apt update
+ sudo apt install -y aspnetcore-runtime-9.0
+
+ - name: Install and Start as a Linux service
run: |
- $serviceName = "Transaction Processing - Messaging Service"
- $servicePath = "C:\txnproc\transactionprocessing\messagingservice\MessagingService.exe"
-
- New-Service -Name $serviceName -BinaryPathName $servicePath -Description "Transaction Processing - Messaging Service" -DisplayName "Transaction Processing - Messaging Service" -StartupType Automatic
- Start-Service -Name $serviceName
+ SERVICE_NAME="securityservice"
+ # The WorkingDirectory is crucial for .NET apps to find appsettings.json and other files
+ WORKING_DIRECTORY="/opt/txnproc/transactionprocessing/securityservice"
+ DLL_NAME="SecurityService.dll" # Your application's DLL
+ SERVICE_DESCRIPTION="Transaction Processing - Security Service"
+
+ # Create a systemd service file
+ echo "[Unit]" | sudo tee /etc/systemd/system/${SERVICE_NAME}.service
+ echo "Description=${SERVICE_DESCRIPTION}" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
+ echo "After=network.target" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
+ echo "" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
+ echo "[Service]" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
+ # IMPORTANT: Use 'dotnet' to run your DLL
+ echo "ExecStart=/usr/bin/dotnet ${WORKING_DIRECTORY}/${DLL_NAME}" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
+ echo "WorkingDirectory=${WORKING_DIRECTORY}" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
+ echo "Restart=always" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
+ echo "User=youruser" # IMPORTANT: Change to a dedicated, less privileged user
+ echo "Group=yourgroup" # IMPORTANT: Change to a dedicated, less privileged group
+ echo "Environment=ASPNETCORE_ENVIRONMENT=Production" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service # Example
+ echo "" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
+ echo "[Install]" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
+ echo "WantedBy=multi-user.target" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
+
+ # Reload systemd, enable, and start the service
+ sudo systemctl daemon-reload
+ sudo systemctl enable "$SERVICE_NAME"
+ sudo systemctl start "$SERVICE_NAME"
+ sudo systemctl status "$SERVICE_NAME" --no-pager # For debugging/verification
deployproduction:
- runs-on: productionserver
+ runs-on: [productionserver, linux]
needs: [buildlinux, deploystaging]
environment: production
name: "Deploy to Production"
@@ -121,25 +167,71 @@ jobs:
- name: Download the artifact
uses: actions/download-artifact@v4.1.8
with:
- name: messagingservice
-
- - name: Remove existing Windows service
+ name: securityservice
+ path: /tmp/securityservice # Download to a temporary directory
+
+ - name: Remove existing service (if applicable)
run: |
- $serviceName = "Transaction Processing - Messaging Service"
- # Check if the service exists
- if (Get-Service -Name $serviceName -ErrorAction SilentlyContinue) {
- Stop-Service -Name $serviceName
- sc.exe delete $serviceName
- }
-
+ SERVICE_NAME="securityservice"
+ if systemctl is-active --quiet "$SERVICE_NAME"; then
+ echo "Stopping existing service..."
+ sudo systemctl stop "$SERVICE_NAME"
+ fi
+ if systemctl is-enabled --quiet "$SERVICE_NAME"; then
+ echo "Disabling existing service..."
+ sudo systemctl disable "$SERVICE_NAME"
+ fi
+ if [ -f "/etc/systemd/system/${SERVICE_NAME}.service" ]; then
+ echo "Removing existing service unit file..."
+ sudo rm "/etc/systemd/system/${SERVICE_NAME}.service"
+ sudo systemctl daemon-reload
+ fi
+
- name: Unzip the files
run: |
- Expand-Archive -Path messagingservice.zip -DestinationPath "C:\txnproc\transactionprocessing\messagingservice" -Force
-
- - name: Install as a Windows service
+ sudo mkdir -p /opt/txnproc/transactionprocessing/securityservice
+ sudo unzip -o /tmp/securityservice/securityservice.zip -d /opt/txnproc/transactionprocessing/securityservice
+
+ # IMPORTANT: Add a step to ensure the .NET runtime is installed on the server
+ # This assumes it's not already there. If your base image already has it, you can skip this.
+ - name: Install .NET Runtime
+ run: |
+ # Example for Ubuntu. Adjust based on your .NET version (e.g., 8.0, 7.0)
+ # and if you need the SDK or just the runtime.
+ # This uses Microsoft's package repository for the latest versions.
+ wget https://packages.microsoft.com/config/ubuntu/$(lsb_release -rs)/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
+ sudo dpkg -i packages-microsoft-prod.deb
+ rm packages-microsoft-prod.deb
+ sudo apt update
+ sudo apt install -y aspnetcore-runtime-9.0
+
+ - name: Install and Start as a Linux service
run: |
- $serviceName = "Transaction Processing - Messaging Service"
- $servicePath = "C:\txnproc\transactionprocessing\messagingservice\MessagingService.exe"
-
- New-Service -Name $serviceName -BinaryPathName $servicePath -Description "Transaction Processing - Messaging Service" -DisplayName "Transaction Processing - Messaging Service" -StartupType Automatic
- Start-Service -Name $serviceName
+ SERVICE_NAME="securityservice"
+ # The WorkingDirectory is crucial for .NET apps to find appsettings.json and other files
+ WORKING_DIRECTORY="/opt/txnproc/transactionprocessing/securityservice"
+ DLL_NAME="SecurityService.dll" # Your application's DLL
+ SERVICE_DESCRIPTION="Transaction Processing - Security Service"
+
+ # Create a systemd service file
+ echo "[Unit]" | sudo tee /etc/systemd/system/${SERVICE_NAME}.service
+ echo "Description=${SERVICE_DESCRIPTION}" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
+ echo "After=network.target" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
+ echo "" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
+ echo "[Service]" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
+ # IMPORTANT: Use 'dotnet' to run your DLL
+ echo "ExecStart=/usr/bin/dotnet ${WORKING_DIRECTORY}/${DLL_NAME}" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
+ echo "WorkingDirectory=${WORKING_DIRECTORY}" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
+ echo "Restart=always" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
+ echo "User=youruser" # IMPORTANT: Change to a dedicated, less privileged user
+ echo "Group=yourgroup" # IMPORTANT: Change to a dedicated, less privileged group
+ echo "Environment=ASPNETCORE_ENVIRONMENT=Production" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service # Example
+ echo "" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
+ echo "[Install]" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
+ echo "WantedBy=multi-user.target" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
+
+ # Reload systemd, enable, and start the service
+ sudo systemctl daemon-reload
+ sudo systemctl enable "$SERVICE_NAME"
+ sudo systemctl start "$SERVICE_NAME"
+ sudo systemctl status "$SERVICE_NAME" --no-pager # For debugging/verification
diff --git a/MessagingService.Client/MessagingService.Client.csproj b/MessagingService.Client/MessagingService.Client.csproj
index 3bceffd..d95a596 100644
--- a/MessagingService.Client/MessagingService.Client.csproj
+++ b/MessagingService.Client/MessagingService.Client.csproj
@@ -6,9 +6,9 @@
-
+
-
+
diff --git a/MessagingService.EmailAggregate.Tests/MessagingService.EmailAggregate.Tests.csproj b/MessagingService.EmailAggregate.Tests/MessagingService.EmailAggregate.Tests.csproj
index e2ac9dc..cc2716b 100644
--- a/MessagingService.EmailAggregate.Tests/MessagingService.EmailAggregate.Tests.csproj
+++ b/MessagingService.EmailAggregate.Tests/MessagingService.EmailAggregate.Tests.csproj
@@ -8,7 +8,7 @@
-
+
diff --git a/MessagingService.EmailMessage.DomainEvents/MessagingService.EmailMessage.DomainEvents.csproj b/MessagingService.EmailMessage.DomainEvents/MessagingService.EmailMessage.DomainEvents.csproj
index 094d260..858edfb 100644
--- a/MessagingService.EmailMessage.DomainEvents/MessagingService.EmailMessage.DomainEvents.csproj
+++ b/MessagingService.EmailMessage.DomainEvents/MessagingService.EmailMessage.DomainEvents.csproj
@@ -6,8 +6,8 @@
-
-
+
+
diff --git a/MessagingService.EmailMessageAggregate/MessagingService.EmailMessageAggregate.csproj b/MessagingService.EmailMessageAggregate/MessagingService.EmailMessageAggregate.csproj
index 7a23361..0842698 100644
--- a/MessagingService.EmailMessageAggregate/MessagingService.EmailMessageAggregate.csproj
+++ b/MessagingService.EmailMessageAggregate/MessagingService.EmailMessageAggregate.csproj
@@ -6,8 +6,8 @@
-
-
+
+
diff --git a/MessagingService.IntegrationTesting.Helpers/MessagingService.IntegrationTesting.Helpers.csproj b/MessagingService.IntegrationTesting.Helpers/MessagingService.IntegrationTesting.Helpers.csproj
index 18762ee..a2f6cbb 100644
--- a/MessagingService.IntegrationTesting.Helpers/MessagingService.IntegrationTesting.Helpers.csproj
+++ b/MessagingService.IntegrationTesting.Helpers/MessagingService.IntegrationTesting.Helpers.csproj
@@ -7,7 +7,7 @@
-
+
diff --git a/MessagingService.IntegrationTests/Common/DockerHelper.cs b/MessagingService.IntegrationTests/Common/DockerHelper.cs
index b581a3d..287f26c 100644
--- a/MessagingService.IntegrationTests/Common/DockerHelper.cs
+++ b/MessagingService.IntegrationTests/Common/DockerHelper.cs
@@ -50,7 +50,8 @@ public class DockerHelper : global::Shared.IntegrationTesting.DockerHelper
/// The testing context.
public DockerHelper()
{
- this.TestingContext = new TestingContext();
+ this.TestingContext = new TestingContext();
+ this.TestId = Guid.NewGuid();
}
#endregion
diff --git a/MessagingService.IntegrationTests/Common/GenericSteps.cs b/MessagingService.IntegrationTests/Common/GenericSteps.cs
index 29925f2..a11fa1a 100644
--- a/MessagingService.IntegrationTests/Common/GenericSteps.cs
+++ b/MessagingService.IntegrationTests/Common/GenericSteps.cs
@@ -28,6 +28,7 @@ public GenericSteps(ScenarioContext scenarioContext,
[BeforeScenario]
public async Task StartSystem()
{
+
// Initialise a logger
String scenarioName = this.ScenarioContext.ScenarioInfo.Title.Replace(" ", "");
NlogLogger logger = new NlogLogger();
diff --git a/MessagingService.IntegrationTests/MessagingService.IntegrationTests.csproj b/MessagingService.IntegrationTests/MessagingService.IntegrationTests.csproj
index 7ba5202..c43aa3e 100644
--- a/MessagingService.IntegrationTests/MessagingService.IntegrationTests.csproj
+++ b/MessagingService.IntegrationTests/MessagingService.IntegrationTests.csproj
@@ -6,7 +6,7 @@
-
+
@@ -16,7 +16,7 @@
-
+
all
@@ -30,15 +30,20 @@
-
+
+
+
+ ReqnrollSingleFileGenerator
+ %(Filename).feature.cs
+
-
Always
diff --git a/MessagingService.SMSMessage.DomainEvents/MessagingService.SMSMessage.DomainEvents.csproj b/MessagingService.SMSMessage.DomainEvents/MessagingService.SMSMessage.DomainEvents.csproj
index 25341e2..ba8f328 100644
--- a/MessagingService.SMSMessage.DomainEvents/MessagingService.SMSMessage.DomainEvents.csproj
+++ b/MessagingService.SMSMessage.DomainEvents/MessagingService.SMSMessage.DomainEvents.csproj
@@ -6,7 +6,7 @@
-
+
diff --git a/MessagingService.SMSMessageAggregate/MessagingService.SMSMessageAggregate.csproj b/MessagingService.SMSMessageAggregate/MessagingService.SMSMessageAggregate.csproj
index efbfce5..863ef39 100644
--- a/MessagingService.SMSMessageAggregate/MessagingService.SMSMessageAggregate.csproj
+++ b/MessagingService.SMSMessageAggregate/MessagingService.SMSMessageAggregate.csproj
@@ -6,7 +6,7 @@
-
+
diff --git a/MessagingService/MessagingService - Backup (1).csproj b/MessagingService/MessagingService - Backup (1).csproj
deleted file mode 100644
index d878941..0000000
--- a/MessagingService/MessagingService - Backup (1).csproj
+++ /dev/null
@@ -1,50 +0,0 @@
-
-
-
- net7.0
- Linux
-
-
-
- D:\Projects\StuartFerguson\Messaging\MessagingService\MessagingService.xml
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Always
-
-
-
-
-
- dockerfile
-
-
-
-
-
diff --git a/MessagingService/MessagingService - Backup (2).csproj b/MessagingService/MessagingService - Backup (2).csproj
deleted file mode 100644
index a57f79c..0000000
--- a/MessagingService/MessagingService - Backup (2).csproj
+++ /dev/null
@@ -1,50 +0,0 @@
-
-
-
- net7.0
- Linux
-
-
-
- D:\Projects\StuartFerguson\Messaging\MessagingService\MessagingService.xml
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Always
-
-
-
-
-
- dockerfile
-
-
-
-
-
diff --git a/MessagingService/MessagingService - Backup.csproj b/MessagingService/MessagingService - Backup.csproj
deleted file mode 100644
index 995c1cb..0000000
--- a/MessagingService/MessagingService - Backup.csproj
+++ /dev/null
@@ -1,50 +0,0 @@
-
-
-
- net7.0
- Linux
-
-
-
- D:\Projects\StuartFerguson\Messaging\MessagingService\MessagingService.xml
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Always
-
-
-
-
-
- dockerfile
-
-
-
-
-
diff --git a/MessagingService/MessagingService.csproj b/MessagingService/MessagingService.csproj
index f75afd5..b64c184 100644
--- a/MessagingService/MessagingService.csproj
+++ b/MessagingService/MessagingService.csproj
@@ -18,11 +18,11 @@
-
+
-
+
diff --git a/MessagingService/aspnetapp-root-cert.cer b/MessagingService/aspnetapp-root-cert.cer
index c6ac5e9..a0e0530 100644
Binary files a/MessagingService/aspnetapp-root-cert.cer and b/MessagingService/aspnetapp-root-cert.cer differ