-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into dependabot/nuget/coverlet.collector-6.0.2
- Loading branch information
Showing
23 changed files
with
556 additions
and
310 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
**/.dockerignore | ||
**/.env | ||
**/.git | ||
**/.gitignore | ||
**/.project | ||
**/.settings | ||
**/.toolstarget | ||
**/.vs | ||
**/.vscode | ||
**/.idea | ||
**/*.*proj.user | ||
**/*.dbmdl | ||
**/*.jfm | ||
**/azds.yaml | ||
**/bin | ||
**/charts | ||
**/docker-compose* | ||
**/Dockerfile* | ||
**/node_modules | ||
**/npm-debug.log | ||
**/obj | ||
**/secrets.dev.yaml | ||
**/values.dev.yaml | ||
LICENSE | ||
README.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
LOCAL_SQL_PASSWORD=L0c4l_S3cr3t_P4a5sw0rD |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<Project> | ||
<PropertyGroup> | ||
<NuGetAuditMode>direct</NuGetAuditMode> | ||
</PropertyGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS base | ||
WORKDIR /app | ||
EXPOSE 80 | ||
EXPOSE 443 | ||
|
||
FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build | ||
ARG BUILD_CONFIGURATION=Debug | ||
COPY *.sln . | ||
COPY . . | ||
RUN dotnet restore | ||
WORKDIR "/src/DevBetterWeb.Web" | ||
RUN dotnet build "DevBetterWeb.Web.csproj" -c $BUILD_CONFIGURATION -o /app/build | ||
|
||
FROM build AS publish | ||
ARG BUILD_CONFIGURATION=Debug | ||
RUN dotnet publish "DevBetterWeb.Web.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false | ||
|
||
FROM base AS final | ||
WORKDIR /app | ||
COPY --from=publish /app/publish . | ||
# Optional: Set this here if not setting it from docker-compose.yml | ||
ENV ASPNETCORE_ENVIRONMENT=Local | ||
ENTRYPOINT ["dotnet", "DevBetterWeb.Web.dll"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
services: | ||
web: | ||
image: dev-better-web | ||
container_name: dev-better-web | ||
depends_on: | ||
- database | ||
ports: | ||
- 80:80 | ||
build: | ||
context: . | ||
dockerfile: Dockerfile | ||
networks: | ||
- my-network | ||
environment: | ||
ASPNETCORE_ENVIRONMENT: Development | ||
ConnectionStrings:DefaultConnection: Server=database,1433;MultipleActiveResultSets=true;User Id=sa;Password=${LOCAL_SQL_PASSWORD};Encrypt=false | ||
|
||
database: | ||
image: mcr.microsoft.com/azure-sql-edge | ||
cap_add: | ||
- SYS_PTRACE | ||
environment: | ||
- ACCEPT_EULA=1 | ||
- MSSQL_SA_PASSWORD=${LOCAL_SQL_PASSWORD} | ||
ports: | ||
- 1433:1433 | ||
container_name: ms-sql | ||
command: | ||
- "/bin/sh" | ||
- "-c" | ||
- "/opt/mssql/bin/launchpadd -usens=false -enableOutboundAccess=true -usesameuser=true -sqlGroup root -- -reparentOrphanedDescendants=true -useDefaultLaunchers=false & /app/asdepackage/AsdePackage & /opt/mssql/bin/sqlservr" | ||
privileged: true | ||
networks: | ||
- my-network | ||
|
||
networks: | ||
my-network: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"sdk": { | ||
"version": "8.0.0", | ||
"version": "8.*", | ||
"rollForward": "latestFeature" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using Microsoft.EntityFrameworkCore; | ||
using Microsoft.Extensions.Logging; | ||
|
||
namespace DevBetterWeb.Web; | ||
|
||
public interface ILocalMigrationService<TContext> where TContext : DbContext | ||
{ | ||
Task ApplyDatabaseMigrationsAsync(); | ||
} | ||
|
||
public class MigrationService<TContext> : ILocalMigrationService<TContext> | ||
where TContext : DbContext | ||
{ | ||
private readonly ILogger<MigrationService<TContext>> _logger; | ||
|
||
private readonly TContext _dbContext; | ||
|
||
public MigrationService( | ||
TContext context, | ||
ILoggerFactory loggerFactory) | ||
{ | ||
_logger = loggerFactory.CreateLogger<MigrationService<TContext>>(); | ||
_dbContext = context; | ||
} | ||
|
||
public async Task ApplyDatabaseMigrationsAsync() | ||
{ | ||
if (await NoPendingMigrationsAsync(_dbContext)) | ||
{ | ||
_logger.LogInformation($"No pending migrations to apply for context: {typeof(TContext).Name}"); | ||
return; | ||
} | ||
|
||
_logger.LogInformation($"Applying pending migrations for context: {typeof(TContext).Name}..."); | ||
await _dbContext.Database.MigrateAsync(); | ||
_logger.LogInformation($"Migrations applied successfully for context: {typeof(TContext).Name}"); | ||
} | ||
|
||
private static async Task<bool> NoPendingMigrationsAsync(TContext dbContext) => | ||
!(await dbContext.Database.GetPendingMigrationsAsync()).Any(); | ||
} |
Oops, something went wrong.