Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when docker-compose #192

Open
alexmc1510 opened this issue Nov 16, 2023 · 17 comments
Open

Error when docker-compose #192

alexmc1510 opened this issue Nov 16, 2023 · 17 comments
Assignees
Labels
bug Something isn't working

Comments

@alexmc1510
Copy link

Hello,

I am trying to install the project in a local environment for test and I receive the following error when running docker compose:

=> CACHED [build 3/7] COPY [UACloudLibraryServer/UA-CloudLibrary.csproj, UACloudLibraryServer/] 0.0s
=> [build 4/7] RUN dotnet restore "UACloudLibraryServer/UA-CloudLibrary.csproj" 140.3s
=> => # /src/UACloudLibraryServer/UA-CloudLibrary.csproj : error NU1301: Unable to load the service index for source h
=> => # ttps://api.nuget.org/v3/index.json.

@barnstee barnstee added the bug Something isn't working label Nov 17, 2023
@alexmc1510
Copy link
Author

@MarkusHorstmann ,hello, can I help you with the debug? I only program js but tell me if I can do something.

@alexmc1510
Copy link
Author

Hello, maybe I am doing something wrong...which is strange because docker-compose is straightforward. Can someone check or help me?

@barnstee
Copy link
Member

@MarkusHorstmann will be in touch soon.

@MarkusHorstmann
Copy link
Collaborator

Looking into this now.
How exactly do you run docker-compose? Windows Powershell/CMD command prompt? Linux shell? From within Visual Studio?

@MarkusHorstmann
Copy link
Collaborator

I just verified that the docker-compose in general still works in at least these scenarios:

  1. Visual Studio: selected docker-compose as the startup project and started debugging (I had to make sure no other configuration in appsettings.json or user secrets.json interfered).
  2. Windows powershell:
cd cd c:\sources\OPCFoundation\UA-CloudLibrary\
docker-compose up

In both cases I had to rerun the ua-cloudlibrary-1 container on first run because it doesn't wait for the pg database container to start.

Possible issues in your case:

  1. Intermittent service issues on nuget.org (I saw these yesterday): retry should fix this.
  2. Network connectivity from your docker environment: nuget.org needs to be reachable from a container.

@alexmc1510
Copy link
Author

Hello, here my debug session:

  • Running from Windows Powershell as you mentioned.

[+] Running 0/1

  • ua-cloudlibrary Warning 5.7s
    [+] Building 11.7s (11/17)
    => [internal] load build definition from Dockerfile 0.0s
    => => transferring dockerfile: 32B 0.0s
    => [internal] load .dockerignore 0.0s
    => => transferring context: 35B 0.0s
    => [internal] load metadata for mcr.microsoft.com/dotnet/sdk:6.0 0.3s
    => [internal] load metadata for mcr.microsoft.com/dotnet/aspnet:6.0 0.2s
    => [base 1/2] FROM mcr.microsoft.com/dotnet/aspnet:6.0@sha256:97cb6ea106e157df9c3db7b2c50884141d0d0764d465104d75 0.0s
    => [internal] load build context 0.2s
    => => transferring context: 33.09kB 0.2s
    => [build 1/7] FROM mcr.microsoft.com/dotnet/sdk:6.0@sha256:6816906adc86b96630fd58c86d73e49f01c9403aeef4a5c76c2b 0.0s
    => CACHED [base 2/2] WORKDIR /app 0.0s
    => CACHED [final 1/2] WORKDIR /app 0.0s
    => CACHED [build 2/7] WORKDIR /src 0.0s
    => CACHED [build 3/7] COPY [UACloudLibraryServer/UA-CloudLibrary.csproj, UACloudLibraryServer/] 0.0s
    => [build 4/7] RUN dotnet restore "UACloudLibraryServer/UA-CloudLibrary.csproj" 11.0s
    => => # Determining projects to restore...
    => => # /src/UACloudLibraryServer/UA-CloudLibrary.csproj : error NU1301: Unable to load the service index for source h
    => => # ttps://api.nuget.org/v3/index.json.
  • Downloading the image direcly from the repo and removing the build entry in the dockerfile to force to use the existing image.

