I am trying to get include a swagger.json file into my docker image. I am using aspnet core 2.2 When I run my app locally it picks up the swagger.json file sitting in wwwroot. when I create my docker image and run it, swagger starts but won't find the .json so it just errors out. I am very new to docker. I should note it also didn't find a test.gif file I dropped into wwwroot either. Am I missing something in the docker file? I definitely want to include the .json file in my image.
dockerfile:
FROM microsoft/dotnet:2.2-aspnetcore-runtime AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443
FROM microsoft/dotnet:2.2-sdk AS build
WORKDIR /src
COPY ["myApp.Api/myApp.Api.csproj", "myApp.Api/"]
COPY ["myApp.logic/myApp.logic.csproj", "myApp.logic/"]
COPY ["myApp.Models/myApp.Models.csproj", "myApp.Models/"]
RUN dotnet restore "myApp.Api/myApp.Api.csproj"
COPY . .
WORKDIR "/src/myApp.Api"
RUN dotnet build "myApp.Api.csproj" -c Release -o /app
FROM build AS publish
RUN dotnet publish "myApp.Api.csproj" -c Release -o /app
FROM base AS final
WORKDIR /app
COPY --from=publish /app .
ENTRYPOINT ["dotnet", "myApp.Api.dll"]
csproj file:
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<UserSecretsId></UserSecretsId>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DocumentationFile></DocumentationFile>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.2.0" PrivateAssets="All" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.0.2105168" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="4.0.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\myApp.logic\myApp.logic.csproj" />
</ItemGroup>
<ItemGroup>
<Content Update="wwwroot\swagger.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
</Project>
docker command
docker run -it -p 5001:80 myapp:latest