460407 (4) [Avatar] Offline
#1
Hi,

I am trying to run a docker container with the following dockerfile.

---------------------------------------------------------------------

FROM microsoft/aspnetcore-build:2.0 AS build-env
WORKDIR /app


#Copy sharedappsettings.json
COPY ./Shared/* /Shared/

# Copy fsproj and restore as distinct layers
COPY ./FloAuthentication/*.fsproj .
RUN dotnet restore

# Copy everything else and build
COPY ./FloAuthentication ./
RUN dotnet publish -c Release -o out

# Build runtime image
FROM microsoft/aspnetcore:2.0
WORKDIR /app
COPY --from=build-env /app/out .
RUN dotnet FloAuthentication.dll
ENTRYPOINT ["dotnet", "FloAuthentication.dll"]


----------------------------------------------------------------------

The docker run command that I am using is as follows.

----------------------------------------------------------------------

~/source/FloAppStpl$ sudo docker build -t floauthentication -f FloAuthentication/Dockerfile .

----------------------------------------------------------------------

The problem is that the aspnet code is not able to access the Shared Folder containing the shared settings file inside the container and throws the following error.

---------------------------------------------------------------------

Unhandled Exception: System.TypeInitializationException: The type initializer for '<StartupCode$FloAuthentication>.$AppSettingsHelper' threw an exception. ---> System.IO.FileNotFoundException: The configuration file 'Shared/sharedappsettings.json' was not found and is not optional. The physical path is '/Shared/sharedappsettings.json'.
at Microsoft.Extensions.Configuration.FileConfigurationProvider.Load(Boolean reload)
at Microsoft.Extensions.Configuration.FileConfigurationProvider.Load()
at Microsoft.Extensions.Configuration.ConfigurationRoot..ctor(IList`1 providers)
at Microsoft.Extensions.Configuration.ConfigurationBuilder.Build()
at <StartupCode$FloAuthentication>.$AppSettingsHelper..cctor() in /app/AppSettingsHelper.fs:line 15
--- End of inner exception stack trace ---
at FloAppAuth.Program.BuildWebHost(String[] args) in /app/Program.fs:line 26
at FloAppAuth.Program.main(String[] args) in /app/Program.fs:line 40
Aborted (core dumped)


----------------------------------------------------------------------

Thanks in advance
Rajat