Skip to content

Commit

Permalink
Revert "Remove EF Core migrations and identity setup"
Browse files Browse the repository at this point in the history
This reverts commit 84a6630.
  • Loading branch information
urumo committed Oct 18, 2024
1 parent 2fc6386 commit b732883
Show file tree
Hide file tree
Showing 20 changed files with 1,171 additions and 7 deletions.
21 changes: 21 additions & 0 deletions Argon.Server.sln
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,18 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AppHost", "src\AppHost\AppH
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ServiceDefaults", "src\ServiceDefaults\ServiceDefaults.csproj", "{3AEA5748-B88E-45FF-B3DC-319A7A8D13B4}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Argon.Api", "src\Argon.Api\Argon.Api.csproj", "{D781D76E-6DD7-4C82-96D2-CA5D316BBF1E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Argon.Api.Common", "src\Argon.Api.Common\Argon.Api.Common.csproj", "{2E23380A-5F69-4FA2-8E91-C98BBF755DB6}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Argon.Grains", "Contracts\Argon.Grains\Argon.Grains.csproj", "{9D8512AA-367B-427C-8387-AE03F2374EE0}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Argon.Grains.Interfaces", "Contracts\Argon.Grains.Interfaces\Argon.Grains.Interfaces.csproj", "{5B50B6FF-C2ED-4DB9-B805-0CB1AA30E328}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Argon.Orleans.Client", "Contracts\Argon.Orleans.Client\Argon.Orleans.Client.csproj", "{B53E94BD-BFB4-4BD1-BFFC-8CC0CB610100}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleApp1", "src\ConsoleApp1\ConsoleApp1.csproj", "{EEC40E82-5DC5-463D-BA56-7680A0E41A4E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -20,9 +26,12 @@ Global
GlobalSection(NestedProjects) = preSolution
{872FE764-2544-4E27-9193-BA625245F8D5} = {43C63C3C-90EB-4AED-BB15-B30F76F93A9E}
{3AEA5748-B88E-45FF-B3DC-319A7A8D13B4} = {43C63C3C-90EB-4AED-BB15-B30F76F93A9E}
{D781D76E-6DD7-4C82-96D2-CA5D316BBF1E} = {43C63C3C-90EB-4AED-BB15-B30F76F93A9E}
{2E23380A-5F69-4FA2-8E91-C98BBF755DB6} = {43C63C3C-90EB-4AED-BB15-B30F76F93A9E}
{9D8512AA-367B-427C-8387-AE03F2374EE0} = {43C63C3C-90EB-4AED-BB15-B30F76F93A9E}
{5B50B6FF-C2ED-4DB9-B805-0CB1AA30E328} = {43C63C3C-90EB-4AED-BB15-B30F76F93A9E}
{B53E94BD-BFB4-4BD1-BFFC-8CC0CB610100} = {43C63C3C-90EB-4AED-BB15-B30F76F93A9E}
{EEC40E82-5DC5-463D-BA56-7680A0E41A4E} = {43C63C3C-90EB-4AED-BB15-B30F76F93A9E}
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{872FE764-2544-4E27-9193-BA625245F8D5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
Expand All @@ -33,6 +42,14 @@ Global
{3AEA5748-B88E-45FF-B3DC-319A7A8D13B4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3AEA5748-B88E-45FF-B3DC-319A7A8D13B4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3AEA5748-B88E-45FF-B3DC-319A7A8D13B4}.Release|Any CPU.Build.0 = Release|Any CPU
{D781D76E-6DD7-4C82-96D2-CA5D316BBF1E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D781D76E-6DD7-4C82-96D2-CA5D316BBF1E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D781D76E-6DD7-4C82-96D2-CA5D316BBF1E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D781D76E-6DD7-4C82-96D2-CA5D316BBF1E}.Release|Any CPU.Build.0 = Release|Any CPU
{2E23380A-5F69-4FA2-8E91-C98BBF755DB6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2E23380A-5F69-4FA2-8E91-C98BBF755DB6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2E23380A-5F69-4FA2-8E91-C98BBF755DB6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2E23380A-5F69-4FA2-8E91-C98BBF755DB6}.Release|Any CPU.Build.0 = Release|Any CPU
{9D8512AA-367B-427C-8387-AE03F2374EE0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9D8512AA-367B-427C-8387-AE03F2374EE0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9D8512AA-367B-427C-8387-AE03F2374EE0}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand All @@ -45,5 +62,9 @@ Global
{B53E94BD-BFB4-4BD1-BFFC-8CC0CB610100}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B53E94BD-BFB4-4BD1-BFFC-8CC0CB610100}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B53E94BD-BFB4-4BD1-BFFC-8CC0CB610100}.Release|Any CPU.Build.0 = Release|Any CPU
{EEC40E82-5DC5-463D-BA56-7680A0E41A4E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EEC40E82-5DC5-463D-BA56-7680A0E41A4E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EEC40E82-5DC5-463D-BA56-7680A0E41A4E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EEC40E82-5DC5-463D-BA56-7680A0E41A4E}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
4 changes: 4 additions & 0 deletions src/AppHost/AppHost.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,8 @@
<PackageReference Include="Aspire.Hosting.Redis" Version="8.2.1"/>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Argon.Api\Argon.Api.csproj"/>
</ItemGroup>

</Project>
14 changes: 7 additions & 7 deletions src/AppHost/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@

var apiDb = db.AddDatabase("apiDb");

// var api = builder.AddProject<Argon_Api>("argon-api")
// .WithReference(apiDb, "DefaultConnection")
// .WithReference(cache)
// .WithReference(rmq)
// .WithEndpoint(11111, 11111, "tcp", "siloPort", isProxied: false)
// .WithEndpoint(30000, 30000, "tcp", "grainPort", isProxied: false)
// .WithExternalHttpEndpoints();
var api = builder.AddProject<Argon_Api>("argon-api")
.WithReference(apiDb, "DefaultConnection")
.WithReference(cache)
.WithReference(rmq)
.WithEndpoint(11111, 11111, "tcp", "siloPort", isProxied: false)
.WithEndpoint(30000, 30000, "tcp", "grainPort", isProxied: false)
.WithExternalHttpEndpoints();

builder.Build().Run();
13 changes: 13 additions & 0 deletions src/Argon.Api.Common/Argon.Api.Common.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">

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

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="8.0.10"/>
</ItemGroup>

</Project>
7 changes: 7 additions & 0 deletions src/Argon.Api.Common/Models/ApplicationUser.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
using Microsoft.AspNetCore.Identity;

namespace Argon.Api.Common.Models;

public class ApplicationUser : IdentityUser<Guid>
{
}
30 changes: 30 additions & 0 deletions src/Argon.Api.Common/Services/EmailSender.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using Argon.Api.Common.Models;
using Microsoft.AspNetCore.Identity;
using Microsoft.Extensions.Logging;

namespace Argon.Api.Common.Services;

public class EmailSender(ILogger<EmailSender> logger) : IEmailSender<ApplicationUser>
{
public Task SendConfirmationLinkAsync(ApplicationUser user, string email, string confirmationLink)
{
logger.LogInformation(
"Sending confirmation link to {email} for user {user} with confirmation link {confirmationLink}", email,
user.UserName, confirmationLink);
return Task.CompletedTask;
}

public Task SendPasswordResetLinkAsync(ApplicationUser user, string email, string resetLink)
{
logger.LogInformation("Sending password reset link to {email} for user {user} with reset link {resetLink}",
email, user.UserName, resetLink);
return Task.CompletedTask;
}

public Task SendPasswordResetCodeAsync(ApplicationUser user, string email, string resetCode)
{
logger.LogInformation("Sending password reset code to {email} for user {user} with reset code {resetCode}",
email, user.UserName, resetCode);
return Task.CompletedTask;
}
}
37 changes: 37 additions & 0 deletions src/Argon.Api/Argon.Api.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="8.0.10"/>
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.10">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Orleans.Server" Version="8.2.0"/>
<PackageReference Include="Orleans.Clustering.Kubernetes" Version="8.2.0"/>
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0"/>
</ItemGroup>

<ItemGroup>
<Folder Include="Controllers\"/>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\Contracts\Argon.Grains\Argon.Grains.csproj"/>
<ProjectReference Include="..\Argon.Api.Common\Argon.Api.Common.csproj"/>
<ProjectReference Include="..\ServiceDefaults\ServiceDefaults.csproj"/>
</ItemGroup>

<ItemGroup>
<Content Include="..\..\.dockerignore">
<Link>.dockerignore</Link>
</Content>
</ItemGroup>

</Project>
27 changes: 27 additions & 0 deletions src/Argon.Api/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
FROM mcr.microsoft.com/dotnet/aspnet:8.0-alpine-arm64v8 AS base
USER $APP_UID
WORKDIR /app
EXPOSE 8080
EXPOSE 8081

FROM mcr.microsoft.com/dotnet/sdk:8.0-alpine-arm64v8 AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
COPY ["src/Argon.Api/Argon.Api.csproj", "src/Argon.Api/"]
COPY ["src/ServiceDefaults/ServiceDefaults.csproj", "src/ServiceDefaults/"]
COPY ["Contracts/Argon.Grains/Argon.Grains.csproj", "Contracts/Argon.Grains/"]
COPY ["Contracts/Argon.Grains.Interfaces/Argon.Grains.Interfaces.csproj", "Contracts/Argon.Grains.Interfaces/"]
COPY ["src/Argon.Api.Common/Argon.Api.Common.csproj", "src/Argon.Api.Common/"]
RUN dotnet restore "src/Argon.Api/Argon.Api.csproj"
COPY . .
WORKDIR "/src/src/Argon.Api"
RUN dotnet build "Argon.Api.csproj" -c $BUILD_CONFIGURATION -o /app/build

FROM build AS publish
ARG BUILD_CONFIGURATION=Release
RUN dotnet publish "Argon.Api.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Argon.Api.dll"]
9 changes: 9 additions & 0 deletions src/Argon.Api/Entities/ApplicationDbContext.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using Argon.Api.Common.Models;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;

namespace Argon.Api.Entities;

public class ApplicationDbContext(DbContextOptions<ApplicationDbContext> options)
: IdentityDbContext<ApplicationUser, IdentityRole<Guid>, Guid>(options);
29 changes: 29 additions & 0 deletions src/Argon.Api/Migrations/20241012001305_Init.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions src/Argon.Api/Migrations/20241012001305_Init.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace Argon.Api.Migrations
{
/// <inheritdoc />
public partial class Init : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{

}

/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{

}
}
}
Loading

0 comments on commit b732883

Please sign in to comment.