diff --git a/docker/all-in-one/Dockerfile b/docker/all-in-one/Dockerfile index fb628cc8..3bd3ca2a 100644 --- a/docker/all-in-one/Dockerfile +++ b/docker/all-in-one/Dockerfile @@ -45,8 +45,11 @@ COPY src/GarageStack.Data/GarageStack.Data.csproj GarageStack.Data/ COPY src/GarageStack.Api/GarageStack.Api.csproj GarageStack.Api/ COPY src/GarageStack.Worker/GarageStack.Worker.csproj GarageStack.Worker/ # The NuGet cache lives in a BuildKit cache mount, so a local rebuild after a package change -# only downloads what changed. The packages are not in any layer, so publish mounts it too. -RUN --mount=type=cache,id=nuget,target=/root/.nuget/packages \ +# only downloads what changed. sharing=locked makes parallel builds take turns (compose builds +# the API and Worker at once): NuGet keeps its locks in each container's own /tmp, so two +# restores into one shared folder delete each other's files. publish restores again rather than +# rely on the restore layer, because BuildKit can keep that layer after it evicts the mount. +RUN --mount=type=cache,id=nuget,target=/root/.nuget/packages,sharing=locked \ dotnet restore GarageStack.Api/GarageStack.Api.csproj \ && dotnet restore GarageStack.Worker/GarageStack.Worker.csproj COPY src/GarageStack.Core/ GarageStack.Core/ @@ -54,9 +57,9 @@ COPY src/GarageStack.Data/ GarageStack.Data/ COPY src/GarageStack.Api/ GarageStack.Api/ COPY src/GarageStack.Worker/ GarageStack.Worker/ # ${APP_VERSION#v} strips a leading "v" (e.g. a tag name), which MinVer rejects -RUN --mount=type=cache,id=nuget,target=/root/.nuget/packages \ - dotnet publish GarageStack.Api/GarageStack.Api.csproj --no-restore -c Release -o /publish/api /p:MinVerVersionOverride=${APP_VERSION#v} \ - && dotnet publish GarageStack.Worker/GarageStack.Worker.csproj --no-restore -c Release -o /publish/worker /p:MinVerVersionOverride=${APP_VERSION#v} +RUN --mount=type=cache,id=nuget,target=/root/.nuget/packages,sharing=locked \ + dotnet publish GarageStack.Api/GarageStack.Api.csproj -c Release -o /publish/api /p:MinVerVersionOverride=${APP_VERSION#v} \ + && dotnet publish GarageStack.Worker/GarageStack.Worker.csproj -c Release -o /publish/worker /p:MinVerVersionOverride=${APP_VERSION#v} # ── Stage 3: Pull SAIC MQTT Gateway (source of truth for the gateway app) ──── # The gateway is not on PyPI. We copy its pre-built venv + source directly from diff --git a/src/GarageStack.Api/Dockerfile b/src/GarageStack.Api/Dockerfile index 30fa3e81..a1d87560 100644 --- a/src/GarageStack.Api/Dockerfile +++ b/src/GarageStack.Api/Dockerfile @@ -9,16 +9,19 @@ COPY ["src/GarageStack.Core/GarageStack.Core.csproj", "GarageStack.Core/"] COPY ["src/GarageStack.Data/GarageStack.Data.csproj", "GarageStack.Data/"] COPY ["src/GarageStack.Api/GarageStack.Api.csproj", "GarageStack.Api/"] # The NuGet cache lives in a BuildKit cache mount, so a local rebuild after a package change -# only downloads what changed. The packages are not in any layer, so publish mounts it too. -RUN --mount=type=cache,id=nuget,target=/root/.nuget/packages \ +# only downloads what changed. sharing=locked makes parallel builds take turns (compose builds +# the API and Worker at once): NuGet keeps its locks in each container's own /tmp, so two +# restores into one shared folder delete each other's files. publish restores again rather than +# rely on the restore layer, because BuildKit can keep that layer after it evicts the mount. +RUN --mount=type=cache,id=nuget,target=/root/.nuget/packages,sharing=locked \ dotnet restore "GarageStack.Api/GarageStack.Api.csproj" COPY src/GarageStack.Core/ GarageStack.Core/ COPY src/GarageStack.Data/ GarageStack.Data/ COPY src/GarageStack.Api/ GarageStack.Api/ WORKDIR /src/GarageStack.Api # ${APP_VERSION#v} strips a leading "v" (e.g. a tag name), which MinVer rejects -RUN --mount=type=cache,id=nuget,target=/root/.nuget/packages \ - dotnet publish --no-restore -c Release -o /app /p:MinVerVersionOverride=${APP_VERSION#v} +RUN --mount=type=cache,id=nuget,target=/root/.nuget/packages,sharing=locked \ + dotnet publish -c Release -o /app /p:MinVerVersionOverride=${APP_VERSION#v} # Alpine with the "extra" globalization set: full ICU data (the API answers in en, nl, es and # pt) and tzdata (climate schedules keep their start time in an IANA zone) are built in. About diff --git a/src/GarageStack.Worker/Dockerfile b/src/GarageStack.Worker/Dockerfile index 7be6219c..5136d88c 100644 --- a/src/GarageStack.Worker/Dockerfile +++ b/src/GarageStack.Worker/Dockerfile @@ -9,16 +9,19 @@ COPY ["src/GarageStack.Core/GarageStack.Core.csproj", "GarageStack.Core/"] COPY ["src/GarageStack.Data/GarageStack.Data.csproj", "GarageStack.Data/"] COPY ["src/GarageStack.Worker/GarageStack.Worker.csproj", "GarageStack.Worker/"] # The NuGet cache lives in a BuildKit cache mount, so a local rebuild after a package change -# only downloads what changed. The packages are not in any layer, so publish mounts it too. -RUN --mount=type=cache,id=nuget,target=/root/.nuget/packages \ +# only downloads what changed. sharing=locked makes parallel builds take turns (compose builds +# the API and Worker at once): NuGet keeps its locks in each container's own /tmp, so two +# restores into one shared folder delete each other's files. publish restores again rather than +# rely on the restore layer, because BuildKit can keep that layer after it evicts the mount. +RUN --mount=type=cache,id=nuget,target=/root/.nuget/packages,sharing=locked \ dotnet restore "GarageStack.Worker/GarageStack.Worker.csproj" COPY src/GarageStack.Core/ GarageStack.Core/ COPY src/GarageStack.Data/ GarageStack.Data/ COPY src/GarageStack.Worker/ GarageStack.Worker/ WORKDIR /src/GarageStack.Worker # ${APP_VERSION#v} strips a leading "v" (e.g. a tag name), which MinVer rejects -RUN --mount=type=cache,id=nuget,target=/root/.nuget/packages \ - dotnet publish --no-restore -c Release -o /app /p:MinVerVersionOverride=${APP_VERSION#v} +RUN --mount=type=cache,id=nuget,target=/root/.nuget/packages,sharing=locked \ + dotnet publish -c Release -o /app /p:MinVerVersionOverride=${APP_VERSION#v} # Alpine with the "extra" globalization set: full ICU data (notifications are translated) and # tzdata (climate schedules keep their start time in an IANA zone) are built in. About 37 MB