diff --git a/Dockerfile b/Dockerfile index 3ee6cf368..eafb78999 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,15 +1,18 @@ # syntax=docker/dockerfile:1 +FROM node:24-bookworm-slim AS node-build +WORKDIR /App + +# Build javascript library. The npm cache mount speeds up repeated local builds. +COPY . ./ +RUN --mount=type=cache,id=try-npm,target=/root/.npm \ + /App/build-js.sh + FROM mcr.microsoft.com/dotnet/sdk:10.0-azurelinux3.0 AS build-env WORKDIR /App # Make sure we run bash CMD ["bash"] -# Install all required build tools in a single layer (rarely changes — stays cached) -# Use nodejs24 for Node 24.x (required for ESM-compatible dependencies). -RUN --mount=type=cache,id=try-tdnf,target=/var/cache/tdnf,sharing=locked \ - tdnf install -y gawk nodejs24 nodejs24-npm - # Copy only the files needed to restore dependencies. # These layers are cached until a manifest file changes, so routine source edits # don't re-run the expensive restore steps below. @@ -38,9 +41,9 @@ RUN --mount=type=cache,id=try-nuget,target=/root/.nuget/packages \ # Copy all remaining source (changes frequently — only layers below rebuild on edits) COPY . ./ -# Build javascript library. The npm cache mount speeds up repeated local builds. -RUN --mount=type=cache,id=try-npm,target=/root/.npm \ - /App/build-js.sh +# Bring built JS/CSS artifacts from the Node build stage. +COPY --from=node-build /App/src/Microsoft.TryDotNet/wwwroot/api /App/src/Microsoft.TryDotNet/wwwroot/api +COPY --from=node-build /App/src/Microsoft.TryDotNet/wwwroot/css /App/src/Microsoft.TryDotNet/wwwroot/css # Publish only what we deploy RUN --mount=type=cache,id=try-nuget,target=/root/.nuget/packages \