Docker Azure Kubernets npm not found错误

vsikbqxv  于 2023-10-22  发布在  Docker
关注(0)|答案(1)|浏览(115)

关于Docker Azure部署的问题我有一个.NET8应用程序,我从3.1升级。现在我尝试将.NET8应用程序部署到Azure Kubernets Service。下面的代码适用于3.1部署,但现在失败了,它说npm找不到。我有一个前端应用程序,它是实现到API。下面的代码是我的docker文件

#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.

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

FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
WORKDIR /src
COPY ["src/Presentation/Abbyy.VerifyOCR.WebApi/Abbyy.VerifyOCR.WebApi.csproj", "src/Presentation/Abbyy.VerifyOCR.WebApi/"]
RUN dotnet restore "src/Presentation/Abbyy.VerifyOCR.WebApi/Abbyy.VerifyOCR.WebApi.csproj"
COPY . .

WORKDIR "/src/src/Presentation/Abbyy.VerifyOCR.WebApi"

# update 
run apt-get update
# install curl 
run apt-get -y install curl
# get install script and pass it to execute: 
run curl -sL https://deb.nodesource.com/setup_14.x | bash
# and install node 
run apt-get -y install nodejs
# confirm that it was successful 
run node -v
# npm installs automatically 
run npm -v

RUN dotnet build "Abbyy.VerifyOCR.WebApi.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "Abbyy.VerifyOCR.WebApi.csproj" -c Release -o /app/publish

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

这里唯一的变化是sdk:3.1-buster到sdk:8.0和aspnet:3.1-buster-slim到aspnet:8.0在docker文件中。它的工作速度是3.1。现在我不知道为什么它不再工作了。这是在github action的日志下面

19 [build 11/13] RUN node -v #19 0.945 v18.13.0 #19 DONE 1.2s

20 [build 12/13] RUN npm -v #20 0.555 /bin/sh:1:npm:not found #20错误:进程“/bin/sh -c npm -v”未成功完成:退出代码:127

[build 12/13] RUN npm -v:0.555 /bin/sh:1:npm:未找到
我该如何解决这个问题?Thanks in advance

egmofgnx

egmofgnx1#

我知道这不是预期的,因为通常npm与node一起安装,但也许尝试手动安装它?:

RUN apt-get install -y npm

相关问题