# 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). # - Bakes docker-compose-local-dev/appsettings.local.json over appsettings.json. # The repo's appsettings.json now only carries a NacosConfig section and pulls # the real settings from a Nacos server (192.168.1.120:8848) that is not # reachable in local dev. Program.cs only loads Nacos when a NacosConfig # section exists, so replacing appsettings.json with a Nacos-free, fully # self-contained config makes the app start without Nacos. # # Build context = repository root (AML_Backend); this Dockerfile lives one level # down in docker-compose-local-dev/. BuildKit uses the sibling # docker-compose-local-dev/Dockerfile.local.dockerignore (not the repo-root # .dockerignore), which keeps appsettings.json and docker-compose-local-dev/. ############################ # 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 base: refresh CA certificates so outbound HTTPS to services whose # chain the stock image can't complete (e.g. the stag iCS at *.iconsz.com, # ZeroSSL/Sectigo-issued -> "PartialChain") validates. The app's own cert # bypass only covers legacy WebClient (ServicePointManager), not HttpClient, # so we fix trust at the OS level to cover every code path. ############################ FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS runtime-base RUN apt-get update \ && apt-get install -y --no-install-recommends ca-certificates \ && update-ca-certificates \ && rm -rf /var/lib/apt/lists/* ############################ # Runtime: API host ############################ FROM runtime-base AS host WORKDIR /app COPY --from=publish-host /app/host ./ # Local dev: replace the Nacos-only appsettings.json with a full self-contained # config (no NacosConfig section -> the app does not try to reach Nacos). COPY docker-compose-local-dev/appsettings.local.json ./appsettings.json 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 runtime-base AS migrator WORKDIR /app COPY --from=publish-migrator /app/migrator ./ # Same Nacos-free local config as the host (the migrator's own appsettings.json # is Nacos-only too); reuse the host's seed Data / wwwroot content. COPY docker-compose-local-dev/appsettings.local.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"]