Open Closed

Use docker to deploy abp #1072


User avatar
0
sgal created
  • ABP Framework version: v4.2.2
  • UI type: Angular
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): yes
  • Exception message and stack trace:Identityserver and hostapi automatically exit after startup, and there is no log information
  • Steps to reproduce the issue:Use vscode to add dockerfile, and then add them to docker-compose
version: '3.4'

services:
  basketdata:
    image: redis
    # volumes:
    #   - /Users/Shared/redis-data:/var/lib/redis/data

  sqldata:
    image: postgres
    environment: 
      - POSTGRES_DB=CoFarm
      - POSTGRES_USER=aspnetcore
      - POSTGRES_PASSWORD=<pwd>
    # volumes:
    #   - /Users/Shared/pg-data:/var/lib/pgsql/data

  yikicofarmidentityserver:
    image: yikicofarmidentityserver
    environment: 
      - ConnectionString=User ID=aspnetcore;Password=<pwd>;Host=sqldata;Port=5432;Database=CoFarm;Pooling=true;Minimum Pool Size=0;Maximum Pool Size=100;Connection Lifetime=0;
    build:
      context: .
      dockerfile: aspnet-core/src/Yiki.CoFarm.IdentityServer/Dockerfile
    ports:
      - 80
    depends_on: 
      - basketdata
      - sqldata
    # volumes:
    #   - ~/Users/yikicoform:/ids:rw

  yikicofarmhttpapihost:
    image: yikicofarmhttpapihost
    environment: 
      - ConnectionString=User ID=aspnetcore;Password=<pwd>;Host=sqldata;Port=5432;Database=CoFarm;Pooling=true;Minimum Pool Size=0;Maximum Pool Size=100;Connection Lifetime=0;
    build:
      context: .
      dockerfile: aspnet-core/src/Yiki.CoFarm.HttpApi.Host/Dockerfile
    ports:
      - 81
    depends_on: 
      - basketdata
      - sqldata


