colinin / abp-next-admin

这是基于vue-vben-admin 模板适用于abp Vnext的前端管理项目
MIT License
806 stars 247 forks source link

Docker-Compose & PS build errors - can't bring up the solution #582

Open HazMat1337 opened 2 years ago

HazMat1337 commented 2 years ago

Hello,

I have not been able to start your solution yet. The PS build scripts do not work on my machine. I had to adjust those so it compiles at least. When bringing up Docker as per your tutorial the services keep restarting. I started adding the ABP framework requirements to docker but has not worked out so far. Could you provide an updated docker-compose with maybe also SQL server set-up already? Would be good to have a "one-line" startup solution. Thank you! Here are my adapted files so far.

JFYI: I also tried the "dotnet new --install LINGYUN.Abp.MicroService.Templates::5.2.0" approach as in your Readme but 5.2.0 is not available yet.

docker-compose.yml:

version: '3.4'

services:
  admin-api:
    environment:
      - ASPNETCORE_ENVIRONMENT=Production
      - ASPNETCORE_URLS=http://0.0.0.0:80
    ports:
      - "30010:80"

  sts-api:
    environment:
      - ASPNETCORE_ENVIRONMENT=Production
      - ASPNETCORE_URLS=http://0.0.0.0:80
    ports:
      - "30015:80"

  localization-api:
    environment:
      - ASPNETCORE_ENVIRONMENT=Production
      - ASPNETCORE_URLS=http://0.0.0.0:80
    ports:
      - "30030:80"

  platform-api:
    environment:
      - ASPNETCORE_ENVIRONMENT=Production
      - ASPNETCORE_URLS=http://0.0.0.0:80
    ports:
      - "30025:80"

  messages-api:
    environment:
      - ASPNETCORE_ENVIRONMENT=Production
      - ASPNETCORE_URLS=http://0.0.0.0:80
    ports:
      - "30020:80"

  task-api:
    environment:
      - ASPNETCORE_ENVIRONMENT=Production
      - ASPNETCORE_URLS=http://0.0.0.0:80
    ports:
      - "30040:80"

  webhook-api:
    environment:
      - ASPNETCORE_ENVIRONMENT=Production
      - ASPNETCORE_URLS=http://0.0.0.0:80
    ports:
      - "30045:80"

  workflow-api:
    environment:
      - ASPNETCORE_ENVIRONMENT=Production
      - ASPNETCORE_URLS=http://0.0.0.0:80
    ports:
      - "30050:80"

  sts-server:
    environment:
      - ASPNETCORE_ENVIRONMENT=Production
      - ASPNETCORE_URLS=http://0.0.0.0:80
    ports:
      - "44385:80"

  internal-apigateway:
    environment:
      - ASPNETCORE_ENVIRONMENT=Production
      - ASPNETCORE_URLS=http://0.0.0.0:80
    ports:
      - "30000:80"

  sqlserver:
    environment:
      - SA_PASSWORD=yourStrong(!)Password
      - ACCEPT_EULA=Y
    ports:
      - "1433:1433"

  mongodb:
    ports:
      - "27017:27017"

  rabbitmq:
    ports:
      - "15672:15672"
      - "5672:5672"

  redis:
    ports:
      - "6379:6379"

  elasticsearch:
    volumes:
      - ./elk/elasticsearch/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml:ro
    environment:
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
    ports:
      - "9200:9200"

  logstash:
    volumes:
      - ./elk/logstash/config/logstash.yml:/usr/share/logstash/config/logstash.yml:ro
      - ./elk/logstash/pipeline:/usr/share/logstash/pipeline:ro
    environment:
      - "LS_JAVA_OPTS=-Xmx256m -Xms256m"
    ports:
      - "9600"
      - "5000"

  kibana:
    volumes:
      - ./elk/kibana/config/:/usr/share/kibana/config:ro
    ports:
      - 51510:5601

docker-compose.override.yml:

version: '3.4'