WARNING: Using local filesystem for storage as HostingPlatform environment variable not specified or invalid!
warn: Microsoft.AspNetCore.DataProtection.Repositories.FileSystemXmlRepository[60]
Storing keys in a directory '/app' that may not be persisted outside of the container. Protected data will be unavailable when container is destroyed.
warn: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[35]
No XML encryptor configured. Key {1d7fea52-ace2-48f3-82de-2c28c3dcac7f} may be persisted to storage in unencrypted form.
WARNING: Using local filesystem for storage as HostingPlatform environment variable not specified or invalid!
warn: Microsoft.AspNetCore.DataProtection.Repositories.FileSystemXmlRepository[60]
Storing keys in a directory '/app' that may not be persisted outside of the container. Protected data will be unavailable when container is destroyed.
Unhandled exception. System.InvalidOperationException: Unable to configure HTTPS endpoint. No server certificate was specified, and the default developer certificate could not be found or is out of date.
To generate a developer certificate run 'dotnet dev-certs https'. To trust the certificate (Windows and macOS only) run 'dotnet dev-certs https --trust'.
For more information on configuring HTTPS see https://go.microsoft.com/fwlink/?linkid=848054.
at Microsoft.AspNetCore.Hosting.ListenOptionsHttpsExtensions.UseHttps(ListenOptions listenOptions, Action1 configureOptions) at Microsoft.AspNetCore.Hosting.ListenOptionsHttpsExtensions.UseHttps(ListenOptions listenOptions) at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.AddressesStrategy.BindAsync(AddressBindContext context, CancellationToken cancellationToken) at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.BindAsync(IEnumerable1 listenOptions, AddressBindContext context, CancellationToken cancellationToken)
at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServerImpl.BindAsync(CancellationToken cancellationToken)
at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServerImpl.StartAsync[TContext](IHttpApplication1 application, CancellationToken cancellationToken) at Microsoft.AspNetCore.Hosting.GenericWebHostService.StartAsync(CancellationToken cancellationToken) at Microsoft.Extensions.Hosting.Internal.Host.StartAsync(CancellationToken cancellationToken) at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token) at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token) at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.Run(IHost host) at Opc.Ua.Cloud.Library.Program.Main(String[] args) in /src/UACloudLibraryServer/Program.cs:line 39 Unhandled exception. System.InvalidOperationException: Unable to configure HTTPS endpoint. No server certificate was specified, and the default developer certificate could not be found or is out of date. To generate a developer certificate run 'dotnet dev-certs https'. To trust the certificate (Windows and macOS only) run 'dotnet dev-certs https --trust'. For more information on configuring HTTPS see https://go.microsoft.com/fwlink/?linkid=848054. at Microsoft.AspNetCore.Hosting.ListenOptionsHttpsExtensions.UseHttps(ListenOptions listenOptions, Action1 configureOptions)
at Microsoft.AspNetCore.Hosting.ListenOptionsHttpsExtensions.UseHttps(ListenOptions listenOptions)
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.AddressesStrategy.BindAsync(AddressBindContext context, CancellationToken cancellationToken)
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.BindAsync(IEnumerable1 listenOptions, AddressBindContext context, CancellationToken cancellationToken) at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServerImpl.BindAsync(CancellationToken cancellationToken) at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServerImpl.StartAsync[TContext](IHttpApplication1 application, CancellationToken cancellationToken)
at Microsoft.AspNetCore.Hosting.GenericWebHostService.StartAsync(CancellationToken cancellationToken)
at Microsoft.Extensions.Hosting.Internal.Host.StartAsync(CancellationToken cancellationToken)
at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token)
at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token)
at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.Run(IHost host)
at Opc.Ua.Cloud.Library.Program.Main(String[] args) in /src/UACloudLibraryServer/Program.cs:line 39

  • Visual Basic docker-compose.
  • Executing task: docker compose -f "docker-compose.yml" up -d --build

[+] Building 24.4s (11/17)
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 32B 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 35B 0.0s
=> [internal] load metadata for mcr.microsoft.com/dotnet/sdk:6.0 0.3s
=> [internal] load metadata for mcr.microsoft.com/dotnet/aspnet:6.0 0.3s
=> [build 1/7] FROM mcr.microsoft.com/dotnet/sdk:6.0@sha256:6816906adc86b96630fd58c86d73e49f01c9403aeef4a5c76c2b1de4f15753ff 0.0s
=> [base 1/2] FROM mcr.microsoft.com/dotnet/aspnet:6.0@sha256:97cb6ea106e157df9c3db7b2c50884141d0d0764d465104d7515bf409d7c99d3 0.0s
=> [internal] load build context 0.2s
=> => transferring context: 33.09kB 0.2s
=> CACHED [base 2/2] WORKDIR /app 0.0s
=> CACHED [final 1/2] WORKDIR /app 0.0s
=> CACHED [build 2/7] WORKDIR /src 0.0s
=> CACHED [build 3/7] COPY [UACloudLibraryServer/UA-CloudLibrary.csproj, UACloudLibraryServer/] 0.0s
=> [build 4/7] RUN dotnet restore "UACloudLibraryServer/UA-CloudLibrary.csproj" 23.7s
=> => # Determining projects to restore...
=> => # /src/UACloudLibraryServer/UA-CloudLibrary.csproj : error NU1301: Unable to load the service index for source https://api.nuget.org/v3/index.json.
=> => # /src/UACloudLibraryServer/UA-CloudLibrary.csproj : error NU1301: Unable to load the service index for source https://api.nuget.org/v3/index.json.

