diff --git a/src/.dockerignore b/src/.dockerignore new file mode 100644 index 00000000..fe1152bd --- /dev/null +++ b/src/.dockerignore @@ -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/** \ No newline at end of file diff --git a/src/Lumina.Presentation.Api/Dockerfile b/src/Lumina.Presentation.Api/Dockerfile new file mode 100644 index 00000000..710c6ca3 --- /dev/null +++ b/src/Lumina.Presentation.Api/Dockerfile @@ -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 . \ No newline at end of file diff --git a/src/Lumina.Presentation.Api/Lumina.Presentation.Api.csproj b/src/Lumina.Presentation.Api/Lumina.Presentation.Api.csproj index 340ea58b..505eb995 100644 --- a/src/Lumina.Presentation.Api/Lumina.Presentation.Api.csproj +++ b/src/Lumina.Presentation.Api/Lumina.Presentation.Api.csproj @@ -3,9 +3,14 @@ net8.0 enable - enable - ..\..\bin\ + disable + $(SolutionDir)..\bin\server\ false + 37d55c87-4374-4971-82e9-012fcaad1853 + Linux + lumina-server + lumina-server + ..\docker-compose.dcproj @@ -24,6 +29,7 @@ + all diff --git a/src/Lumina.Presentation.Api/Properties/launchSettings.json b/src/Lumina.Presentation.Api/Properties/launchSettings.json index 19f75032..1ef0f32b 100644 --- a/src/Lumina.Presentation.Api/Properties/launchSettings.json +++ b/src/Lumina.Presentation.Api/Properties/launchSettings.json @@ -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" +} \ No newline at end of file diff --git a/src/Lumina.sln b/src/Lumina.sln index eedfba66..6077e9cf 100644 --- a/src/Lumina.sln +++ b/src/Lumina.sln @@ -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 diff --git a/src/docker-compose.dcproj b/src/docker-compose.dcproj new file mode 100644 index 00000000..a54dad6c --- /dev/null +++ b/src/docker-compose.dcproj @@ -0,0 +1,19 @@ + + + + 2.1 + Linux + False + d4c61542-fc91-47fa-b1d2-11cc99617454 + + + + docker-compose.yml + + + docker-compose.yml + + + + + \ No newline at end of file diff --git a/src/docker-compose.override.yml b/src/docker-compose.override.yml new file mode 100644 index 00000000..d7774a07 --- /dev/null +++ b/src/docker-compose.override.yml @@ -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" \ No newline at end of file diff --git a/src/docker-compose.vs.debug.yml b/src/docker-compose.vs.debug.yml new file mode 100644 index 00000000..684e66fa --- /dev/null +++ b/src/docker-compose.vs.debug.yml @@ -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 \ No newline at end of file diff --git a/src/docker-compose.yml b/src/docker-compose.yml new file mode 100644 index 00000000..d84ac5ae --- /dev/null +++ b/src/docker-compose.yml @@ -0,0 +1,7 @@ +services: + lumina.presentation.api: + container_name: lumina-server + image: ${DOCKER_REGISTRY-}lumina-server + build: + context: . + dockerfile: Lumina.Presentation.Api/Dockerfile diff --git a/src/launchSettings.json b/src/launchSettings.json new file mode 100644 index 00000000..fe4f1df9 --- /dev/null +++ b/src/launchSettings.json @@ -0,0 +1,11 @@ +{ + "profiles": { + "Docker Compose": { + "commandName": "DockerCompose", + "commandVersion": "1.0", + "serviceActions": { + "lumina.presentation.api": "StartDebugging" + } + } + } +} \ No newline at end of file