Skip to content

Commit

Permalink
Fixed CoreAPI seeding bug, updated docker configurations
Browse files Browse the repository at this point in the history
  • Loading branch information
stijuh committed May 27, 2023
1 parent 7b877b2 commit 650abee
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 11 deletions.
2 changes: 1 addition & 1 deletion GainsTracker.CoreAPI/Components/Security/Models/User.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ namespace GainsTracker.CoreAPI.Components.Security.Models;
public class User : IdentityUser
{
public override string Id { get; set; } = Guid.NewGuid().ToString();
public GainsAccount GainsAccount { get; set; } = new();
public GainsAccount? GainsAccount { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,11 @@ public static void ConfigureCors(this WebApplicationBuilder builder)
{
builder.Services.AddCors(options =>
{
options.AddPolicy("AllowAngularDevClient",
options.AddPolicy("AllowBlazorDevClient",
b =>
{
b
.WithOrigins("http://localhost:4200")
.WithOrigins("https://localhost:7093", "http://localhost:5027", "http://localhost:5027")
.AllowAnyHeader()
.AllowAnyMethod();
});
Expand Down
10 changes: 10 additions & 0 deletions GainsTracker.CoreAPI/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM mcr.microsoft.com/dotnet/aspnet:7.0

ENV ASPNETCORE_URLS=http://*:4040
ENV ASPNETCORE_ENVIRONMENT=Development

COPY ./bin/Release/net7.0/publish App/
WORKDIR /App
EXPOSE 4040

ENTRYPOINT ["dotnet","GainsTracker.CoreAPI.dll"]
10 changes: 5 additions & 5 deletions GainsTracker.CoreAPI/GainsTracker.CoreAPI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.4"/>
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.4">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="6.0.12"/>
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="7.0.3"/>
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3"/>
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="6.0.12" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="7.0.3" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\GainsTracker.Common\GainsTracker.Common.csproj"/>
<ProjectReference Include="..\GainsTracker.Common\GainsTracker.Common.csproj" />
</ItemGroup>
</Project>
4 changes: 2 additions & 2 deletions GainsTracker.CoreAPI/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

WebApplication app = builder.Build();

app.ResetAndUpdateDatabase();
app.ResetAndUpdateDatabase(false);

// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
Expand All @@ -30,7 +30,7 @@
app.UseSwaggerUI();
}

app.UseCors("AllowAngularDevClient");
app.UseCors("AllowBlazorDevClient");
app.UseHttpsRedirection();

// Authentication
Expand Down
2 changes: 1 addition & 1 deletion GainsTracker.CoreAPI/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
}
},
"ConnectionStrings": {
"databaseConnection": "Host=localhost:15432; Database=gainstracker_db; Username=stoy; Password=postman"
"databaseConnection": "Host=db:5432; Database=gainstracker_db; Username=stoy; Password=postman"
},
"JWT": {
"ValidAudience": "http://localhost:4200",
Expand Down
7 changes: 7 additions & 0 deletions GainsTracker.CoreAPI/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,10 @@ services:
DB_APP_PASS: gainstracker_db
volumes:
- ./development/postgres/data:/var/lib/postgresql/data
api:
build: ./
restart: always
depends_on:
- db
ports:
- "420:4040" # funny

0 comments on commit 650abee

Please sign in to comment.