Alex
Alex

Reputation: 71

.Net Core UBI image doesn't allow running `dotnet restore`

I have a little Web API POC which runs fine when using mcr.microsoft.com/dotnet/aspnet:8.0 as base but when I switch it to registry.access.redhat.com/ubi8/dotnet-80 I start getting permission errors.

Specifically on dotnet restore I get

11.56 /usr/lib64/dotnet/sdk/8.0.103/NuGet.targets(156,5): error : Access to the path '/src/WebApiPoc/obj' is denied. [/src/WebApiPoc/webapipoc.csproj]
11.56 /usr/lib64/dotnet/sdk/8.0.103/NuGet.targets(156,5): error :   Permission denied [/src/WebApiPoc/webapipoc.csproj]

I tried changing the user, running chown or chmod on the directory but nothing helps. I would appreciate any ideas what to do.

My dockerfile

    FROM registry.access.redhat.com/ubi8/dotnet-80:8.0-5 AS base
WORKDIR /app
EXPOSE 5164

ENV ASPNETCORE_URLS=http://+:5164


FROM --platform=$BUILDPLATFORM registry.access.redhat.com/ubi8/dotnet-80:8.0-5 AS build
ARG configuration=Release

WORKDIR /src
RUN chown -R 1001 /src
RUN chmod -R 755 /src

USER 1001

COPY ["WebApiPoc/webapipoc.csproj", "WebApiPoc/"]
RUN dotnet restore "WebApiPoc/webapipoc.csproj"
COPY . .
WORKDIR "/src/WebApiPoc"
RUN dotnet build "webapipoc.csproj" -c $configuration -o /app/build

FROM build AS publish
ARG configuration=Release
RUN dotnet publish "webapipoc.csproj" -c $configuration -o /app/publish /p:UseAppHost=false

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "webapipoc.dll"]

Upvotes: 1

Views: 99

Answers (0)

Related Questions