Dockerfile: COPY static Swagger no such file or directory 错误

Dockerfile: COPY static Swagger no such file or directory error

Docker 找不到我的静态 Swagger 文件。我的代码在本地主机上运行,​​但是当我尝试在临时服务器上 运行 时,我在 AWS CodePipeline 中收到以下错误:

COPY failed: stat /var/lib/docker/overlay2/ebbaca51ed1994dce1148a3fdcdbb80dafa1f3266bad100393bbd2d27413b607/merged/app/TimeProject.Beta.Nswag/specification: no such file or directory` 

我的 docker 文件:

FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build
ARG asmver=1.0.0.0

WORKDIR /source
COPY . .
RUN dotnet restore --configfile Application.Startup/NuGet.Config Application.Startup/Application.Startup.csproj
RUN dotnet publish -c Release -o /app Application.Startup/Application.Startup.csproj /p:AssemblyVersion=$asmver
COPY Application.Startup/cert.pfx /app/cert.pfx

FROM mcr.microsoft.com/dotnet/core/aspnet:3.1 AS runtime
WORKDIR /app

# https://github.com/dotnet/runtime/issues/30667 -> To be fixed in .Net 5.0
RUN sed -i "s|DEFAULT@SECLEVEL=2|DEFAULT@SECLEVEL=1|g" /etc/ssl/openssl.cnf
RUN mkdir ../TimeProject.Beta.Nswag
RUN mkdir ../TimeProject.Beta.Nswag/specification
COPY --from=build /app .
COPY --from=build /app ./
RUN pwd
RUN dir

COPY --from=build /app/TimeProject.Beta.Nswag/specification/ ../TimeProject.Beta.Nswag/specification

ENTRYPOINT ["dotnet", "Application.Startup.dll"]

CodeBuild-Docker.yaml:

version: 0.2
phases:
  install:
    runtime-versions:
      docker: latest
      dotnet: 3.1
  pre_build:
    commands:
      - $(aws ecr get-login --no-include-email --region $AWS_DEFAULT_REGION)
  build:
    commands:
      - echo $RELEASE_VERSION
      - cd src/app
      - docker build . -f Application.Startup/Dockerfile -t $IMAGE_REPO_NAME:$RELEASE_VERSION --build-arg asmver=$RELEASE_VERSION
      - docker tag $IMAGE_REPO_NAME:$RELEASE_VERSION $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/$IMAGE_REPO_NAME:$RELEASE_VERSION
  post_build:
    commands:
      - docker push $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/$IMAGE_REPO_NAME:$RELEASE_VERSION

通过删除解决

COPY Application.Startup/cert.pfx /app/cert.pfx

COPY --from=build /app .

,并通过添加

EXPOSE 5001