Remote Docker build error with Nodejs and ASP.NET

Hi all,

I am getting an error:

 => ERROR [build  2/10] COPY --from=node_base . .                                                                                                               3.1s
------
 > [build  2/10] COPY --from=node_base . .:
------
Error failed to fetch an image or build from source: error building: cannot replace to directory /data/docker/overlay2/[alpha-numeric string]/merged/usr/share/doc/perl-base with file

(I have removed the string after /overlay2/ because I am not sure if that is sensitive to my organization)

when trying to build this Dockerfile:

FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
WORKDIR /app
EXPOSE 80

FROM node:lts AS node_base
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
COPY --from=node_base . .

WORKDIR /src
# copy csproj and restore as distinct layers
COPY *.sln .
COPY RazorPagesUI/*.csproj ./RazorPagesUI/
RUN dotnet restore
# copy everything else and build app
COPY RazorPagesUI/. ./RazorPagesUI/
WORKDIR /src/RazorPagesUI

RUN npm ci

RUN dotnet build -c Release -o /app/build

FROM build as publish
RUN dotnet publish -c release -o /app --no-restore

# final stage/image
FROM base
WORKDIR /app
COPY --from=publish /app ./
ENV ASPNETCORE_URLS="http://+:8080"
ENTRYPOINT ["dotnet", "RazorPagesUI.dll"]

The build works on my local machine, although that is an arch64-linux build since my machine is an M1 Mac.

I would build the image during the GH Action deploy process but fly’s builds are free and I don’t have to deal with a Docker registry so…hopefully I can get this working.

Thanks,

Jack

Doing a copy from node_base would not be the best way to get node installed and is probably copying a ton of dependencies you don’t need.

Can you try replacing the top with something like:

FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
WORKDIR /app
EXPOSE 80

FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
RUN apt-get update && apt-get install nodejs