I just want to run the complete platform into a docker system in a VM: all the components.

@MarkusHorstmann
Copy link
Collaborator

Is it possible that you are connecting through a proxy server? See https://stackoverflow.com/questions/50347517/docker-unable-to-load-the-service-index-for-source-https-api-nuget-org-v3-inde.

@alexmc1510
Copy link
Author

It could be the issue for error 1 and 3 of my previous post but not for the case where I downloaded directly the image. You can see that the error is this case is related to HTTPS and server certificate.

@alexmc1510
Copy link
Author

alexmc1510 commented Nov 26, 2023

Hello, below the error when I run it from a computer without proxy:

cmd
docker-compose up


[+] Running 1/1
 ! ua-cloudlibrary Warning                                                                                         3.1s
[+] Building 10.5s (15/17)                                                                               docker:default
 => [ua-cloudlibrary internal] load .dockerignore                                                                  0.0s
 => => transferring context: 373B                                                                                  0.0s
 => [ua-cloudlibrary internal] load build definition from Dockerfile                                               0.0s
 => => transferring dockerfile: 800B                                                                               0.0s
 => [ua-cloudlibrary internal] load metadata for mcr.microsoft.com/dotnet/sdk:6.0                                  0.2s
 => [ua-cloudlibrary internal] load metadata for mcr.microsoft.com/dotnet/aspnet:6.0                               0.2s
 => [ua-cloudlibrary build 1/7] FROM mcr.microsoft.com/dotnet/sdk:6.0@sha256:6816906adc86b96630fd58c86d73e49f01c9  0.0s
 => [ua-cloudlibrary base 1/2] FROM mcr.microsoft.com/dotnet/aspnet:6.0@sha256:97cb6ea106e157df9c3db7b2c50884141d  0.0s
 => [ua-cloudlibrary internal] load build context                                                                  0.1s
 => => transferring context: 29.88kB                                                                               0.1s
 => CACHED [ua-cloudlibrary base 2/2] WORKDIR /app                                                                 0.0s
 => CACHED [ua-cloudlibrary final 1/2] WORKDIR /app                                                                0.0s
 => CACHED [ua-cloudlibrary build 2/7] WORKDIR /src                                                                0.0s
 => CACHED [ua-cloudlibrary build 3/7] COPY [UACloudLibraryServer/UA-CloudLibrary.csproj, UACloudLibraryServer/]   0.0s
 => CACHED [ua-cloudlibrary build 4/7] RUN dotnet restore "UACloudLibraryServer/UA-CloudLibrary.csproj"            0.0s
 => CACHED [ua-cloudlibrary build 5/7] COPY . .                                                                    0.0s
 => CACHED [ua-cloudlibrary build 6/7] WORKDIR /src/UACloudLibraryServer                                           0.0s
 => ERROR [ua-cloudlibrary build 7/7] RUN dotnet build "UA-CloudLibrary.csproj" -c Release -o /app/build          10.0s
------
 > [ua-cloudlibrary build 7/7] RUN dotnet build "UA-CloudLibrary.csproj" -c Release -o /app/build:
