0

I'm using docker image to deploy my asp.net application and i'm facing 2 issues.

  1. The first one: after some deployes the api list still the same although a made changes on it (it seems like image caching problem "not sure")

  2. The second one: my code has an upload function to upload to specific dir, and when try to upload the file form specific api i get this:

fail: Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware[1]
        at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddlewareImpl.<Invoke>g__Awaited|10_0(ExceptionHandlerMiddlewareImpl middleware, HttpContext context, Task task)
     --- End of stack trace from previous location ---
        at Microsoft.AspNetCore.Http.RequestDelegateFactory.<>c__DisplayClass103_2.<<HandleRequestBodyAndCompileRequestDelegateForForm>b__2>d.MoveNext()
        at Microsoft.AspNetCore.Http.RequestDelegateFactory.<ExecuteValueTaskOfObject>g__ExecuteAwaited|128_0(ValueTask`1 valueTask, HttpContext httpContext, JsonTypeInfo`1 jsonTypeInfo)
        at Endpoints.ValidatorFilter`1.InvokeAsync(EndpointFilterInvocationContext context, EndpointFilterDelegate next) in /src/src/Endpoints/ValidatorFilter.cs:line 24
        at Microsoft.AspNetCore.Http.RequestDelegateFactory.<TaskOfTToValueTaskOfObject>g__ExecuteAwaited|91_0[T](Task`1 task)
        at Application.RequestDispatcher.SendAsync[TRequest,TResponse](TRequest request, CancellationToken cancellationToken) in /src/src/Application/CQRS/Dispatchers/RequestDispatcher.cs:line 10
        at Application.UpdateDataCommandHandler.HandleAsync(UpdateDataCommand request, CancellationToken cancellationToken) in /src/src/Application/Features/ExcelData/Commands/UpdateDataCommand.cs:line 40
        at Application.Services.FileStorageService.CreateAttachmentAsync(IFormFile file, CancellationToken cancellationToken) in /src/src/Application/Services/FileStorageService.cs:line 39
        at Application.Services.FileStorageService.SaveFileAsync(IFormFile file, CancellationToken cancellationToken) in /src/src/Application/Services/FileStorageService.cs:line 16
        at System.IO.Directory.CreateDirectory(String path)
        at System.IO.FileSystem.CreateDirectory(String fullPath, UnixFileMode unixCreateMode)
        --- End of inner exception stack trace ---
      ---> System.IO.IOException: Permission denied
     System.UnauthorizedAccessException: Access to the path '/app/wwwroot/Uploads' is denied.
     An unhandled exception has occurred while executing the request.

my docker file:

# See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging.

# This stage is used when running from VS in fast mode (Default for Debug configuration)
FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS base

# Puppeteer recipe
# Based on this code: https://github.com/armbues/chrome-headless/blob/master/Dockerfile
RUN apt-get update && apt-get -f install && apt-get -y install wget gnupg2 apt-utils
RUN wget -q -O - https://dl.google.com/linux/linux_signing_key.pub | apt-key add -
RUN echo 'deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main' >> /etc/apt/sources.list
RUN apt-get update \
&& apt-get install -y google-chrome-stable --no-install-recommends --allow-downgrades fonts-ipafont-gothic fonts-wqy-zenhei fonts-thai-tlwg fonts-kacst fonts-freefont-ttf

# Install fonts for comprehensive emoji and system font support
RUN apt-get update \
    && apt-get install -y \
        google-chrome-stable \
        fonts-ipafont-gothic \
        fonts-wqy-zenhei \
        fonts-thai-tlwg \
        fonts-kacst \
        fonts-freefont-ttf \
        fonts-liberation \
        fonts-noto-color-emoji \
        fonts-noto-cjk \
        fonts-noto \
        fonts-dejavu \
        fonts-roboto \
        fonts-opensymbol \
        fonts-unifont \
        fonts-sil-gentium \
        fonts-sil-gentium-basic \
        fontconfig \
        --no-install-recommends \
        --allow-downgrades

## We are setting the same path as before in the C# code
#ENV PUPPETEER_EXECUTABLE_PATH="/usr/bin/google-chrome-stable"

USER $APP_UID
WORKDIR /app
EXPOSE 8080
EXPOSE 8081
 
# Set environment variables
ENV ASPNETCORE_ENVIRONMENT=RCP_Development

# This stage is used to build the service project
FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
COPY ["Directory.Packages.props", "./"]
 
COPY ["src/RCP.Portal/RCP.Portal.csproj", "src/RCP.Portal/"]
COPY ["src/Infrastructure/Infrastructure.csproj", "src/Infrastructure/"]
COPY ["src/Application/Application.csproj", "src/Application/"]
COPY ["src/Domain/Domain.csproj", "src/Domain/"]
COPY ["src/Endpoints/Endpoints.csproj", "src/Endpoints/"]
RUN dotnet restore "./src/RCP.Portal/RCP.Portal.csproj"
COPY . .
WORKDIR "/src/src/RCP.Portal"
RUN dotnet build "./RCP.Portal.csproj" -c $BUILD_CONFIGURATION -o /app/build

# This stage is used to publish the service project to be copied to the final stage
FROM build AS publish
ARG BUILD_CONFIGURATION=Release
RUN dotnet publish "./RCP.Portal.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false

# This stage is used in production or when running from VS in regular mode (Default when not using the Debug configuration)
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "RCP.Portal.dll"]

Is there anything i can do to solve these issues?

2
  • 1
    Can you store the uploads somewhere other than the container-local filesystem, maybe an object-store like MinIO (or an equivalent cloud-hosted solution)? That avoids a number of practical issues around permissions and persistence. If not, how are you running the container; where does the /app/wwwroot/Uploads directory come from, and what ownership and permissions does it have? Commented Nov 16 at 12:30
  • @DavidMaze Thank you for the second point it solved (the server admin said he will provied me a object-store) but what about the first point, is there a soultion? Commented Nov 18 at 6:45

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.