services:
  sts-server:
    build:
      context: ./build/aspnet-core/services/Publish/identityserver
    volumes:
      - /var/opt/abp/logs/ids-sts:/app/Logs
      - /var/opt/abp/data/ids-sts/Modules:/app/Modules
    restart: always
    networks:
      - framework

  sts-api:
    build:
      context: ./build/aspnet-core/services/Publish/identityserver4-admin
    volumes:
      - /var/opt/abp/logs/ids-admin:/app/Logs
      - /var/opt/abp/data/ids-admin/Modules:/app/Modules
    depends_on:
      - sts-server
    restart: always
    networks:
      - framework

  admin-api:
    build:
      context: ./build/aspnet-core/services/Publish/admin
    volumes:
      - /var/opt/abp/logs/backend-admin:/app/Logs
      - /var/opt/abp/data/backend-admin/Modules:/app/Modules
    depends_on:
      - sts-server
    restart: always
    networks:
      - framework

  localization-api:
    build:
      context: ./build/aspnet-core/services/Publish/localization
    volumes:
      - /var/opt/abp/logs/localization:/app/Logs
      - /var/opt/abp/data/localization/Modules:/app/Modules
    restart: always
    depends_on:
      - sts-server
    networks:
      - framework

  platform-api:
    build:
      context: ./build/aspnet-core/services/Publish/platform
    volumes:
      - /var/opt/abp/logs/platform:/app/Logs
      - /var/opt/abp/data/platform/Modules:/app/Modules
      - /var/opt/abp/data/platform:/app/file-blob-storing
    depends_on:
      - sts-server
    restart: always
    networks:
      - framework

  messages-api:
    build:
      context: ./build/aspnet-core/services/Publish/messages
    volumes:
      - /var/opt/abp/logs/messages:/app/Logs
      - /var/opt/abp/data/messages/Modules:/app/Modules
    depends_on:
      - sts-server
    restart: always
    networks:
      - framework

  task-api:
    build:
      context: ./build/aspnet-core/services/Publish/task-management
    volumes:
      - /var/opt/abp/logs/task-management:/app/Logs
      - /var/opt/abp/data/task-management/Modules:/app/Modules
    depends_on:
      - sts-server
    restart: always
    networks:
      - framework

  webhook-api:
    build:
      context: ./build/aspnet-core/services/Publish/webhooks
    volumes:
      - /var/opt/abp/logs/webhooks:/app/Logs
      - /var/opt/abp/data/webhooks/Modules:/app/Modules
    depends_on:
      - sts-server
    restart: always
    networks:
      - framework

  workflow-api:
    build:
      context: ./build/aspnet-core/services/Publish/workflows
    volumes:
      - /var/opt/abp/logs/webhooks:/app/Logs
      - /var/opt/abp/data/webhooks/Modules:/app/Modules
    depends_on:
      - sts-server
    restart: always
    networks:
      - framework

  internal-apigateway:
    build:
      context: ./build/aspnet-core/services/Publish/internal-apigateway
    volumes:
      - /var/opt/abp/logs/internal-apigateway:/app/Logs
      - /var/opt/abp/data/internal-apigateway/Modules:/app/Modules
    restart: always
    networks:
      - framework

  sqlserver:
    image: mcr.microsoft.com/mssql/server
    volumes:
      - dbdata:/var/opt/mssql
    networks:
      - framework

  mongodb:
    image: mongo
    networks:
      - framework

  rabbitmq:
    image: 'rabbitmq:3-management-alpine'
    networks:
      - framework

  redis:
    image: redis:alpine
    networks:
      - framework

  elasticsearch:
    image: 'docker.elastic.co/elasticsearch/elasticsearch:7.8.0'
    volumes:
      - esdata:/usr/share/elasticsearch/data
    networks:
      - framework

  logstash:
    image: 'docker.elastic.co/logstash/logstash:7.8.0'
    depends_on:
      - elasticsearch
    networks:
      - framework

  kibana:
    image: 'docker.elastic.co/kibana/kibana:7.8.0'
    depends_on:
      - elasticsearch
    networks:
      - framework

volumes:
  dbdata:
  esdata:

networks:
  framework:
      name: ly_app_net

build-aspnetcore-release.ps1:

. "./build-aspnetcore-common.ps1"

# Build all solutions
foreach ($service in $serviceArray) {
    Set-Location $service.Path
    $publishPath = $rootFolder + "/aspnet-core/services/Publish/" + $service.Service
    dotnet restore
    dotnet publish -c Release -o $publishPath --no-cache --no-restore
    Copy-Item (Join-Path $service.Path "Dockerfile") -Destination $publishPath -Recurse
}

Set-Location $rootFolder

build-aspnetcore-common.ps1:

# COMMON PATHS 

$rootFolder = (Get-Item -Path "./" -Verbose).FullName

