From 0f5c5d7f1ae70f3a86680f487977612cd9a5995a Mon Sep 17 00:00:00 2001 From: Fillip Vikter Fontao Danelund <156663476+fontoinparis@users.noreply.github.com> Date: Fri, 28 Mar 2025 10:51:12 +0100 Subject: [PATCH] initial efcore solution + dockerfile --- DnDBattlefield/Data/AppDbContext.cs | 14 ++++++++++++++ DnDBattlefield/DnDBattlefield.csproj | 18 ++++++++++++++++++ DnDBattlefield/Program.cs | 2 ++ DnDBattlefield/docker-compose.yml | 22 ++++++++++++++++++++++ DnDBattlefield/dockerfile | 20 ++++++++++++++++++++ dnd-battlefield.sln | 24 ++++++++++++++++++++++++ 6 files changed, 100 insertions(+) create mode 100644 DnDBattlefield/Data/AppDbContext.cs create mode 100644 DnDBattlefield/DnDBattlefield.csproj create mode 100644 DnDBattlefield/Program.cs create mode 100644 DnDBattlefield/docker-compose.yml create mode 100644 DnDBattlefield/dockerfile create mode 100644 dnd-battlefield.sln diff --git a/DnDBattlefield/Data/AppDbContext.cs b/DnDBattlefield/Data/AppDbContext.cs new file mode 100644 index 0000000..f40a655 --- /dev/null +++ b/DnDBattlefield/Data/AppDbContext.cs @@ -0,0 +1,14 @@ +using Microsoft.EntityFrameworkCore; + +namespace DnDSpilleplade.API.Data +{ + public class AppDbContext : DbContext + { + + public AppDbContext(DbContextOptions<AppDbContext> options) : base(options) + { + + } + } +} + diff --git a/DnDBattlefield/DnDBattlefield.csproj b/DnDBattlefield/DnDBattlefield.csproj new file mode 100644 index 0000000..05284a8 --- /dev/null +++ b/DnDBattlefield/DnDBattlefield.csproj @@ -0,0 +1,18 @@ +<Project Sdk="Microsoft.NET.Sdk"> + + <PropertyGroup> + <OutputType>Exe</OutputType> + <TargetFramework>net9.0</TargetFramework> + <ImplicitUsings>enable</ImplicitUsings> + <Nullable>enable</Nullable> + </PropertyGroup> + + <ItemGroup> + <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.3"> + <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> + <PrivateAssets>all</PrivateAssets> + </PackageReference> + <PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="9.0.3" /> + </ItemGroup> + +</Project> diff --git a/DnDBattlefield/Program.cs b/DnDBattlefield/Program.cs new file mode 100644 index 0000000..3751555 --- /dev/null +++ b/DnDBattlefield/Program.cs @@ -0,0 +1,2 @@ +// See https://aka.ms/new-console-template for more information +Console.WriteLine("Hello, World!"); diff --git a/DnDBattlefield/docker-compose.yml b/DnDBattlefield/docker-compose.yml new file mode 100644 index 0000000..57a47b3 --- /dev/null +++ b/DnDBattlefield/docker-compose.yml @@ -0,0 +1,22 @@ +version: '3.9' + +services: + api: + build: + context: . + dockerfile: DnDSpilleplade.API/Dockerfile + ports: + - "5000:80" + environment: + - ASPNETCORE_ENVIRONMENT=Development + - ConnectionStrings__DefaultConnection=Server=sqlserver;Database=DnDDB;User=sa;Password=Your_password123; + depends_on: + - sqlserver + + sqlserver: + image: mcr.microsoft.com/mssql/server:2022-latest + environment: + SA_PASSWORD: "Your_password123" + ACCEPT_EULA: "Y" + ports: + - "1433:1433" diff --git a/DnDBattlefield/dockerfile b/DnDBattlefield/dockerfile new file mode 100644 index 0000000..3d38b84 --- /dev/null +++ b/DnDBattlefield/dockerfile @@ -0,0 +1,20 @@ +# Use the official .NET 9 SDK image to build the app +FROM mcr.microsoft.com/dotnet/sdk:9.0-preview AS build +WORKDIR /app + +# Copy solution and project files +COPY *.sln . +COPY DnDSpilleplade.API/*.csproj ./DnDSpilleplade.API/ +COPY DnDSpilleplade.Data/*.csproj ./DnDSpilleplade.Data/ +RUN dotnet restore + +# Copy the rest of the source code +COPY . . +WORKDIR /app/DnDSpilleplade.API +RUN dotnet publish -c Release -o out + +# Runtime image (ASP.NET Core 9 preview) +FROM mcr.microsoft.com/dotnet/aspnet:9.0-preview +WORKDIR /app +COPY --from=build /app/DnDSpilleplade.API/out ./ +ENTRYPOINT ["dotnet", "DnDSpilleplade.API.dll"] diff --git a/dnd-battlefield.sln b/dnd-battlefield.sln new file mode 100644 index 0000000..b28a12d --- /dev/null +++ b/dnd-battlefield.sln @@ -0,0 +1,24 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.5.2.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DnDBattlefield", "DnDBattlefield\DnDBattlefield.csproj", "{7339DEAA-3CFC-DC3F-4E87-8A8EF05B6965}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {7339DEAA-3CFC-DC3F-4E87-8A8EF05B6965}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7339DEAA-3CFC-DC3F-4E87-8A8EF05B6965}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7339DEAA-3CFC-DC3F-4E87-8A8EF05B6965}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7339DEAA-3CFC-DC3F-4E87-8A8EF05B6965}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {CD890992-A0AD-4A6B-93FB-11B6B3DD0BB2} + EndGlobalSection +EndGlobal -- GitLab