69 lines
2.7 KiB
Docker
69 lines
2.7 KiB
Docker
# syntax=docker/dockerfile:1
|
|
#
|
|
# Local-development image for iCON.Abp.FX.HttpApi.Host (+ DbMigrator).
|
|
#
|
|
# Differs from src/iCON.Abp.FX.HttpApi.Host/Dockerfile (CI):
|
|
# - Targets .NET 6 (the projects are net6.0; the CI Dockerfile still says 5.0).
|
|
# - Does not COPY the non-existent src/access-token.bin.
|
|
# - Produces two runtime targets: `host` (the API) and `migrator` (data init).
|
|
#
|
|
# Build context = repository root (AML_Backend). See Dockerfile.local.dockerignore.
|
|
|
|
############################
|
|
# Restore + build (whole solution available)
|
|
############################
|
|
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
|
|
ARG BUILD_CONFIGURATION=Release
|
|
WORKDIR /src
|
|
|
|
# NuGet.Config carries the ABP commercial feed (the account key is embedded in the URL).
|
|
COPY NuGet.Config ./
|
|
COPY . .
|
|
|
|
# Cache the NuGet global-packages folder so context changes don't force a re-download.
|
|
RUN --mount=type=cache,target=/root/.nuget/packages \
|
|
dotnet restore "src/iCON.Abp.FX.HttpApi.Host/iCON.Abp.FX.HttpApi.Host.csproj" && \
|
|
dotnet restore "src/iCON.Abp.FX.DbMigrator/iCON.Abp.FX.DbMigrator.csproj"
|
|
|
|
############################
|
|
# Publish API host
|
|
############################
|
|
FROM build AS publish-host
|
|
ARG BUILD_CONFIGURATION=Release
|
|
# -m:1 builds one project at a time to keep peak memory down (this solution's
|
|
# DbMigrations project is large enough to OOM Roslyn when compiled in parallel).
|
|
RUN --mount=type=cache,target=/root/.nuget/packages \
|
|
dotnet publish "src/iCON.Abp.FX.HttpApi.Host/iCON.Abp.FX.HttpApi.Host.csproj" \
|
|
-c "$BUILD_CONFIGURATION" -o /app/host /p:UseAppHost=false -m:1
|
|
|
|
############################
|
|
# Publish DbMigrator (schema migration + data seeding)
|
|
############################
|
|
FROM build AS publish-migrator
|
|
ARG BUILD_CONFIGURATION=Release
|
|
RUN --mount=type=cache,target=/root/.nuget/packages \
|
|
dotnet publish "src/iCON.Abp.FX.DbMigrator/iCON.Abp.FX.DbMigrator.csproj" \
|
|
-c "$BUILD_CONFIGURATION" -o /app/migrator /p:UseAppHost=false -m:1
|
|
|
|
############################
|
|
# Runtime: API host
|
|
############################
|
|
FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS host
|
|
WORKDIR /app
|
|
COPY --from=publish-host /app/host ./
|
|
EXPOSE 44331
|
|
ENTRYPOINT ["dotnet", "iCON.Abp.FX.HttpApi.Host.dll"]
|
|
|
|
############################
|
|
# Runtime: DbMigrator
|
|
# Seed contributors read data files and the full AppConfig relative to the
|
|
# app base directory, so we reuse the host's appsettings.json / Data / wwwroot.
|
|
############################
|
|
FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS migrator
|
|
WORKDIR /app
|
|
COPY --from=publish-migrator /app/migrator ./
|
|
COPY --from=publish-host /app/host/appsettings.json ./appsettings.json
|
|
COPY --from=publish-host /app/host/Data ./Data
|
|
COPY --from=publish-host /app/host/wwwroot ./wwwroot
|
|
ENTRYPOINT ["dotnet", "iCON.Abp.FX.DbMigrator.dll"]
|