# List of solutions used only in development mode
[PsObject[]]$serviceArray = @()

$serviceArray += [PsObject]@{ Path = $rootFolder + "/../aspnet-core/services/LY.MicroService.BackendAdmin.HttpApi.Host/"; Service = "admin" }
$serviceArray += [PsObject]@{ Path = $rootFolder + "/../aspnet-core/services/LY.MicroService.IdentityServer/"; Service = "identityserver" }
$serviceArray += [PsObject]@{ Path = $rootFolder + "/../aspnet-core/services/LY.MicroService.IdentityServer.HttpApi.Host/"; Service = "identityserver4-admin" }
$serviceArray += [PsObject]@{ Path = $rootFolder + "/../aspnet-core/services/LY.MicroService.LocalizationManagement.HttpApi.Host/"; Service = "localization" }
$serviceArray += [PsObject]@{ Path = $rootFolder + "/../aspnet-core/services/LY.MicroService.PlatformManagement.HttpApi.Host/"; Service = "platform" }
$serviceArray += [PsObject]@{ Path = $rootFolder + "/../aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/"; Service = "messages" }
$serviceArray += [PsObject]@{ Path = $rootFolder + "/../aspnet-core/services/LY.MicroService.TaskManagement.HttpApi.Host/"; Service = "task-management" }
$serviceArray += [PsObject]@{ Path = $rootFolder + "/../aspnet-core/services/LY.MicroService.WebhooksManagement.HttpApi.Host/"; Service = "webhooks" }
$serviceArray += [PsObject]@{ Path = $rootFolder + "/../aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/"; Service = "workflows" }
$serviceArray += [PsObject]@{ Path = $rootFolder + "/../gateways/internal/LINGYUN.MicroService.Internal.ApiGateway/src/LINGYUN.MicroService.Internal.ApiGateway/"; Service = "internal-apigateway" }

Write-host ""
Write-host ":::::::::::::: !!! You are in development mode !!! ::::::::::::::" -ForegroundColor red -BackgroundColor  yellow
Write-host "" 
colinin commented 2 years ago

Your docker-compose context is defined in the ./build/aspnet-core/services/Publish/ subdirectory, and the build script build-aspnetcore-release.ps1 output is in the /aspnet-core/services/Publish/ subdirectory

HazMat1337 commented 2 years ago

Sorry but I don't understand what you are referring to.

The build script build-aspnetcore-release.ps1 is run from the ./build directory and outputs therefore to ./build/aspnet-core/services/Publish/. This is exactly the path the docker-compose references to. I also have not changed the files in terms of the paths. They are the original ones provided by you.

When I run docker by docker-compose -f docker-compose.yml -f docker-compose.override.yml up --build -d the microservices restart constantly with the following issues:

image

So I'm assuming this has to do with Redis. It's not present in your docker-compose, so not sure if it every worked for you. I have it within my docker-compose version shown above and it's up and running but I assume the microservices are not pointed into the right location (ip:port).

colinin commented 2 years ago

As you can see from the error stack, the application did not find the redis configuration in appsettings.json or appsettings.{env}.json when it started, please check

colinin commented 2 years ago

build-aspnetcore-release.ps1 uses a relative path to build, so the output directory is not under the build directory

HazMat1337 commented 2 years ago

Thank you, I'm just not able to get it to run. Can you provide a docker-compose which covers all the requirements to run it? Like RabbitMQ, the database, Redis, etc. I have not changed a single configuration and thought getting up and running would be much easier but so many tools are required which aren't mentioned in your Readme.

colinin commented 2 years ago

Maybe you need to add the -f docker-compose.configuration, yml

HazMat1337 commented 2 years ago

No doesn't work. I also had to change the whole references in docker-compose.configuration.yml because the names don't match any longer (i.e., admin-service must be admin-api, etc.). I was hoping you would provide a Docker compatibility but this just doesn't work and is buggy as hell. Not going to play with it any further and trashing plans to use this project.

colinin commented 2 years ago

I would consider incorporating middleware into docker-compose as well

colinin commented 2 months ago

943 once deploy script has been added to this commit,

Warning: Middleware, because join so many of the footprint is very high, you can cancel ELK, rabbitmq, mysql and so on, and modify the docker-compose.override.configuration.yml configured to use the existing environment

dongfo commented 1 month ago

with the GA of aspire,we can use aspire to develop,and generate docker compose yaml or k8s yaml