Я использую образ docker для развертывания моего приложения asp.net
и столкнулся с двумя проблемами.
Первая: после некоторых развертываний список API остается прежним, хотя в него внесены изменения (похоже, что проблема с кэшированием изображений «не уверен»)
Вторая: в моем коде есть функция загрузки для загрузки в определенный каталог и при попытке загрузки API конкретной формы файла я получаю это:
fail: Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware[1]
at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddlewareImpl.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.d.MoveNext()
at Microsoft.AspNetCore.Http.RequestDelegateFactory.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.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.
# 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"]
Могу ли я что-нибудь сделать, чтобы решить эти проблемы?
Я использую образ docker для развертывания моего приложения asp.net и столкнулся с двумя проблемами. [list] [*]Первая: после некоторых развертываний список API остается прежним, хотя в него внесены изменения (похоже, что проблема с кэшированием изображений «не уверен»)
[*]Вторая: в моем коде есть функция загрузки для загрузки в определенный каталог и при попытке загрузки API конкретной формы файла я получаю это:
[/list] [code]fail: Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware[1] at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddlewareImpl.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.d.MoveNext() at Microsoft.AspNetCore.Http.RequestDelegateFactory.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.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. [/code] мой файл докера: [code]# 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", "./"]
# 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"] [/code] Могу ли я что-нибудь сделать, чтобы решить эти проблемы?