45 lines
2.3 KiB
Docker
45 lines
2.3 KiB
Docker
# Builds the LaDOSE.Api image. Context is LaDOSE.Src (see .dockerignore next to this file).
|
|
#
|
|
# Only LaDOSE.Api is published. LaDOSE.linux.sln also carries the Avalonia desktop app,
|
|
# the Discord bot and LinuxTest, and `dotnet publish <sln> -o out` flattens every project
|
|
# into that one directory — which is why the previous version of this file copied from
|
|
# /app/LaDOSE.Api/out/ and found nothing there.
|
|
ARG DOTNET_VERSION=9.0
|
|
|
|
FROM mcr.microsoft.com/dotnet/sdk:${DOTNET_VERSION} AS build
|
|
WORKDIR /src
|
|
|
|
# Debug is deliberate for local work, and docker-compose.yml passes it: the OpenAPI
|
|
# document and the Scalar UI are gated behind `#if DEBUG` in Startup.cs *and* behind
|
|
# Condition="'$(Configuration)' == 'Debug'" on their PackageReferences in
|
|
# LaDOSE.Api.csproj. A Release image therefore serves no /openapi/v1.json, which is
|
|
# exactly what LaDOSE.WebApp's `npm run api:sync` reads. Default stays Release.
|
|
ARG BUILD_CONFIGURATION=Release
|
|
|
|
# Project files first so this layer survives every .cs edit. Restore has to run under
|
|
# the same Configuration as the publish below, or the conditional PackageReferences
|
|
# above make the two disagree about which packages the assets file should contain.
|
|
COPY global.json ./
|
|
COPY LaDOSE.Api/LaDOSE.Api.csproj LaDOSE.Api/
|
|
COPY LaDOSE.DTO/LaDOSE.DTO.csproj LaDOSE.DTO/
|
|
COPY LaDOSE.Entity/LaDOSE.Entity.csproj LaDOSE.Entity/
|
|
COPY LaDOSE.Service/LaDOSE.Business.csproj LaDOSE.Service/
|
|
RUN dotnet restore LaDOSE.Api/LaDOSE.Api.csproj -p:Configuration=${BUILD_CONFIGURATION}
|
|
|
|
# Libraries/ChallongeCSharpDriver.dll is a HintPath reference from LaDOSE.Business,
|
|
# so the build needs the whole tree, not just the projects listed above.
|
|
COPY . .
|
|
RUN dotnet publish LaDOSE.Api/LaDOSE.Api.csproj -c ${BUILD_CONFIGURATION} --no-restore -o /app/out
|
|
|
|
FROM mcr.microsoft.com/dotnet/aspnet:${DOTNET_VERSION}
|
|
WORKDIR /app
|
|
COPY --from=build /app/out/ ./
|
|
|
|
# Fixed in the image on purpose. Program.cs binds Kestrel from appsettings.json's
|
|
# AllowedHosts/Port through a ConfigurationBuilder that reads *only* that file, so a
|
|
# Port env var would not move the listener — remap on the host side instead.
|
|
# Everything Startup.cs reads does honour env vars (ConnectionStrings__DbContext,
|
|
# ApiKey__SmashApiKey, ApiKey__ChallongeApiKey, JWTTokenSecret).
|
|
EXPOSE 5000
|
|
ENTRYPOINT ["dotnet", "LaDOSE.Api.dll"]
|