Skip to content

Commit

Permalink
Merge pull request #81 from SimCorp/develop
Browse files Browse the repository at this point in the history
Release Version 0.6.0
  • Loading branch information
hojelse authored May 21, 2021
2 parents c118791 + 541152a commit 27e3a59
Show file tree
Hide file tree
Showing 32 changed files with 1,506 additions and 530 deletions.
1 change: 0 additions & 1 deletion .env.example

This file was deleted.

38 changes: 38 additions & 0 deletions .github/workflows/build-docker-images.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Build front- and back-end docker images

on:
push:
branches:
- main
- feature/docker-deployment

jobs:
docker-back-end:
name: Build and push back-end docker image
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Docker build
working-directory: ./backend
run: docker build -t ghcr.io/simcorp/nats-topology-visualiser-backend .
- name: Docker login
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Docker push
run: docker push ghcr.io/simcorp/nats-topology-visualiser-backend

docker-front-end:
name: Build and push front-end docker image
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Docker build
working-directory: ./
run: docker build -t ghcr.io/simcorp/nats-topology-visualiser-frontend .
- name: Docker login
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Docker push
run: docker push ghcr.io/simcorp/nats-topology-visualiser-frontend
1 change: 0 additions & 1 deletion .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,4 @@ jobs:
with:
node-version: ${{ matrix.node-version }}
- run: npm ci
- run: npm run build --if-present
- run: npm test
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ pnpm-debug.log*
*.sln
*.sw?
.vs
backend.sln.DotSettings.user

# .NET build files
bin
obj
publish
12 changes: 12 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM node:lts-alpine as build-stage
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run build; exit 0

# production stage
FROM nginx:stable-alpine as production-stage
COPY --from=build-stage /app/dist /usr/share/nginx/html
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
7 changes: 6 additions & 1 deletion appsettings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"CORS": {
"AllowedHosts": [ "http://localhost:8080" ]
"AllowedHosts": [
"http://localhost:8080",
"https://localhost:8080",
"http://localhost:80",
"https://localhost:80"
]
}
}
48 changes: 27 additions & 21 deletions backend/Controller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,28 @@ public class Controller : ControllerBase

private readonly DataStorage _dataStorage;

private static String timeOfRequest;

public Controller(DataStorage dataStorage)
{
_dataStorage = dataStorage;
}

[HttpGet("/updateEverything")]
[ProducesResponseType(Status200OK)]
public ActionResult<DataTransfer> GetData()
{
Program.UpdateData();
return new DataTransfer {
processedServers = _dataStorage.processedServers,
links = _dataStorage.links,
processedClusters = _dataStorage.processedClusters,
gatewayLinks = _dataStorage.gatewayLinks,
leafLinks = _dataStorage.leafLinks,
varz = _dataStorage.servers,
treeNodes = _dataStorage.treeNodes,
timeOfRequest = Program.dateOfNatsRequest
};
}

[HttpGet("/nodes")]
[ProducesResponseType(Status200OK)]
public ActionResult<IEnumerable<ServerNode>> GetNodes()
Expand All @@ -46,10 +61,9 @@ public ActionResult<IEnumerable<ClusterNode>> GetClusters()

[HttpGet("/timeOfRequest")]
[ProducesResponseType(Status200OK)]
public ActionResult<String> GetTimeOfRequest()
public ActionResult<DateTime> GetTimeOfRequest()
{
timeOfRequest = Program.dateOfNatsRequest.ToString("hh:mm tt - dd MMMM yyyy");
return timeOfRequest;
return Program.dateOfNatsRequest;
}

[HttpGet("/iptoserverid")]
Expand All @@ -70,22 +84,7 @@ public ActionResult<List<LeafLink>> GetLeafLinks()
[ProducesResponseType(Status200OK)]
public ActionResult<IEnumerable<GatewayLink>> GetGatewayLinks()
{
var gatewayLinks = new List<GatewayLink>();
foreach (var cluster in _dataStorage.clusterConnectionErrors)
{
var split = cluster.Key.Split(" NAMESPLIT ");
var source = split[0];
var target = split[1];
var link = new GatewayLink (source, target, cluster.Value.Count > 0);
link.errors = cluster.Value;
foreach (var err in cluster.Value)
{
link.errorsAsString += "\n" + err;
}
gatewayLinks.Add(link);
}

return gatewayLinks;
return _dataStorage.gatewayLinks;
}

[HttpGet("/varz")]
Expand Down Expand Up @@ -140,5 +139,12 @@ public ActionResult<IEnumerable<Leaf>> GetLeafz()
{
return _dataStorage.leafs;
}

[HttpGet("/TreeViewData")]
[ProducesResponseType(Status200OK)]
public ActionResult<IEnumerable<TreeNode>> GetTreeViewData()
{
return _dataStorage.treeNodes;
}
}
}
6 changes: 5 additions & 1 deletion backend/DataStorage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ public class DataStorage
public Dictionary<string, string> ipToServerId;
public List<LeafLink> leafLinks;
public HashSet<string> leafConnections;
public List<GatewayLink> gatewayLinks;
public List<TreeNode> treeNodes;

public DataStorage() {

Expand All @@ -43,14 +45,16 @@ public DataStorage() {
serverToMissingServer = new Dictionary<string, List<string>>();
ipToServerId = new Dictionary<string, string>();
leafLinks = new List<LeafLink>();

gatewayLinks = new List<GatewayLink>();

missingServerIds = new HashSet<string>();
foundServers = new HashSet<string>();
serverToCluster = new Dictionary<string, string>();
clusterConnectionErrors = new Dictionary<string, List<string>>();
errorClusters = new List<ClusterNode>();
leafConnections = new HashSet<string>();

treeNodes = new List<TreeNode>();
}
}
}
20 changes: 20 additions & 0 deletions backend/DataTransfer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using backend.drawables;
using backend.models;

namespace backend
{
public class DataTransfer
{
public ConcurrentBag<ServerNode> processedServers {get; set;}
public List<Link> links {get; set;}
public ConcurrentBag<ClusterNode> processedClusters {get; set;}
public List<GatewayLink> gatewayLinks {get; set;}
public List<LeafLink> leafLinks {get; set;}
public List<Server> varz {get; set;}
public List<TreeNode> treeNodes { get; set; }
public DateTime timeOfRequest {get; set;}
}
}
10 changes: 10 additions & 0 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build
WORKDIR /src/
COPY . .
RUN dotnet publish -o /app/

FROM mcr.microsoft.com/dotnet/aspnet:5.0 AS runtime
WORKDIR /app/
EXPOSE 443
ENTRYPOINT ["dotnet", "backend.dll"]
COPY --from=build /app/ .
Loading

0 comments on commit 27e3a59

Please sign in to comment.