0

Docker can't find my static Swagger files. My code is working on localhost, but when I try to run on a staging server I get the following error in AWS CodePipeline:

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

My docker file:

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

1 Answers1

0

Solved by removing

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

and

COPY --from=build /app .

, and by adding

EXPOSE 5001