0.718 MSBuild version 17.3.2+561848881 for .NET
1.563   Determining projects to restore...
4.367   Restored /src/UACloudLibraryServer/UA-CloudLibrary.csproj (in 2.32 sec).
5.675 /root/.nuget/packages/microsoft.build.tasks.git/1.1.1/build/Microsoft.Build.Tasks.Git.targets(25,5): warning : Unable to locate repository with working directory that contains directory '/src/UACloudLibraryServer'. [/src/UACloudLibraryServer/UA-CloudLibrary.csproj]
5.763 /root/.nuget/packages/microsoft.build.tasks.git/1.1.1/build/Microsoft.Build.Tasks.Git.targets(48,5): warning : Unable to locate repository with working directory that contains directory '/src/UACloudLibraryServer'. [/src/UACloudLibraryServer/UA-CloudLibrary.csproj]
5.771 /root/.nuget/packages/microsoft.sourcelink.common/1.1.1/build/Microsoft.SourceLink.Common.targets(53,5): warning : Source control information is not available - the generated source link is empty. [/src/UACloudLibraryServer/UA-CloudLibrary.csproj]
9.885 /src/UACloudLibraryServer/Views/Shared/_Layout.cshtml(36,121): error CS0117: 'ThisAssembly' does not contain a definition for 'GitCommitId' [/src/UACloudLibraryServer/UA-CloudLibrary.csproj]
9.898
9.898 Build FAILED.
9.898
9.898 /root/.nuget/packages/microsoft.build.tasks.git/1.1.1/build/Microsoft.Build.Tasks.Git.targets(25,5): warning : Unable to locate repository with working directory that contains directory '/src/UACloudLibraryServer'. [/src/UACloudLibraryServer/UA-CloudLibrary.csproj]
9.898 /root/.nuget/packages/microsoft.build.tasks.git/1.1.1/build/Microsoft.Build.Tasks.Git.targets(48,5): warning : Unable to locate repository with working directory that contains directory '/src/UACloudLibraryServer'. [/src/UACloudLibraryServer/UA-CloudLibrary.csproj]
9.898 /root/.nuget/packages/microsoft.sourcelink.common/1.1.1/build/Microsoft.SourceLink.Common.targets(53,5): warning : Source control information is not available - the generated source link is empty. [/src/UACloudLibraryServer/UA-CloudLibrary.csproj]
9.899 /src/UACloudLibraryServer/Views/Shared/_Layout.cshtml(36,121): error CS0117: 'ThisAssembly' does not contain a definition for 'GitCommitId' [/src/UACloudLibraryServer/UA-CloudLibrary.csproj]
9.899     3 Warning(s)
9.899     1 Error(s)
9.899
9.899 Time Elapsed 00:00:09.05
------
failed to solve: process "/bin/sh -c dotnet build \"UA-CloudLibrary.csproj\" -c Release -o /app/build" did not complete successfully: exit code: 1

@MarkusHorstmann
Copy link
Collaborator

This error indicates that you don't have a GIT repository clone, but only the files. Building the cloudlibrary requires a valid GIT repository.

@barnstee
Copy link
Member

@alexmc1510, are you now unblocked?

@alexmc1510
Copy link
Author

alexmc1510 commented Dec 14, 2023

Hello, I finally managed to deploy the compose as you mentioned using another laptop. It seems everything ok, db is up and running but I cannot access to the web interface of the library in port 8443. Here the log of the container and the error:

2023-12-14 23:17:29 warn: Microsoft.AspNetCore.DataProtection.Repositories.FileSystemXmlRepository[60]
2023-12-14 23:17:29 Storing keys in a directory '/app' that may not be persisted outside of the container. Protected data will be unavailable when container is destroyed.
2023-12-14 23:17:31 info: Microsoft.Hosting.Lifetime[14]
2023-12-14 23:17:31 Now listening on: http://[::]:80
2023-12-14 23:17:31 info: Microsoft.Hosting.Lifetime[0]
2023-12-14 23:17:31 Application started. Press Ctrl+C to shut down.
2023-12-14 23:17:31 info: Microsoft.Hosting.Lifetime[0]
2023-12-14 23:17:31 Hosting environment: Production
2023-12-14 23:17:31 info: Microsoft.Hosting.Lifetime[0]
2023-12-14 23:17:31 Content root path: /app

Error:
image

Do you have any idea....

@barnstee
Copy link
Member

Can you double-check in your docker environment that port 80 is mapped to port 8443?

@alexmc1510
Copy link
Author

In the docker-compose you have the following so no....I confirm you that it is not mapped. The compose file is mapping 443 to 8443.

services:
ua-cloudlibrary:
image: ${DOCKER_REGISTRY-}uacloudlibrary
ports:
- 8443:443
build:
context: .
dockerfile: UACloudLibraryServer/Dockerfile
environment:
PostgreSQLUsername: uacloudlib
PostgreSQLPassword: uacloudlib
ServicePassword: uacloudlib
PostgreSQLEndpoint: db

@barnstee
Copy link
Member

Ok, then make sure you use https://localhost

@alexmc1510
Copy link
Author

Hello, I managed to enter in the main page adding port mapping for port 80, nevertheless, it seems that without a cloud deployment I cannot login as an external service is required. Is it not possible to have the library running in "PROD" on premise? Do you know what could be the issue of not accessing by port 443?

@barnstee
Copy link
Member

@MarkusHorstmann , any idea?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants