Adds docker support for the server API.

This commit is contained in:
BinaryAlley committed 2024-09-12 13:48:37 +03:00
1 parent dfc7112cb7
commit 4a53348013
10 files changed
+178 -14

No files matched your search

+30
View File
@@ -0,0 +1,30 @@
**/.classpath
**/.dockerignore
**/.env
**/.git
**/.gitignore
**/.project
**/.settings
**/.toolstarget
**/.vs
**/.vscode
**/*.*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
!**/.gitignore
!.git/HEAD
!.git/config
!.git/packed-refs
!.git/refs/heads/**
+54
View File
@@ -0,0 +1,54 @@
# This stage is used when running from VS in fast mode (Default for Debug configuration)
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
USER app
WORKDIR /app
EXPOSE 5214
# ==== Stage 1: Build stage
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
# restore NuGet packages (keeping this section separate from the rest of the project files allows Docker to cache the restored packages)
COPY ["AssemblyInfo_Shared.cs", "."]
COPY ["Lumina.Presentation.Api/Lumina.Presentation.Api.csproj", "Lumina.Presentation.Api/"]
COPY ["Lumina.Application/Lumina.Application.csproj", "Lumina.Application/"]
COPY ["Lumina.Domain/Lumina.Domain.csproj", "Lumina.Domain/"]
COPY ["Lumina.Infrastructure/Lumina.Infrastructure.csproj", "Lumina.Infrastructure/"]
COPY ["Lumina.DataAccess/Lumina.DataAccess.csproj", "Lumina.DataAccess/"]
RUN dotnet restore "./Lumina.Presentation.Api/Lumina.Presentation.Api.csproj" /p:BaseOutputPath=/app/publish/
# build the project
COPY ["Lumina.Presentation.Api/", "Lumina.Presentation.Api/"]
COPY ["Lumina.Application/", "Lumina.Application/"]
COPY ["Lumina.Domain/", "Lumina.Domain/"]
COPY ["Lumina.Infrastructure/", "Lumina.Infrastructure/"]
COPY ["Lumina.DataAccess/", "Lumina.DataAccess/"]
COPY . .
WORKDIR /src/Lumina.Presentation.Api
RUN dotnet build "./Lumina.Presentation.Api.csproj" -c $BUILD_CONFIGURATION -o /app/build /p:BaseOutputPath=/app/publish/
# ==== Stage 2: Publish stage
FROM build AS publish
ARG BUILD_CONFIGURATION=Release
RUN dotnet publish "./Lumina.Presentation.Api.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false /p:BaseOutputPath=/app/publish/
# ==== Stage 3: Run stage
#FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS runtime
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENV ASPNETCORE_HTTP_PORTS=5214
EXPOSE 5214
ENTRYPOINT ["dotnet", "Lumina.Presentation.Api.dll"]
# to build this Docker image, run the following command from the root of the project (location of the .sln file):
# docker build --no-cache -t lumina-server -f Lumina.Presentation.Api/Dockerfile .
@@ -3,9 +3,14 @@
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<BaseOutputPath>..\..\bin\</BaseOutputPath>
<ImplicitUsings>disable</ImplicitUsings>
<BaseOutputPath>$(SolutionDir)..\bin\server\</BaseOutputPath>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<UserSecretsId>37d55c87-4374-4971-82e9-012fcaad1853</UserSecretsId>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<ContainerRepository>lumina-server</ContainerRepository>
<DockerfileTag>lumina-server</DockerfileTag>
<DockerComposeProjectPath>..\docker-compose.dcproj</DockerComposeProjectPath>
</PropertyGroup>
<ItemGroup>
@@ -24,6 +29,7 @@
<PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning" Version="5.1.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning.ApiExplorer" Version="5.1.0" />
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.8" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.21.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.7.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.8">
<PrivateAssets>all</PrivateAssets>
@@ -1,25 +1,32 @@
{
"$schema": "http://json.schemastore.org/launchsettings.json",
{
"profiles": {
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": false,
"launchUrl": "swagger",
"applicationUrl": "http://localhost:5214",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"dotnetRunMessages": true,
"applicationUrl": "http://localhost:5214"
},
"https": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": false,
"launchUrl": "swagger",
"applicationUrl": "https://localhost:7057;http://localhost:5214",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"dotnetRunMessages": true,
"applicationUrl": "https://localhost:7057;http://localhost:5214"
},
"Container (Dockerfile)": {
"commandName": "Docker",
"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}",
"environmentVariables": {
"ASPNETCORE_HTTP_PORTS": "5214"
},
"publishAllPorts": true,
"useSSL": true
}
}
}
},
"$schema": "http://json.schemastore.org/launchsettings.json"
}
+6
View File
@@ -69,6 +69,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Lumina.DataAccess.Integrati
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Lumina.Presentation.Api.IntegrationTests", "..\tests\IntegrationTests\Lumina.Presentation.Api.IntegrationTests\Lumina.Presentation.Api.IntegrationTests.csproj", "{3680DAFB-10BA-4A0F-AE40-620D06DAF617}"
EndProject
Project("{E53339B2-1760-4266-BCC7-CA923CBCF16C}") = "docker-compose", "docker-compose.dcproj", "{D4C61542-FC91-47FA-B1D2-11CC99617454}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -127,6 +129,10 @@ Global
{3680DAFB-10BA-4A0F-AE40-620D06DAF617}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3680DAFB-10BA-4A0F-AE40-620D06DAF617}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3680DAFB-10BA-4A0F-AE40-620D06DAF617}.Release|Any CPU.Build.0 = Release|Any CPU
{D4C61542-FC91-47FA-B1D2-11CC99617454}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D4C61542-FC91-47FA-B1D2-11CC99617454}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D4C61542-FC91-47FA-B1D2-11CC99617454}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D4C61542-FC91-47FA-B1D2-11CC99617454}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
+19
View File
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" Sdk="Microsoft.Docker.Sdk">
<PropertyGroup Label="Globals">
<ProjectVersion>2.1</ProjectVersion>
<DockerTargetOS>Linux</DockerTargetOS>
<DockerPublishLocally>False</DockerPublishLocally>
<ProjectGuid>d4c61542-fc91-47fa-b1d2-11cc99617454</ProjectGuid>
</PropertyGroup>
<ItemGroup>
<None Include="docker-compose.override.yml">
<DependentUpon>docker-compose.yml</DependentUpon>
</None>
<None Include="docker-compose.vs.debug.yml">
<DependentUpon>docker-compose.yml</DependentUpon>
</None>
<None Include="docker-compose.yml" />
<None Include=".dockerignore" />
</ItemGroup>
</Project>
+15
View File
@@ -0,0 +1,15 @@
services:
lumina.presentation.api:
container_name: lumina-server
build:
context: .
dockerfile: Lumina.Presentation.Api/Dockerfile
environment:
- ASPNETCORE_ENVIRONMENT=Development
- ASPNETCORE_HTTP_PORTS=5214
ports:
- "5214:5214"
volumes:
- ${APPDATA}/Microsoft/UserSecrets:/home/app/.microsoft/usersecrets:ro
- ${APPDATA}/ASP.NET/Https:/home/app/.aspnet/https:ro
command: "dotnet /app/Lumina.Presentation.Api.dll"
+9
View File
@@ -0,0 +1,9 @@
# this file is required because the default base output path for the projects has been changed, and we need to tell docker compose where to take the files from, in debug mode
# this file is the last in the chain of files when docker-compose commands are called, so it always takes precedence
services:
lumina.presentation.api:
labels:
com.microsoft.visualstudio.debuggee.program: "/app/Lumina.Presentation.Api.dll"
com.microsoft.visualstudio.debuggee.workingdirectory: "/app"
volumes:
- ../bin/server/Debug/net8.0:/app
+7
View File
@@ -0,0 +1,7 @@
services:
lumina.presentation.api:
container_name: lumina-server
image: ${DOCKER_REGISTRY-}lumina-server
build:
context: .
dockerfile: Lumina.Presentation.Api/Dockerfile
+11
View File
@@ -0,0 +1,11 @@
{
"profiles": {
"Docker Compose": {
"commandName": "DockerCompose",
"commandVersion": "1.0",
"serviceActions": {
"lumina.presentation.api": "StartDebugging"
}
}
}
}