Open Closed

Local Docker Deployment #4729


User avatar
0
Spospisil created
  • ABP Framework version: v7.0.2
  • UI type: MVC
  • DB provider: EF Core/PostgreSQL
  • Tiered (MVC) or Identity Server Separated (Angular): Tiered/MVC
  • Exception message and stack trace:
  • Steps to reproduce the issue:"

Hi,

I would like support to provide to me or tell me how to deploy a tiered/MVC/PostegreSQL generated from ABP suite to my local docker environment. Since the generated docker-compose.yml file seems incomplete at best, I am at a loss as to how I can make an generated ABP solution work within a local docker environment. I'm going on 2 weeks now with no success.

Thanks.


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

    We're preparing to guide explaining how to run ABP application using docker-compose on localhost environment. Postgres is not supported currently.

    You need to update the docker-compose.yml file and update the sql-server service with a postgres image and update the connectionstrings based on that.

    Afterwards, please share the problems you come across.

  • User Avatar
    0
    Spospisil created

    We're preparing to guide explaining how to run ABP application using docker-compose on localhost environment. Postgres is not supported currently.

    You need to update the docker-compose.yml file and update the sql-server service with a postgres image and update the connectionstrings based on that.

    Afterwards, please share the problems you come across.

    That is fine but I don't use Postgres inside a container docker. I have a local running postgres db installation and in fact I've had this working for a while.

    My main issue is getting the 3 tiers (web, api and auth server) talking to each other within the separate containers. When can I expect this 'guide'? Currently, the generated docker-compose.yml file for a tiered solution only has the 'web' service defined in it, but I'm more concerned about all the url settings needed to run ABP, such as the ones for oidc, etc

  • User Avatar
    0
    gterdem created
    Support Team Senior .NET Developer

    Currently, the generated docker-compose.yml file for a tiered solution only has the 'web' service defined in it, but I'm more concerned about all the url settings needed to run ABP, such as the ones for oidc, etc

    On which version did you come across this behavior? This problem should have been fixed on version 7.1.0-rc.

    Here is the docker-compose.yml file I've just generated for a tiered mvc project named Acme.BookStore on latest rc version 7.1.0-rc.3:

    version: '3.7'
    
    services:
      bookstore-web:
        image: acme/bookstore-web:latest
        container_name: bookstore-web
        hostname: bookstore-web
        build:
          context: ../../
          dockerfile: src/Acme.BookStore.Web/Dockerfile.local
        environment:
          - ASPNETCORE_URLS=https://+:443;http://+:80;
          - Kestrel__Certificates__Default__Path=/root/certificate/localhost.pfx
          - Kestrel__Certificates__Default__Password=91f91912-5ab0-49df-8166-23377efaf3cc
          - App__SelfUrl=https://localhost:44353
          - AuthServer__RequireHttpsMetadata=false
          - AuthServer__IsContainerizedOnLocalhost=true
          - AuthServer__Authority=https://localhost:44334/
          - RemoteServices__Default__BaseUrl=http://bookstore-api
          - RemoteServices__AbpAccountPublic__BaseUrl=http://bookstore-authserver
          - AuthServer__MetaAddress=http://bookstore-authserver
          - Redis__Configuration=redis
        ports:
          - "44353:443"
        depends_on:
          - bookstore-api
        restart: on-failure
        volumes:
          - ./certs:/root/certificate
        networks:
          - abp-network
    
      bookstore-api:
        image: acme/bookstore-api:latest
        container_name: bookstore-api
        hostname: bookstore-api
        build:
          context: ../../
          dockerfile: src/Acme.BookStore.HttpApi.Host/Dockerfile.local
        environment:
          - ASPNETCORE_URLS=https://+:443;http://+:80;
          - Kestrel__Certificates__Default__Path=/root/certificate/localhost.pfx
          - Kestrel__Certificates__Default__Password=91f91912-5ab0-49df-8166-23377efaf3cc
          - App__SelfUrl=https://localhost:44354
          - App__HealthCheckUrl=http://bookstore-api/health-status
          - AuthServer__RequireHttpsMetadata=false
          - AuthServer__Authority=http://bookstore-authserver
          - ConnectionStrings__Default=Data Source=sql-server;Initial Catalog=BookStore;User Id=sa;Password=myPassw0rd;MultipleActiveResultSets=true;TrustServerCertificate=True;
          - Redis__Configuration=redis
        ports:
          - "44354:443"
        depends_on:
          sql-server:
            condition: service_healthy
          redis:
            condition: service_healthy
        restart: on-failure
        volumes:
          - ./certs:/root/certificate
        networks:
          - abp-network
      
      bookstore-authserver:
        image: acme/bookstore-authserver:latest
        container_name: bookstore-authserver
        build:
          context: ../../
          dockerfile: src/Acme.BookStore.AuthServer/Dockerfile.local
        environment:
          - ASPNETCORE_URLS=https://+:443;http://+:80;
          - App__SelfUrl=https://localhost:44334
          - App__CorsOrigins=https://localhost:44353,https://localhost:44354
          - AuthServer__RequireHttpsMetadata=false
          - AuthServer__Authority=http://bookstore-authserver
          - Kestrel__Certificates__Default__Path=/root/certificate/localhost.pfx
          - Kestrel__Certificates__Default__Password=91f91912-5ab0-49df-8166-23377efaf3cc
          - ConnectionStrings__Default=Data Source=sql-server;Initial Catalog=BookStore;User Id=sa;Password=myPassw0rd;MultipleActiveResultSets=true;TrustServerCertificate=True;
          - Redis__Configuration=redis
        ports:
          - "44334:443"
        depends_on:
          sql-server:
            condition: service_healthy
          redis:
            condition: service_healthy
        restart: on-failure
        volumes:
          - ./certs:/root/certificate
        networks:
          - abp-network
    
      
      db-migrator:
        image: acme/bookstore-db-migrator:latest
        container_name: db-migrator
        build:
          context: ../../
          dockerfile: src/BookStore.DbMigrator/Dockerfile.local
        environment:
          - OpenIddict__Applications__BookStore_Web__RootUrl=https://localhost:44353
          - OpenIddict__Applications__BookStore_Swagger__RootUrl=https://localhost:44354
          - ConnectionStrings__Default=Data Source=sql-server;Initial Catalog=BookStore;User Id=sa;Password=myPassw0rd;MultipleActiveResultSets=true;TrustServerCertificate=True;
        depends_on:
          sql-server:
            condition: service_healthy
        networks:
          - abp-network
      
      sql-server:
        container_name: sql-server
        image: mcr.microsoft.com/mssql/server:2019-latest
        ports:
          - "1434:1433"
        environment:
          SA_PASSWORD: "myPassw0rd"
          ACCEPT_EULA: "Y"
        volumes:
          - sqldata:/var/opt/mssql
        networks:
          - abp-network
        healthcheck:
          test: /opt/mssql-tools/bin/sqlcmd -S sql-server -U sa -P "myPassw0rd" -Q "SELECT 1" -b -o /dev/null
          interval: 10s
          timeout: 3s
          retries: 10
          start_period: 10s
      redis:
        container_name: redis
        image: redis:alpine
        ports:
          - "6379:6379"
        networks:
          - abp-network
        healthcheck:
          test: ["CMD", "redis-cli","ping"]
    volumes:
      sqldata:
        name: bookstore_sqldata
    networks:
      abp-network:
        name: bookstore-network
        driver: bridge
    

    You can try to use this and update as you see fit.

  • User Avatar
    0
    Spospisil created

    Currently, the generated docker-compose.yml file for a tiered solution only has the 'web' service defined in it, but I'm more concerned about all the url settings needed to run ABP, such as the ones for oidc, etc

    On which version did you come across this behavior? This problem should have been fixed on version 7.1.0-rc.

    Here is the docker-compose.yml file I've just generated for a tiered mvc project named Acme.BookStore on latest rc version 7.1.0-rc.3:

    version: '3.7' 
     
    services: 
      bookstore-web: 
        image: acme/bookstore-web:latest 
        container_name: bookstore-web 
        hostname: bookstore-web 
        build: 
          context: ../../ 
          dockerfile: src/Acme.BookStore.Web/Dockerfile.local 
        environment: 
          - ASPNETCORE_URLS=https://+:443;http://+:80; 
          - Kestrel__Certificates__Default__Path=/root/certificate/localhost.pfx 
          - Kestrel__Certificates__Default__Password=91f91912-5ab0-49df-8166-23377efaf3cc 
          - App__SelfUrl=https://localhost:44353 
          - AuthServer__RequireHttpsMetadata=false 
          - AuthServer__IsContainerizedOnLocalhost=true 
          - AuthServer__Authority=https://localhost:44334/ 
          - RemoteServices__Default__BaseUrl=http://bookstore-api 
          - RemoteServices__AbpAccountPublic__BaseUrl=http://bookstore-authserver 
          - AuthServer__MetaAddress=http://bookstore-authserver 
          - Redis__Configuration=redis 
        ports: 
          - "44353:443" 
        depends_on: 
          - bookstore-api 
        restart: on-failure 
        volumes: 
          - ./certs:/root/certificate 
        networks: 
          - abp-network 
     
      bookstore-api: 
        image: acme/bookstore-api:latest 
        container_name: bookstore-api 
        hostname: bookstore-api 
        build: 
          context: ../../ 
          dockerfile: src/Acme.BookStore.HttpApi.Host/Dockerfile.local 
        environment: 
          - ASPNETCORE_URLS=https://+:443;http://+:80; 
          - Kestrel__Certificates__Default__Path=/root/certificate/localhost.pfx 
          - Kestrel__Certificates__Default__Password=91f91912-5ab0-49df-8166-23377efaf3cc 
          - App__SelfUrl=https://localhost:44354 
          - App__HealthCheckUrl=http://bookstore-api/health-status 
          - AuthServer__RequireHttpsMetadata=false 
          - AuthServer__Authority=http://bookstore-authserver 
          - ConnectionStrings__Default=Data Source=sql-server;Initial Catalog=BookStore;User Id=sa;Password=myPassw0rd;MultipleActiveResultSets=true;TrustServerCertificate=True; 
          - Redis__Configuration=redis 
        ports: 
          - "44354:443" 
        depends_on: 
          sql-server: 
            condition: service_healthy 
          redis: 
            condition: service_healthy 
        restart: on-failure 
        volumes: 
          - ./certs:/root/certificate 
        networks: 
          - abp-network 
       
      bookstore-authserver: 
        image: acme/bookstore-authserver:latest 
        container_name: bookstore-authserver 
        build: 
          context: ../../ 
          dockerfile: src/Acme.BookStore.AuthServer/Dockerfile.local 
        environment: 
          - ASPNETCORE_URLS=https://+:443;http://+:80; 
          - App__SelfUrl=https://localhost:44334 
          - App__CorsOrigins=https://localhost:44353,https://localhost:44354 
          - AuthServer__RequireHttpsMetadata=false 
          - AuthServer__Authority=http://bookstore-authserver 
          - Kestrel__Certificates__Default__Path=/root/certificate/localhost.pfx 
          - Kestrel__Certificates__Default__Password=91f91912-5ab0-49df-8166-23377efaf3cc 
          - ConnectionStrings__Default=Data Source=sql-server;Initial Catalog=BookStore;User Id=sa;Password=myPassw0rd;MultipleActiveResultSets=true;TrustServerCertificate=True; 
          - Redis__Configuration=redis 
        ports: 
          - "44334:443" 
        depends_on: 
          sql-server: 
            condition: service_healthy 
          redis: 
            condition: service_healthy 
        restart: on-failure 
        volumes: 
          - ./certs:/root/certificate 
        networks: 
          - abp-network 
     
       
      db-migrator: 
        image: acme/bookstore-db-migrator:latest 
        container_name: db-migrator 
        build: 
          context: ../../ 
          dockerfile: src/BookStore.DbMigrator/Dockerfile.local 
        environment: 
          - OpenIddict__Applications__BookStore_Web__RootUrl=https://localhost:44353 
          - OpenIddict__Applications__BookStore_Swagger__RootUrl=https://localhost:44354 
          - ConnectionStrings__Default=Data Source=sql-server;Initial Catalog=BookStore;User Id=sa;Password=myPassw0rd;MultipleActiveResultSets=true;TrustServerCertificate=True; 
        depends_on: 
          sql-server: 
            condition: service_healthy 
        networks: 
          - abp-network 
       
      sql-server: 
        container_name: sql-server 
        image: mcr.microsoft.com/mssql/server:2019-latest 
        ports: 
          - "1434:1433" 
        environment: 
          SA_PASSWORD: "myPassw0rd" 
          ACCEPT_EULA: "Y" 
        volumes: 
          - sqldata:/var/opt/mssql 
        networks: 
          - abp-network 
        healthcheck: 
          test: /opt/mssql-tools/bin/sqlcmd -S sql-server -U sa -P "myPassw0rd" -Q "SELECT 1" -b -o /dev/null 
          interval: 10s 
          timeout: 3s 
          retries: 10 
          start_period: 10s 
      redis: 
        container_name: redis 
        image: redis:alpine 
        ports: 
          - "6379:6379" 
        networks: 
          - abp-network 
        healthcheck: 
          test: ["CMD", "redis-cli","ping"] 
    volumes: 
      sqldata: 
        name: bookstore_sqldata 
    networks: 
      abp-network: 
        name: bookstore-network 
        driver: bridge 
    

    You can try to use this and update as you see fit.

    As I indicated in the initial support ticket I am running 7.0.2. However let me take what you outlined and apply it to what my current docker-compose is currently.

  • User Avatar
    0
    Spospisil created

    Currently, the generated docker-compose.yml file for a tiered solution only has the 'web' service defined in it, but I'm more concerned about all the url settings needed to run ABP, such as the ones for oidc, etc

    On which version did you come across this behavior? This problem should have been fixed on version 7.1.0-rc.

    Here is the docker-compose.yml file I've just generated for a tiered mvc project named Acme.BookStore on latest rc version 7.1.0-rc.3:

    version: '3.7'  
      
    services:  
      bookstore-web:  
        image: acme/bookstore-web:latest  
        container_name: bookstore-web  
        hostname: bookstore-web  
        build:  
          context: ../../  
          dockerfile: src/Acme.BookStore.Web/Dockerfile.local  
        environment:  
          - ASPNETCORE_URLS=https://+:443;http://+:80;  
          - Kestrel__Certificates__Default__Path=/root/certificate/localhost.pfx  
          - Kestrel__Certificates__Default__Password=91f91912-5ab0-49df-8166-23377efaf3cc  
          - App__SelfUrl=https://localhost:44353  
          - AuthServer__RequireHttpsMetadata=false  
          - AuthServer__IsContainerizedOnLocalhost=true  
          - AuthServer__Authority=https://localhost:44334/  
          - RemoteServices__Default__BaseUrl=http://bookstore-api  
          - RemoteServices__AbpAccountPublic__BaseUrl=http://bookstore-authserver  
          - AuthServer__MetaAddress=http://bookstore-authserver  
          - Redis__Configuration=redis  
        ports:  
          - "44353:443"  
        depends_on:  
          - bookstore-api  
        restart: on-failure  
        volumes:  
          - ./certs:/root/certificate  
        networks:  
          - abp-network  
      
      bookstore-api:  
        image: acme/bookstore-api:latest  
        container_name: bookstore-api  
        hostname: bookstore-api  
        build:  
          context: ../../  
          dockerfile: src/Acme.BookStore.HttpApi.Host/Dockerfile.local  
        environment:  
          - ASPNETCORE_URLS=https://+:443;http://+:80;  
          - Kestrel__Certificates__Default__Path=/root/certificate/localhost.pfx  
          - Kestrel__Certificates__Default__Password=91f91912-5ab0-49df-8166-23377efaf3cc  
          - App__SelfUrl=https://localhost:44354  
          - App__HealthCheckUrl=http://bookstore-api/health-status  
          - AuthServer__RequireHttpsMetadata=false  
          - AuthServer__Authority=http://bookstore-authserver  
          - ConnectionStrings__Default=Data Source=sql-server;Initial Catalog=BookStore;User Id=sa;Password=myPassw0rd;MultipleActiveResultSets=true;TrustServerCertificate=True;  
          - Redis__Configuration=redis  
        ports:  
          - "44354:443"  
        depends_on:  
          sql-server:  
            condition: service_healthy  
          redis:  
            condition: service_healthy  
        restart: on-failure  
        volumes:  
          - ./certs:/root/certificate  
        networks:  
          - abp-network  
        
      bookstore-authserver:  
        image: acme/bookstore-authserver:latest  
        container_name: bookstore-authserver  
        build:  
          context: ../../  
          dockerfile: src/Acme.BookStore.AuthServer/Dockerfile.local  
        environment:  
          - ASPNETCORE_URLS=https://+:443;http://+:80;  
          - App__SelfUrl=https://localhost:44334  
          - App__CorsOrigins=https://localhost:44353,https://localhost:44354  
          - AuthServer__RequireHttpsMetadata=false  
          - AuthServer__Authority=http://bookstore-authserver  
          - Kestrel__Certificates__Default__Path=/root/certificate/localhost.pfx  
          - Kestrel__Certificates__Default__Password=91f91912-5ab0-49df-8166-23377efaf3cc  
          - ConnectionStrings__Default=Data Source=sql-server;Initial Catalog=BookStore;User Id=sa;Password=myPassw0rd;MultipleActiveResultSets=true;TrustServerCertificate=True;  
          - Redis__Configuration=redis  
        ports:  
          - "44334:443"  
        depends_on:  
          sql-server:  
            condition: service_healthy  
          redis:  
            condition: service_healthy  
        restart: on-failure  
        volumes:  
          - ./certs:/root/certificate  
        networks:  
          - abp-network  
      
        
      db-migrator:  
        image: acme/bookstore-db-migrator:latest  
        container_name: db-migrator  
        build:  
          context: ../../  
          dockerfile: src/BookStore.DbMigrator/Dockerfile.local  
        environment:  
          - OpenIddict__Applications__BookStore_Web__RootUrl=https://localhost:44353  
          - OpenIddict__Applications__BookStore_Swagger__RootUrl=https://localhost:44354  
          - ConnectionStrings__Default=Data Source=sql-server;Initial Catalog=BookStore;User Id=sa;Password=myPassw0rd;MultipleActiveResultSets=true;TrustServerCertificate=True;  
        depends_on:  
          sql-server:  
            condition: service_healthy  
        networks:  
          - abp-network  
        
      sql-server:  
        container_name: sql-server  
        image: mcr.microsoft.com/mssql/server:2019-latest  
        ports:  
          - "1434:1433"  
        environment:  
          SA_PASSWORD: "myPassw0rd"  
          ACCEPT_EULA: "Y"  
        volumes:  
          - sqldata:/var/opt/mssql  
        networks:  
          - abp-network  
        healthcheck:  
          test: /opt/mssql-tools/bin/sqlcmd -S sql-server -U sa -P "myPassw0rd" -Q "SELECT 1" -b -o /dev/null  
          interval: 10s  
          timeout: 3s  
          retries: 10  
          start_period: 10s  
      redis:  
        container_name: redis  
        image: redis:alpine  
        ports:  
          - "6379:6379"  
        networks:  
          - abp-network  
        healthcheck:  
          test: ["CMD", "redis-cli","ping"]  
    volumes:  
      sqldata:  
        name: bookstore_sqldata  
    networks:  
      abp-network:  
        name: bookstore-network  
        driver: bridge  
    

    You can try to use this and update as you see fit.

    As I indicated in the initial support ticket I am running 7.0.2. However let me take what you outlined and apply it to what my current docker-compose is currently.

    Can you also show me what your OpenIddictApplications table looks like as well please?

  • User Avatar
    0
    gterdem created
    Support Team Senior .NET Developer

    I don't recommend altering database manually, ever.

    Application must handle this since this information is cached. If you manually alter it from the database, application won't know it and you will still get error since the cache is not invalidated. Secondly, it is complicated and all the list information is held as in a string by the OpenIdDict library which is very prune to manual typos or missing commas that can be very hard to troubleshoot.

    You can examine the environment variables of the DbMigrator service to see which data is overridden.

    In tiered solution, there are basically 2 different clients/applications:

    • Web: OpenIddict__Applications__BookStore_Web__RootUrl=https://localhost:44353
    • SwaggerUI: OpenIddict__Applications__BookStore_Swagger__RootUrl=https://localhost:44354

    Web application runs on https://localhost:44353 SwaggerUI is on Http.Api.Host which runs on https://localhost:44354

  • User Avatar
    0
    Spospisil created

    So, not surprisingly to me the out of the box solution produced using the version you specified be used does not even build, so I'll have to spend some time here first figuring out what the issue is in the build before trying out the solution you suggested.

  • User Avatar
    0
    Spospisil created

    So, not surprisingly to me the out of the box solution produced using the version you specified be used does not even build, so I'll have to spend some time here first figuring out what the issue is in the build before trying out the solution you suggested.

    Any assistance you could provide to the error I'm getting out of the box would be very helpful.

    PS C:\bookstore\bookstore\etc\docker> .\run-docker.ps1 docker-compose : Creating network "bookstore-network" with driver "bridge" At C:\bookstore\bookstore\etc\docker\run-docker.ps1:16 char:1

    • docker-compose up -d
    •   + CategoryInfo          : NotSpecified: (Creating networ...driver "bridge":String) [], RemoteException
        + FullyQualifiedErrorId : NativeCommandError
      
      

    Building db-migrator #1 [internal] load build definition from Dockerfile.local #1 sha256:6c9be97f9f8271f05874fb52f7bcccfc4c31691a1c114c723c053b1529d83196 #1 transferring dockerfile: 38B done #1 DONE 0.0s #2 [internal] load .dockerignore #2 sha256:3b5b004ae2d4be64dd318933a5c91a53c3bacf0671f5b5de5016f34a1e1cd992 #2 transferring context: 366B done #2 DONE 0.0s #3 [internal] load metadata for mcr.microsoft.com/dotnet/aspnet:7.0 #3 sha256:bd81707146cb292c295dcfd83d3d7f373e1cbce6796768c5454f972e96118801 #3 DONE 0.0s #4 [1/3] FROM mcr.microsoft.com/dotnet/aspnet:7.0 #4 sha256:fca9347c67c2a2d23af44c6e8d6dcb7691ddb36bcfa46dbc8c338612349514b9 #4 CACHED #5 [internal] load build context #5 sha256:4ad41e85c8cbe41a30b57549e8807d3a01884469bba0e31295e5db07c821fdcd #5 transferring context: 25B done #5 DONE 0.0s #6 [2/3] COPY bin/Release/net7.0/publish/ app/ #6 sha256:3dac2ec270c0eea5c43deffff9c7b9aec2e2c1f1ff0da08cefe6ec900288542d #6 ERROR: "/bin/Release/net7.0/publish" not found: not found

    [2/3] COPY bin/Release/net7.0/publish/ app/:


    failed to compute cache key: "/bin/Release/net7.0/publish" not found: not found Service 'db-migrator' failed to build : Build failed

  • User Avatar
    0
    Spospisil created

    I got past the initial error.....however the out of the box solution STILL does not work within a local docker environment. Actually I'm in a worse position now as the API does not even load properly now.

    Can you please provide step by step documentation on how to get the out of the box solution you created to work within a local docker environment.

    Again, I am using exactly the same version of ABP you used and cannot get it to run.

    Thanks.

  • User Avatar
    0
    gterdem created
    Support Team Senior .NET Developer

    The error indicates dockerfile could not find the related folder to create image. docker-compose would not work without building the images first since the dockerfiles are not multi-staged dockerfiles.

    You need to run etc/build/build-images-locally.ps1 to create the images first than run etc/docker/run-docker.ps1.

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