I try this Hosting ASP.NET Core image in container using docker compose with HTTPS it worked
But there are other problems, identityserver cannot enable https
And I tried the production environment, the problem disappeared
do you have still this issue at the moment?
I think this may be a problem with the directory separator between different operating systems (/?\)
I found the problem. I configured real environment variables in docker-compose, ConnectionStrings, and missing s, which resulted in the appsetting configuration not being replaced.
I know, this is because the development environment has executed the following code
if (hostingEnvironment.IsDevelopment())
{
Configure<AbpVirtualFileSystemOptions>(options =>
{
options.FileSets.ReplaceEmbeddedByPhysical<CoFarmDomainSharedModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}Yiki.CoFarm.Domain.Shared", Path.DirectorySeparatorChar)));
options.FileSets.ReplaceEmbeddedByPhysical<CoFarmDomainModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}Yiki.CoFarm.Domain", Path.DirectorySeparatorChar)));
});
}
But there is no problem with the operation Yiki.CoFarm.IdentityServer and Yiki.CoFarm.Domain.Shared path of COPY in my dockerfile, And I tried the production environment, the problem disappeared
I don’t think it’s a problem, the packaged images are all passed. My Dockerfile
FROM mcr.microsoft.com/dotnet/aspnet:5.0 AS base
WORKDIR /app
EXPOSE 8080
FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build
WORKDIR /src
COPY ["aspnet-core/src/Yiki.CoFarm.IdentityServer/Yiki.CoFarm.IdentityServer.csproj", "aspnet-core/src/Yiki.CoFarm.IdentityServer/"]
COPY ["aspnet-core/src/Yiki.CoFarm.EntityFrameworkCore.DbMigrations/Yiki.CoFarm.EntityFrameworkCore.DbMigrations.csproj", "aspnet-core/src/Yiki.CoFarm.EntityFrameworkCore.DbMigrations/"]
COPY ["aspnet-core/src/Yiki.CoFarm.EntityFrameworkCore/Yiki.CoFarm.EntityFrameworkCore.csproj", "aspnet-core/src/Yiki.CoFarm.EntityFrameworkCore/"]
COPY ["aspnet-core/modules/Yiki.CoFarm.Core/src/Yiki.CoFarm.Core.EntityFrameworkCore/Yiki.CoFarm.Core.EntityFrameworkCore.csproj", "aspnet-core/modules/Yiki.CoFarm.Core/src/Yiki.CoFarm.Core.EntityFrameworkCore/"]
COPY ["aspnet-core/modules/Yiki.CoFarm.Core/src/Yiki.CoFarm.Core.Domain/Yiki.CoFarm.Core.Domain.csproj", "aspnet-core/modules/Yiki.CoFarm.Core/src/Yiki.CoFarm.Core.Domain/"]
COPY ["aspnet-core/modules/Yiki.CoFarm.Core/src/Yiki.CoFarm.Core.Domain.Shared/Yiki.CoFarm.Core.Domain.Shared.csproj", "aspnet-core/modules/Yiki.CoFarm.Core/src/Yiki.CoFarm.Core.Domain.Shared/"]
COPY ["aspnet-core/src/Yiki.CoFarm.Domain/Yiki.CoFarm.Domain.csproj", "aspnet-core/src/Yiki.CoFarm.Domain/"]
COPY ["aspnet-core/src/Yiki.CoFarm.Domain.Shared/Yiki.CoFarm.Domain.Shared.csproj", "aspnet-core/src/Yiki.CoFarm.Domain.Shared/"]
COPY ["aspnet-core/NuGet.Config", "aspnet-core/"]
RUN dotnet restore "aspnet-core/src/Yiki.CoFarm.IdentityServer/Yiki.CoFarm.IdentityServer.csproj"
COPY . .
WORKDIR "/src/aspnet-core/src/Yiki.CoFarm.IdentityServer"
RUN dotnet build "Yiki.CoFarm.IdentityServer.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "Yiki.CoFarm.IdentityServer.csproj" -c Release -o /app/publish
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Yiki.CoFarm.IdentityServer.dll"]
2021-03-23 06:38:22.426 +00:00 [INF] Starting Yiki.CoFarm.IdentityServer.
2021-03-23 06:38:24.278 +00:00 [WRN] Storing keys in a directory '/root/.aspnet/DataProtection-Keys' that may not be persisted outside of the container. Protected data will be unavailable when container is destroyed.
2021-03-23 06:38:24.280 +00:00 [INF] User profile is available. Using '/root/.aspnet/DataProtection-Keys' as key repository; keys will not be encrypted at rest.
2021-03-23 06:38:24.315 +00:00 [INF] Creating key {bdb6cead-ab9f-47e5-972e-3062c2af2453} with creation date 2021-03-23 06:38:24Z, activation date 2021-03-23 06:38:24Z, and expiration date 2021-06-21 06:38:24Z.
2021-03-23 06:38:24.321 +00:00 [WRN] No XML encryptor configured. Key {bdb6cead-ab9f-47e5-972e-3062c2af2453} may be persisted to storage in unencrypted form.
2021-03-23 06:38:24.324 +00:00 [INF] Writing data to file '/root/.aspnet/DataProtection-Keys/key-bdb6cead-ab9f-47e5-972e-3062c2af2453.xml'.
2021-03-23 06:38:24.368 +00:00 [INF] Loaded ABP modules:
2021-03-23 06:38:24.368 +00:00 [INF] - Volo.Abp.Castle.AbpCastleCoreModule
2021-03-23 06:38:24.368 +00:00 [INF] - Volo.Abp.Autofac.AbpAutofacModule
2021-03-23 06:38:24.368 +00:00 [INF] - Volo.Abp.Threading.AbpThreadingModule
......
2021-03-23 06:38:24.369 +00:00 [INF] - Yiki.CoFarm.CoFarmIdentityServerModule
2021-03-23 06:38:24.654 +00:00 [FTL] Application startup exception
Volo.Abp.AbpInitializationException: An error occurred during the initialize Volo.Abp.Modularity.OnApplicationInitializationModuleLifecycleContributor phase of the module Yiki.CoFarm.CoFarmIdentityServerModule, Yiki.CoFarm.IdentityServer, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null: An exception was thrown while activating λ:Volo.Abp.AspNetCore.VirtualFileSystem.IWebContentFileProvider -> Volo.Abp.AspNetCore.VirtualFileSystem.WebContentFileProvider -> λ:Volo.Abp.VirtualFileSystem.IVirtualFileProvider -> Volo.Abp.VirtualFileSystem.VirtualFileProvider.. See the inner exception for details.
---> Autofac.Core.DependencyResolutionException: An exception was thrown while activating λ:Volo.Abp.AspNetCore.VirtualFileSystem.IWebContentFileProvider -> Volo.Abp.AspNetCore.VirtualFileSystem.WebContentFileProvider -> λ:Volo.Abp.VirtualFileSystem.IVirtualFileProvider -> Volo.Abp.VirtualFileSystem.VirtualFileProvider.
---> Autofac.Core.DependencyResolutionException: An exception was thrown while invoking the constructor 'Void .ctor(Microsoft.Extensions.Options.IOptions`1[Volo.Abp.VirtualFileSystem.AbpVirtualFileSystemOptions], Volo.Abp.VirtualFileSystem.IDynamicFileProvider)' on type 'VirtualFileProvider'.
---> System.IO.DirectoryNotFoundException: /Yiki.CoFarm.Domain.Shared/
at Microsoft.Extensions.FileProviders.PhysicalFileProvider..ctor(String root, ExclusionFilters filters)
at Volo.Abp.VirtualFileSystem.VirtualFileSetListExtensions.ReplaceEmbeddedByPhysical[T](VirtualFileSetList fileSets, String physicalPath)
at Yiki.CoFarm.CoFarmIdentityServerModule.<>c__DisplayClass1_0.<ConfigureServices>b__3(AbpVirtualFileSystemOptions options) in /src/aspnet-core/src/Yiki.CoFarm.IdentityServer/CoFarmIdentityServerModule.cs:line 90
at Microsoft.Extensions.Options.ConfigureNamedOptions`1.Configure(String name, TOptions options)
at Microsoft.Extensions.Options.OptionsFactory`1.Create(String name)
at Microsoft.Extensions.Options.OptionsManager`1.<>c__DisplayClass5_0.<Get>b__0()
at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode)
at System.Lazy`1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor)
at System.Lazy`1.CreateValue()
at System.Lazy`1.get_Value()
at Microsoft.Extensions.Options.OptionsCache`1.GetOrAdd(String name, Func`1 createOptions)
at Microsoft.Extensions.Options.OptionsManager`1.Get(String name)
at Microsoft.Extensions.Options.OptionsManager`1.get_Value()
at Volo.Abp.VirtualFileSystem.VirtualFileProvider..ctor(IOptions`1 options, IDynamicFileProvider dynamicFileProvider)
at lambda_method962(Closure , Object[] )
at Autofac.Core.Activators.Reflection.BoundConstructor.Instantiate()
--- End of inner exception stack trace ---
at Autofac.Core.Activators.Reflection.BoundConstructor.Instantiate()
at Autofac.Core.Activators.Reflection.ReflectionActivator.ActivateInstance(IComponentContext context, IEnumerable`1 parameters)
at Autofac.Core.Activators.Reflection.ReflectionActivator.<ConfigurePipeline>b__11_0(ResolveRequestContext ctxt, Action`1 next)
at Autofac.Core.Resolving.Middleware.DelegateMiddleware.Execute(ResolveRequestContext context, Action`1 next)
at Autofac.Core.Resolving.Pipeline.ResolvePipelineBuilder.<>c__DisplayClass14_0.<BuildPipeline>b__1(ResolveRequestContext ctxt)
at Autofac.Core.Resolving.Middleware.DisposalTrackingMiddleware.Execute(ResolveRequestContext context, Action`1 next)
at Autofac.Core.Resolving.Pipeline.ResolvePipelineBuilder.<>c__DisplayClass14_0.<BuildPipeline>b__1(ResolveRequestContext ctxt)
at Autofac.Builder.RegistrationBuilder`3.<>c__DisplayClass41_0.<PropertiesAutowired>b__0(ResolveRequestContext ctxt, Action`1 next)
at Autofac.Core.Resolving.Middleware.DelegateMiddleware.Execute(ResolveRequestContext context, Action`1 next)
at Autofac.Core.Resolving.Pipeline.ResolvePipelineBuilder.<>c__DisplayClass14_0.<BuildPipeline>b__1(ResolveRequestContext ctxt)
at Autofac.Core.Resolving.Middleware.ActivatorErrorHandlingMiddleware.Execute(ResolveRequestContext context, Action`1 next)
--- End of inner exception stack trace ---
......
but annother error
2021-03-22 12:58:49.214 +00:00 [ERR] An error occurred using the connection to database 'CoFarm' on server 'tcp://localhost:5432'.
2021-03-22 12:58:49.227 +00:00 [ERR] An exception occurred while iterating over the results of a query for context type 'Volo.Abp.BackgroundJobs.EntityFrameworkCore.BackgroundJobsDbContext'.
System.InvalidOperationException: An exception has been raised that is likely due to a transient failure.
---> Npgsql.NpgsqlException (0x80004005): Exception while connecting
---> System.Net.Sockets.SocketException (99): Cannot assign requested address
......
add this
ports:
- 6379
occur error
StackExchange.Redis.RedisConnectionException: It was not possible to connect to the redis server(s). UnableToConnect on 127.0.0.1:6379/Interactive, Initializing/NotStarted, last: NONE, origin: BeginConnectAsync, outstanding: 0, last-read: 0s ago, last-write: 0s ago, keep-alive: 60s, state: Connecting, mgr: 10 of 10 available, last-heartbeat: never, global: 0s ago, v: 2.0.593.37019
It seems use appsetting.json config
I use environment-> Redis:Configuration=basketdata
it worked!
I already dependon, why can't it find it?