Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions src/Games.Api/DOCKERFILE
Original file line number Diff line number Diff line change
@@ -1,31 +1,25 @@
# Use the official .NET 9.0 runtime as a parent image
FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS base
WORKDIR /app
EXPOSE 7001

# Use the official .NET 9.0 SDK as a build image
FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build
WORKDIR /src

# Copy project files and restore dependencies
COPY ["src/Games.Api/Games.Api.csproj", "src/Games.Api/"]
COPY ["src/Application/Application.csproj", "src/Application/"]
COPY ["src/Domain/Domain.csproj", "src/Domain/"]
COPY ["src/Infrastructure/Infrastructure.csproj", "src/Infrastructure/"]

RUN dotnet restore "src/Games.Api/Games.Api.csproj"

# Copy the rest of the application code
COPY . .

WORKDIR "/src/src/Games.Api"
RUN dotnet build "Games.Api.csproj" -c Release -o /app/build

# Publish the application
FROM build AS publish
RUN dotnet publish "Games.Api.csproj" -c Release -o /app/publish /p:UseAppHost=false

# Final stage/image
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
Expand Down
6 changes: 0 additions & 6 deletions src/Gateway.Api/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,28 +1,22 @@
# Use the official .NET 9.0 runtime as a parent image
FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS base
WORKDIR /app
EXPOSE 7000

# Use the official .NET 9.0 SDK as a build image
FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build
WORKDIR /src

# Copy project files and restore dependencies
COPY ["src/Gateway.Api/Gateway.Api.csproj", "src/Gateway.Api/"]

RUN dotnet restore "src/Gateway.Api/Gateway.Api.csproj"

# Copy the rest of the application code
COPY . .

WORKDIR "/src/src/Gateway.Api"
RUN dotnet build "Gateway.Api.csproj" -c Release -o /app/build

# Publish the application
FROM build AS publish
RUN dotnet publish "Gateway.Api.csproj" -c Release -o /app/publish /p:UseAppHost=false

# Final stage/image
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
Expand Down
6 changes: 0 additions & 6 deletions src/Identity.Api/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,31 +1,25 @@
# Use the official .NET 9.0 runtime as a parent image
FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS base
WORKDIR /app
EXPOSE 7002

# Use the official .NET 9.0 SDK as a build image
FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build
WORKDIR /src

# Copy project files and restore dependencies
COPY ["src/Identity.Api/Identity.Api.csproj", "src/Identity.Api/"]
COPY ["src/Application/Application.csproj", "src/Application/"]
COPY ["src/Domain/Domain.csproj", "src/Domain/"]
COPY ["src/Infrastructure/Infrastructure.csproj", "src/Infrastructure/"]

RUN dotnet restore "src/Identity.Api/Identity.Api.csproj"

# Copy the rest of the application code
COPY . .

WORKDIR "/src/src/Identity.Api"
RUN dotnet build "Identity.Api.csproj" -c Release -o /app/build

# Publish the application
FROM build AS publish
RUN dotnet publish "Identity.Api.csproj" -c Release -o /app/publish /p:UseAppHost=false

# Final stage/image
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
Expand Down
6 changes: 5 additions & 1 deletion src/Infrastructure/Data/GamesDbContextInitialiser.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Domain.Common.Interfaces;
using Domain.Entities;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;

namespace Infrastructure.Data;
Expand All @@ -12,9 +13,12 @@ public async Task InitialiseAsync()
{
try
{
await context.Database.EnsureDeletedAsync();
await context.Database.EnsureCreatedAsync();

await context.Database.MigrateAsync();

await SeedAsync();

}
catch (Exception ex)
{
Expand Down
4 changes: 3 additions & 1 deletion src/Infrastructure/Data/IdentityDbContextInitialiser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Domain.Entities;
using Domain.Identity.PasswordHashers;
using Microsoft.AspNetCore.Identity;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;

namespace Infrastructure.Data;
Expand All @@ -15,9 +16,10 @@ public async Task InitialiseAsync()
{
try
{
await context.Database.EnsureDeletedAsync();
await context.Database.EnsureCreatedAsync();

await context.Database.MigrateAsync();

await SeedAsync();
}
catch (Exception ex)
Expand Down
2 changes: 0 additions & 2 deletions src/Infrastructure/DependencyInjection.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
using Application;
using Application.Identity.Queries.GetUsers;
using Application.Users.Commands.AddUserGame;
using Domain.Common.Interfaces;
using Infrastructure.Data;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.AspNetCore.Identity;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ public class GlobalExceptionHandlingMiddleware(RequestDelegate next, ILogger<Glo
private readonly RequestDelegate _next = next;
private readonly ILogger<GlobalExceptionHandlingMiddleware> _logger = logger;

private static readonly JsonSerializerOptions _jsonSerializerOptions = new()
{
PropertyNamingPolicy = JsonNamingPolicy.CamelCase
};

public async Task InvokeAsync(HttpContext context)
{
try
Expand Down Expand Up @@ -42,10 +47,7 @@ private static async Task HandleExceptionAsync(HttpContext context, Exception ex
}
};

var jsonResponse = JsonSerializer.Serialize(response, new JsonSerializerOptions
{
PropertyNamingPolicy = JsonNamingPolicy.CamelCase
});
var jsonResponse = JsonSerializer.Serialize(response, _jsonSerializerOptions);

await context.Response.WriteAsync(jsonResponse);
}
Expand Down