9 Answer(s)
  • User Avatar
    0
    gterdem created
    Support Team Senior .NET Developer

    It is hard to say anything without checking logs.

    To check logs of a stopped container: hit docker ps -a and notice your exited container ID, something like:

    docker commit 0dfd54557799 auth/test (exited container id). Now you can see it when you run docker images list.

    create new container from faulty image docker run -it --rm --entrypoint sh auth/test

    Now navigate to check the logs under Logs/logs.txt.

  • User Avatar
    0
    sgal created

    Thanks, I will try.

  • User Avatar
    0
    sgal created

    This logs look like redis can't found

       at StackExchange.Redis.ConnectionMultiplexer.Connect(String configuration, TextWriter log) in C:\projects\stackexchange-redis\src\StackExchange.Redis\ConnectionMultiplexer.cs:line 903
       at Yiki.CoFarm.CoFarmIdentityServerModule.ConfigureServices(ServiceConfigurationContext context) in /src/aspnet-core/src/Yiki.CoFarm.IdentityServer/CoFarmIdentityServerModule.cs:line 113
       at Volo.Abp.AbpApplicationBase.ConfigureServices()
       --- End of inner exception stack trace ---
       at Volo.Abp.AbpApplicationBase.ConfigureServices()
       at Volo.Abp.AbpApplicationBase..ctor(Type startupModuleType, IServiceCollection services, Action`1 optionsAction)
       at Volo.Abp.AbpApplicationWithExternalServiceProvider..ctor(Type startupModuleType, IServiceCollection services, Action`1 optionsAction)
       at Volo.Abp.AbpApplicationFactory.Create(Type startupModuleType, IServiceCollection services, Action`1 optionsAction)
       at Volo.Abp.AbpApplicationFactory.Create[TStartupModule](IServiceCollection services, Action`1 optionsAction)
       at Microsoft.Extensions.DependencyInjection.ServiceCollectionApplicationExtensions.AddApplication[TStartupModule](IServiceCollection services, Action`1 optionsAction)
       at Yiki.CoFarm.Startup.ConfigureServices(IServiceCollection services) in /src/aspnet-core/src/Yiki.CoFarm.IdentityServer/Startup.cs:line 10
       at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
       at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
       at Microsoft.AspNetCore.Hosting.ConfigureServicesBuilder.InvokeCore(Object instance, IServiceCollection services)
       at Microsoft.AspNetCore.Hosting.ConfigureServicesBuilder.&lt;&gt;c__DisplayClass9_0.&lt;Invoke&gt;g__Startup|0(IServiceCollection serviceCollection)
       at Microsoft.AspNetCore.Hosting.ConfigureServicesBuilder.Invoke(Object instance, IServiceCollection services)
       at Microsoft.AspNetCore.Hosting.ConfigureServicesBuilder.&lt;&gt;c__DisplayClass8_0.&lt;Build&gt;b__0(IServiceCollection services)
       at Microsoft.AspNetCore.Hosting.GenericWebHostBuilder.UseStartup(Type startupType, HostBuilderContext context, IServiceCollection services, Object instance)
       at Microsoft.AspNetCore.Hosting.GenericWebHostBuilder.&lt;&gt;c__DisplayClass13_0.&lt;UseStartup&gt;b__0(HostBuilderContext context, IServiceCollection services)
       at Microsoft.Extensions.Hosting.HostBuilder.CreateServiceProvider()
       at Microsoft.Extensions.Hosting.HostBuilder.Build()
       at Yiki.CoFarm.Program.Main(String[] args) in /src/aspnet-core/src/Yiki.CoFarm.IdentityServer/Program.cs:line 31
    2021-03-22 06:34:47.175 +00:00 [INF] Starting Yiki.CoFarm.IdentityServer.
    2021-03-22 06:34:48.271 +00:00 [FTL] Yiki.CoFarm.IdentityServer terminated unexpectedly!
    Volo.Abp.AbpInitializationException: An error occurred during ConfigureServices phase of the module Yiki.CoFarm.CoFarmIdentityServerModule, Yiki.CoFarm.IdentityServer, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null. See the inner exception for details.
     ---> 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
       at StackExchange.Redis.ConnectionMultiplexer.ConnectImpl(Object configuration, TextWriter log) in C:\projects\stackexchange-redis\src\StackExchange.Redis\ConnectionMultiplexer.cs:line 941
       at StackExchange.Redis.ConnectionMultiplexer.Connect(String configuration, TextWriter log) in C:\projects\stackexchange-redis\src\StackExchange.Redis\ConnectionMultiplexer.cs:line 903
       at Yiki.CoFarm.CoFarmIdentityServerModule.ConfigureServices(ServiceConfigurationContext context) in /src/aspnet-core/src/Yiki.CoFarm.IdentityServer/CoFarmIdentityServerModule.cs:line 113
       at Volo.Abp.AbpApplicationBase.ConfigureServices()
       ......
    
  • User Avatar
    0
    gterdem created
    Support Team Senior .NET Developer

    Makes sense,

    services: basketdata: image: redis # volumes: # - /Users/Shared/redis-data:/var/lib/redis/data

    Should expose 6379

  • User Avatar
    0
    sgal created

    I already dependon, why can't it find it?

  • User Avatar
    0
    sgal created

    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!

  • User Avatar
    0
    sgal created

    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
     ......
    
  • User Avatar
    0
    alper created
    Support Team Director

    This doesn't seem to be related to the ABP Framework.

    See these:

    • https://github.com/npgsql/efcore.pg/issues/225#issuecomment-356307586
    • https://github.com/npgsql/efcore.pg/issues/225#issuecomment-532313931
  • User Avatar
    0
    sgal created

    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.

Made with ❤️ on ABP v8.2.0-preview Updated on March 25, 2024, 15:11