I am trying to build a dotnet docker image for linux/amd64 architecture on my Apple Silicon. It works for other architectures but it get stuck at "RUN dotnet restore" when building for linux/amd64.
Tried both following commands:
docker build --platform linux/amd64 -t my-hub/solid:auth-api .
docker buildx build --platform linux/amd64 -t my-hub/solid:auth-api .
My Dockerfile:
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
WORKDIR /app
COPY *.csproj ./
ENV DOTNET_NUGET_SIGNATURE_VERIFICATION=false
RUN dotnet restore --verbosity detailed
COPY . .
RUN dotnet publish -c Release -o out
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS runtime
WORKDIR /app
COPY --from=build /app/out ./
EXPOSE 5241
ENTRYPOINT ["dotnet", "AuthAPI.dll"]
Console Output:
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 396B 0.0s
=> [internal] load metadata for mcr.microsoft.com/dotnet/aspnet:8.0 0.1s
=> [internal] load metadata for mcr.microsoft.com/dotnet/sdk:8.0 0.1s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [build 1/6] FROM mcr.microsoft.com/dotnet/sdk:8.0@sha256:35792ea4ad1db051981f62b313f1be3b46b1f45cadbaa3c288cd0d3056eefb83 0.0s
=> [runtime 1/3] FROM mcr.microsoft.com/dotnet/aspnet:8.0@sha256:6c4df091e4e531bb93bdbfe7e7f0998e7ced344f54426b7e874116a3dc32 0.0s
=> [internal] load build context 0.0s
=> => transferring context: 45.74kB 0.0s
=> CACHED [runtime 2/3] WORKDIR /app 0.0s
=> CACHED [build 2/6] WORKDIR /app 0.0s
=> CACHED [build 3/6] COPY *.csproj ./ 0.0s
=> CANCELED [build 4/6] RUN dotnet restore --verbosity detailed 243.7s # this line takes forever