Skip to content

Commit

Permalink
Sprint release 10 (#366)
Browse files Browse the repository at this point in the history
  • Loading branch information
Corgam authored Jul 6, 2024
2 parents 40138ed + 90ac564 commit ea82120
Show file tree
Hide file tree
Showing 79 changed files with 2,671 additions and 1,057 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/backend-CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ jobs:
run: dotnet restore
working-directory: backend\src\BIE.DataPipeline

- name: Build required Libraries
run: dotnet build "./BieMetadata.csproj" -c Release
working-directory: backend\lib\BieMetadata

- name: Run unit tests
run: dotnet test
working-directory: backend\src\BIE.DataPipeline
run: dotnet test ".\src\BIE.DataPipeline"
working-directory: backend
20 changes: 13 additions & 7 deletions .github/workflows/deploy_production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,22 @@ jobs:
service:
- name: frontend
context: ./frontend
docker_dir:
- name: api-gateway
context: ./backend/api-gateway
context: ./backend
docker_dir: /api-gateway
- name: api-composer
context: ./backend/src/BIE.Core
context: ./backend
docker_dir: /src/BIE.Core
- name: datapipeline
context: ./backend/src/BIE.DataPipeline
context: ./backend
docker_dir: /src/BIE.DataPipeline
- name: sql-database
context: ./backend/sql-database
context: ./backend
docker_dir: /sql-database
- name: metadata-database
context: ./backend/metadata-database
context: ./backend
docker_dir: /metadata-database

steps:
- name: Checkout repository
Expand Down Expand Up @@ -59,7 +65,7 @@ jobs:
uses: docker/build-push-action@v5
with:
context: ${{ matrix.service.context }}
file: ${{ matrix.service.context }}/Dockerfile
file: ${{ matrix.service.context }}${{ matrix.service.docker_dir }}/Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
Expand All @@ -86,6 +92,6 @@ jobs:
scp ./docker-compose.yml ${{secrets.PROD_ENV_SSH_USER}}@${{secrets.PROD_ENV_SSH_HOST}}:/var/lib/bie
scp ./.env.production ${{secrets.PROD_ENV_SSH_USER}}@${{secrets.PROD_ENV_SSH_HOST}}:/var/lib/bie/.env
- name: Connect and Pull
run: ssh ${{secrets.PROD_ENV_SSH_USER}}@${{secrets.PROD_ENV_SSH_HOST}} "cd /var/lib/bie && docker compose pull && docker compose up -d --remove-orphans --force-recreate && exit"
run: ssh ${{secrets.PROD_ENV_SSH_USER}}@${{secrets.PROD_ENV_SSH_HOST}} "cd /var/lib/bie && docker compose down -v && docker compose pull && docker compose up -d --remove-orphans --force-recreate && exit"
- name: Cleanup
run: rm -rf ~/.ssh
20 changes: 13 additions & 7 deletions .github/workflows/deploy_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,22 @@ jobs:
service:
- name: frontend
context: ./frontend
docker_dir:
- name: api-gateway
context: ./backend/api-gateway
context: ./backend
docker_dir: /api-gateway
- name: api-composer
context: ./backend/src/BIE.Core
context: ./backend
docker_dir: /src/BIE.Core
- name: datapipeline
context: ./backend/src/BIE.DataPipeline
context: ./backend
docker_dir: /src/BIE.DataPipeline
- name: sql-database
context: ./backend/sql-database
docker_dir:
- name: metadata-database
context: ./backend/metadata-database

docker_dir:
steps:
- name: Checkout repository
uses: actions/checkout@v4
Expand All @@ -54,14 +59,15 @@ jobs:
type=ref,event=tag
type=sha
type=raw,value=${{ env.STAGE }}
latest
labels: |
stage=${{ env.STAGE }}
- name: Build and Publish Docker Image - ${{ matrix.service.name }}
uses: docker/build-push-action@v5
with:
context: ${{ matrix.service.context }}
file: ${{ matrix.service.context }}/Dockerfile
file: ${{ matrix.service.context }}${{ matrix.service.docker_dir }}/Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
Expand Down Expand Up @@ -89,7 +95,7 @@ jobs:
scp ./.env.test ${{ secrets.TEST_ENV_SSH_USER }}@${{ secrets.TEST_ENV_SSH_HOST }}:/var/lib/bie/.env
- name: Connect and Pull
run: ssh ${{ secrets.TEST_ENV_SSH_USER }}@${{ secrets.TEST_ENV_SSH_HOST }} "cd /var/lib/bie && docker compose pull && docker compose up -d --remove-orphans --force-recreate && exit"
run: ssh ${{ secrets.TEST_ENV_SSH_USER }}@${{ secrets.TEST_ENV_SSH_HOST }} "cd /var/lib/bie && docker compose down -v && docker compose pull && docker compose up -d --remove-orphans --force-recreate && exit"

- name: Cleanup
run: rm -rf ~/.ssh
run: rm -rf ~/.ssh
6 changes: 6 additions & 0 deletions backend/api-gateway/APIGateway.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,10 @@
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.6.2" />
</ItemGroup>

<ItemGroup>
<Reference Include="BieMetadata">
<HintPath>..\lib\BieMetadata\bin\Release\net6.0\BieMetadata.dll</HintPath>
</Reference>
</ItemGroup>

</Project>
13 changes: 11 additions & 2 deletions backend/api-gateway/Controllers/APIGatewayController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using System.ComponentModel.DataAnnotations;
using System.Net.Mime;
using System.Text;
using BieMetadata;

namespace BIE.Core.API.Controllers
{
Expand Down Expand Up @@ -192,9 +193,17 @@ public async Task<IActionResult> GetDatasetViewportData(
try
{
var response = await _httpClient.GetAsync(targetUrl);
response.EnsureSuccessStatusCode(); // Throw if not a success code.
var content = await response.Content.ReadAsStringAsync();
return Ok(content);

if (response.IsSuccessStatusCode)
{
return Ok(content);
}
else
{
_logger.LogError($"Error fetching data from the target service. Status code: {response.StatusCode}");
return StatusCode((int)response.StatusCode, content);
}
}
catch (HttpRequestException ex)
{
Expand Down
14 changes: 10 additions & 4 deletions backend/api-gateway/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,20 @@ FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
WORKDIR /app

# Copy the .csproj file and restore any dependencies
COPY *.csproj ./
RUN dotnet restore
# This is done separately from the rest of the source to (potentially)
# speed up later builds.
COPY ./api-gateway/APIGateway.csproj ./api-gateway/
RUN dotnet restore ./api-gateway/APIGateway.csproj

# Copy the remaining source code
COPY . ./
COPY ./api-gateway ./api-gateway
# Copy the Metadata Library
# Copy and build metadata library
COPY ./lib/BieMetadata ./lib/BieMetadata
RUN dotnet build "./lib/BieMetadata/BieMetadata.csproj" -c Release

# Build the application
RUN dotnet publish -c Release -o out
RUN dotnet publish ./api-gateway/APIGateway.csproj -c Release -o out

# Use the official Microsoft .NET runtime image to run the app
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS runtime
Expand Down
55 changes: 0 additions & 55 deletions backend/api-gateway/Models/MetadataObject.cs

This file was deleted.

1 change: 1 addition & 0 deletions backend/api-gateway/Services/MongoDBService.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using MongoDB.Driver;
using Microsoft.Extensions.Configuration;
using APIGateway.Models;
using BieMetadata;

namespace BIE.Core.API.Services
{
Expand Down
14 changes: 14 additions & 0 deletions backend/lib/BieMetadata/.nuspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<!-- Required elements-->
<id>BieMetadata</id>
<version>1.0.0</version>
<description>The shared Metadata libraries used in the BIE project</description>
<authors>Code.ing</authors>

<!-- Optional elements -->
<!-- ... -->
</metadata>
<!-- Optional 'files' node -->
</package>
13 changes: 13 additions & 0 deletions backend/lib/BieMetadata/BieMetadata.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="MongoDB.Driver" Version="2.26.0" />
</ItemGroup>

</Project>
16 changes: 16 additions & 0 deletions backend/lib/BieMetadata/BieMetadata.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@

Microsoft Visual Studio Solution File, Format Version 12.00
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BieMetadata", "BieMetadata.csproj", "{C70EFDC8-4D31-4BBF-828C-80E47C4064DA}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{C70EFDC8-4D31-4BBF-828C-80E47C4064DA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C70EFDC8-4D31-4BBF-828C-80E47C4064DA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C70EFDC8-4D31-4BBF-828C-80E47C4064DA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C70EFDC8-4D31-4BBF-828C-80E47C4064DA}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
10 changes: 10 additions & 0 deletions backend/lib/BieMetadata/BoundingBox.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// ReSharper disable InconsistentNaming
namespace BieMetadata;

public struct BoundingBox
{
public float minX;
public float minY;
public float maxX;
public float maxY;
}
Loading

0 comments on commit ea82120

Please sign in to comment.