Librum-Reader/Librum-Server

Cannot build

janaxhell opened this issue · 13 comments

I'm trying to deploy this on docker x86, I've cloned the git, but when I try to build, the operation fails:

root@openmediavault:~/Librum-Server# docker build . -t librum
[+] Building 47.1s (13/19)                                                                               docker:default
 => [internal] load .dockerignore                                                                                  1.2s
 => => transferring context: 2B                                                                                    0.1s
 => [internal] load build definition from Dockerfile                                                               1.5s
 => => transferring dockerfile: 1.23kB                                                                             0.1s
 => [internal] load metadata for mcr.microsoft.com/dotnet/sdk:7.0                                                  2.2s
 => [internal] load metadata for mcr.microsoft.com/dotnet/aspnet:7.0                                               2.2s
 => [stage-1  1/10] FROM mcr.microsoft.com/dotnet/aspnet:7.0@sha256:743d4bd26c49646063980e194e4511e634ad6acd42f5  11.0s
 => => resolve mcr.microsoft.com/dotnet/aspnet:7.0@sha256:743d4bd26c49646063980e194e4511e634ad6acd42f5c5dcfdead00  0.6s
 => => sha256:743d4bd26c49646063980e194e4511e634ad6acd42f5c5dcfdead00ba06c5b2e 1.79kB / 1.79kB                     0.0s
 => => sha256:55ead8f1276b27abef1afe689269e6a977c072b87ec861fc3c3a806e6981178a 1.37kB / 1.37kB                     0.0s
 => => sha256:3cd2697e389f1f41d135cf539e908d838d1ebdf00c7e08a73c59b1b774aa7d4d 2.36kB / 2.36kB                     0.0s
 => => sha256:d48364e8bf766e63c7388427188ee4b6d260b35a24a4d37d4fb1a8b69654b1fe 14.97MB / 14.97MB                   1.2s
 => => sha256:10150b823b311ce705b8666aeea939e6e811eaec5385b80dfeef09099459ff92 155B / 155B                         1.0s
 => => sha256:90406e5c4fd4719e8fcdd31778acbd3eda5a6ebbb26028e9dae4444462c29cf2 32.46MB / 32.46MB                   2.0s
 => => sha256:dfc18d8c8dd1d8ed3005e96959e81b977daab51543d1f53012f2bbdc2ef8127a 10.12MB / 10.12MB                   2.2s
 => => extracting sha256:d48364e8bf766e63c7388427188ee4b6d260b35a24a4d37d4fb1a8b69654b1fe                         40.2s
 => => extracting sha256:90406e5c4fd4719e8fcdd31778acbd3eda5a6ebbb26028e9dae4444462c29cf2                         38.4s
 => => extracting sha256:dfc18d8c8dd1d8ed3005e96959e81b977daab51543d1f53012f2bbdc2ef8127a                         35.8s
 => [internal] load build context                                                                                  1.3s
 => => transferring context: 1.39MB                                                                                0.1s
 => [build 1/4] FROM mcr.microsoft.com/dotnet/sdk:7.0@sha256:b1cac83c512ebf84f1f1b8a84e412838f7e946c35a7f34114ab  34.5s
 => => resolve mcr.microsoft.com/dotnet/sdk:7.0@sha256:b1cac83c512ebf84f1f1b8a84e412838f7e946c35a7f34114abe284de9  0.6s
 => => sha256:b1cac83c512ebf84f1f1b8a84e412838f7e946c35a7f34114abe284de93dc779 1.79kB / 1.79kB                     0.0s
 => => sha256:04d3a19daaaf26caad5c37663fec4de6193529c348f361c35dc3ff6fd6019bf3 2.01kB / 2.01kB                     0.0s
 => => sha256:3723787e2be92327f28d75b0b9a05559efd7cc909f809d188334ee5c239dd451 5.31kB / 5.31kB                     0.0s
 => => sha256:d48364e8bf766e63c7388427188ee4b6d260b35a24a4d37d4fb1a8b69654b1fe 14.97MB / 14.97MB                   1.3s
 => => sha256:10150b823b311ce705b8666aeea939e6e811eaec5385b80dfeef09099459ff92 155B / 155B                         1.0s
 => => sha256:90406e5c4fd4719e8fcdd31778acbd3eda5a6ebbb26028e9dae4444462c29cf2 32.46MB / 32.46MB                   2.1s
 => => sha256:dfc18d8c8dd1d8ed3005e96959e81b977daab51543d1f53012f2bbdc2ef8127a 10.12MB / 10.12MB                   2.3s
 => => extracting sha256:d48364e8bf766e63c7388427188ee4b6d260b35a24a4d37d4fb1a8b69654b1fe                          0.9s
 => => sha256:2ec4e41d3fea05c7cf93acef59791d531cd93141d7c6a490b94674703c7057a0 25.38MB / 25.38MB                   2.9s
 => => sha256:401693f5bb8d375400c42cb28bc1c3ce7d3933327a2800395a2dccb0d1a6edc7 180.94MB / 180.94MB                 8.3s
 => => sha256:fe21a45bda9ba49e0f80d912ea9144a81f99a4699b6fbc79044ee39357bdd6b7 13.97MB / 13.97MB                   3.3s
 => => extracting sha256:90406e5c4fd4719e8fcdd31778acbd3eda5a6ebbb26028e9dae4444462c29cf2                          1.7s
 => => extracting sha256:10150b823b311ce705b8666aeea939e6e811eaec5385b80dfeef09099459ff92                          0.1s
 => => extracting sha256:dfc18d8c8dd1d8ed3005e96959e81b977daab51543d1f53012f2bbdc2ef8127a                          0.5s
 => => extracting sha256:2ec4e41d3fea05c7cf93acef59791d531cd93141d7c6a490b94674703c7057a0                          1.7s
 => => extracting sha256:401693f5bb8d375400c42cb28bc1c3ce7d3933327a2800395a2dccb0d1a6edc7                         11.4s
 => => extracting sha256:fe21a45bda9ba49e0f80d912ea9144a81f99a4699b6fbc79044ee39357bdd6b7                          0.8s
 => [stage-1  2/10] WORKDIR /var/lib/librum-server/                                                                5.9s
 => [stage-1  3/10] RUN groupadd -r -f librum-server                                                               9.1s
 => [stage-1  4/10] RUN useradd -r -g librum-server -d /var/lib/librum-server --shell /usr/sbin/nologin librum-se  7.5s
 => [build 2/4] WORKDIR /app                                                                                       0.8s
 => [build 3/4] COPY . .                                                                                           1.1s
 => ERROR [build 4/4] RUN dotnet restore &&     cd src/Presentation &&     dotnet publish -c Release -o build  --  5.8s
------
 > [build 4/4] RUN dotnet restore &&     cd src/Presentation &&     dotnet publish -c Release -o build  --no-restore --verbosity m:
4.588   Determining projects to restore...
4.860 /usr/share/dotnet/sdk/7.0.404/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.TargetFrameworkInference.targets(160,5): error NETSDK1045: The current .NET SDK does not support targeting .NET 8.0.  Either target .NET 7.0 or lower, or use a version of the .NET SDK that supports .NET 8.0. Download the .NET SDK from https://aka.ms/dotnet/download [/app/src/Domain/Domain.csproj]
4.865 /usr/share/dotnet/sdk/7.0.404/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.TargetFrameworkInference.targets(160,5): error NETSDK1045: The current .NET SDK does not support targeting .NET 8.0.  Either target .NET 7.0 or lower, or use a version of the .NET SDK that supports .NET 8.0. Download the .NET SDK from https://aka.ms/dotnet/download [/app/src/Application/Application.csproj]
4.869 /usr/share/dotnet/sdk/7.0.404/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.TargetFrameworkInference.targets(160,5): error NETSDK1045: The current .NET SDK does not support targeting .NET 8.0.  Either target .NET 7.0 or lower, or use a version of the .NET SDK that supports .NET 8.0. Download the .NET SDK from https://aka.ms/dotnet/download [/app/tests/Application.UnitTests/Application.UnitTests.csproj]
4.875 /usr/share/dotnet/sdk/7.0.404/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.TargetFrameworkInference.targets(160,5): error NETSDK1045: The current .NET SDK does not support targeting .NET 8.0.  Either target .NET 7.0 or lower, or use a version of the .NET SDK that supports .NET 8.0. Download the .NET SDK from https://aka.ms/dotnet/download [/app/src/Infrastructure/Infrastructure.csproj]
4.882 /usr/share/dotnet/sdk/7.0.404/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.TargetFrameworkInference.targets(160,5): error NETSDK1045: The current .NET SDK does not support targeting .NET 8.0.  Either target .NET 7.0 or lower, or use a version of the .NET SDK that supports .NET 8.0. Download the .NET SDK from https://aka.ms/dotnet/download [/app/src/Presentation/Presentation.csproj]
------
Dockerfile:5
--------------------
   4 |     COPY . .
   5 | >>> RUN dotnet restore && \
   6 | >>>     cd src/Presentation && \
   7 | >>>     dotnet publish -c Release -o build  --no-restore --verbosity m
   8 |
--------------------
ERROR: failed to solve: process "/bin/sh -c dotnet restore &&     cd src/Presentation &&     dotnet publish -c Release -o build  --no-restore --verbosity m" did not complete successfully: exit code: 1

What can I check?

I had the same issue. I can't confirm everything works as of right now, but it will build.

To fix:
In 'Dockerfile' change
FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build to FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build

and

FROM mcr.microsoft.com/dotnet/aspnet:7.0 to FROM mcr.microsoft.com/dotnet/aspnet:8.0.

Right, thanks for pointing that out. I have updated the server to .NET 8 some days ago, but forgot to update that in the docker files.

Thank you, I was able to build with that fix, now off to compose!

It doesn't work:

2023-12-18T14:10:26.758444287Z Running in selfhosted mode, skipping AzureKeyVault configuration
2023-12-18T14:10:27.977414519Z warn: Microsoft.EntityFrameworkCore.Model.Validation[10400]
2023-12-18T14:10:27.977448259Z       Sensitive data logging is enabled. Log entries and exception messages may include sensitive application data; this mode should only be enabled during development.
2023-12-18T14:10:28.147875431Z fail: Microsoft.EntityFrameworkCore.Database.Connection[20004]
2023-12-18T14:10:28.147897184Z       An error occurred using the connection to database '' on server 'mariadb'.
2023-12-18T14:10:28.170998468Z Unhandled exception. System.InvalidOperationException: An exception has been raised that is likely due to a transient failure. Consider enabling transient error resiliency by adding 'EnableRetryOnFailure()' to the 'UseMySql' call.
2023-12-18T14:10:28.171026015Z  ---> MySqlConnector.MySqlException (0x80004005): Unable to connect to any of the specified MySQL hosts.
2023-12-18T14:10:28.171032248Z    at MySqlConnector.Core.ServerSession.ConnectAsync(ConnectionSettings cs, MySqlConnection connection, Int32 startTickCount, ILoadBalancer loadBalancer, IOBehavior ioBehavior, CancellationToken cancellationToken) in /_/src/MySqlConnector/Core/ServerSession.cs:line 433
2023-12-18T14:10:28.171036514Z    at MySqlConnector.MySqlConnection.CreateSessionAsync(ConnectionPool pool, Int32 startTickCount, Nullable`1 ioBehavior, CancellationToken cancellationToken) in /_/src/MySqlConnector/MySqlConnection.cs:line 926
2023-12-18T14:10:28.171040563Z    at MySqlConnector.MySqlConnection.OpenAsync(Nullable`1 ioBehavior, CancellationToken cancellationToken) in /_/src/MySqlConnector/MySqlConnection.cs:line 406
2023-12-18T14:10:28.171044708Z    at MySqlConnector.MySqlConnection.Open() in /_/src/MySqlConnector/MySqlConnection.cs:line 369
2023-12-18T14:10:28.171048510Z    at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.OpenDbConnection(Boolean errorsExpected)
2023-12-18T14:10:28.171052343Z    at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.OpenInternal(Boolean errorsExpected)
2023-12-18T14:10:28.171056132Z    at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.Open(Boolean errorsExpected)
2023-12-18T14:10:28.171060904Z    at Pomelo.EntityFrameworkCore.MySql.Storage.Internal.MySqlRelationalConnection.Open(Boolean errorsExpected)
2023-12-18T14:10:28.171066023Z    at Pomelo.EntityFrameworkCore.MySql.Storage.Internal.MySqlDatabaseCreator.<>c__DisplayClass18_0.<Exists>b__0(DateTime giveUp)
2023-12-18T14:10:28.171072530Z    at Microsoft.EntityFrameworkCore.ExecutionStrategyExtensions.<>c__DisplayClass12_0`2.<Execute>b__0(DbContext c, TState s)
2023-12-18T14:10:28.171078461Z    at Pomelo.EntityFrameworkCore.MySql.Storage.Internal.MySqlExecutionStrategy.Execute[TState,TResult](TState state, Func`3 operation, Func`3 verifySucceeded)
2023-12-18T14:10:28.171083923Z    --- End of inner exception stack trace ---
2023-12-18T14:10:28.171090228Z    at Pomelo.EntityFrameworkCore.MySql.Storage.Internal.MySqlExecutionStrategy.Execute[TState,TResult](TState state, Func`3 operation, Func`3 verifySucceeded)
2023-12-18T14:10:28.171094636Z    at Microsoft.EntityFrameworkCore.ExecutionStrategyExtensions.Execute[TState,TResult](IExecutionStrategy strategy, TState state, Func`2 operation, Func`2 verifySucceeded)
2023-12-18T14:10:28.171113889Z    at Microsoft.EntityFrameworkCore.ExecutionStrategyExtensions.Execute[TState,TResult](IExecutionStrategy strategy, TState state, Func`2 operation)
2023-12-18T14:10:28.171119115Z    at Pomelo.EntityFrameworkCore.MySql.Storage.Internal.MySqlDatabaseCreator.Exists(Boolean retryOnNotExists)
2023-12-18T14:10:28.171123689Z    at Pomelo.EntityFrameworkCore.MySql.Storage.Internal.MySqlDatabaseCreator.Exists()
2023-12-18T14:10:28.171128281Z    at Microsoft.EntityFrameworkCore.Storage.RelationalDatabaseCreator.EnsureCreated()
2023-12-18T14:10:28.171132414Z    at Microsoft.EntityFrameworkCore.Infrastructure.DatabaseFacade.EnsureCreated()
2023-12-18T14:10:28.171137065Z    at Program.<Main>$(String[] args) in /app/src/Presentation/Program.cs:line 51
2023-12-18T14:10:28.171142364Z    at Program.<Main>(String[] args)
2023-12-18T14:10:29.133267704Z /var/lib/librum-server/srv/run.sh: line 4:     8 Aborted                 (core dumped) dotnet Presentation.dll
2023-12-18T14:10:32.036032690Z Running in selfhosted mode, skipping AzureKeyVault configuration
2023-12-18T14:10:32.841466570Z warn: Microsoft.EntityFrameworkCore.Model.Validation[10400]
2023-12-18T14:10:32.841486282Z       Sensitive data logging is enabled. Log entries and exception messages may include sensitive application data; this mode should only be enabled during development.
2023-12-18T14:10:34.004751031Z warn: Microsoft.AspNetCore.DataProtection.Repositories.FileSystemXmlRepository[60]
2023-12-18T14:10:34.004810682Z       Storing keys in a directory '/var/lib/librum-server/.aspnet/DataProtection-Keys' that may not be persisted outside of the container. Protected data will be unavailable when container is destroyed. For more information go to https://aka.ms/aspnet/dataprotectionwarning
2023-12-18T14:10:34.272113844Z warn: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[35]
2023-12-18T14:10:34.272134146Z       No XML encryptor configured. Key {ae082f8b-1129-4b5f-af1c-a12d930d9fdb} may be persisted to storage in unencrypted form.
2023-12-18T14:10:34.387457646Z warn: Application.BackgroundServices.DeleteUnconfirmedUsers[0]
2023-12-18T14:10:34.387483907Z       Deleting unconfirmed users
2023-12-18T14:10:34.465289044Z warn: Microsoft.AspNetCore.Server.Kestrel[0]
2023-12-18T14:10:34.465314445Z       Overriding address(es) 'http://*:8080'. Binding to endpoints defined via IConfiguration and/or UseKestrel() instead.
2023-12-18T14:10:55.210230684Z warn: Microsoft.AspNetCore.HttpsPolicy.HttpsRedirectionMiddleware[3]
2023-12-18T14:10:55.210260546Z       Failed to determine the https port for redirect.

and if I try to open the webgui I get

This 192.168.1.94 page can’t be found
No webpage was found for the web address: http://192.168.1.94:5678/
HTTP ERROR 404

This is my compose, omv1 is a network I've created that already works fine with other containers:

---
version: "3.8"
services:
  librum:
    image: librum
    hostname: librum
    container_name: librum
    ports:
      - 5678:5000
    networks:
      - omv1
    volumes:
      - /srv/dev-disk-by-uuid-2628F1C228F19153/data/media/books:/var/lib/librum-server/librum_storage
    environment:
      - JWTValidIssuer=exampleIssuer
      - JWTKey=exampleOfALongSecretToken
      - SMTPEndpoint=smtp.XXXXX.com
      - SMTPUsername=XXXXXXXXXXXXXX
      - SMTPPassword=XXXXXXXXXXXXX
      - SMTPMailFrom=XXXXXXXXXXXXXXX
      - DBConnectionString=Server=mariadb;port=3306;Database=librum;Uid=librum;Pwd=mariadb;
      - AdminEmail=XXXXXXXXXXXXX
      - AdminPassword=XXXXXXXXXXX
    restart: unless-stopped
    depends_on:
      - librum_db

  librum_db:
    image: mariadb:latest
    hostname: mariadb
    container_name: librum_db
    networks:
      - omv1
    volumes:
      - /srv/dev-disk-by-uuid-5b67514d-485e-4306-873e-b1cbb54ccf99/Config/librum/librum_db:/var/lib/mysql
    environment:
      - MARIADB_USER=librum
      - MARIADB_PASSWORD=mariadb
      - MARIADB_DATABASE=librum
      - MARIADB_ROOT_PASSWORD=mariadb
    restart: unless-stopped

# networks:
#  librum:
#    name: "librum"

# networks:
#  omv1:
networks:
  omv1:
    external: true   

volumes:
  librum:
    name: "books"
  librum_db:
    name: "librum_db"

Also, what is JWT key in the compose? Should I use it? Comment it? What is it for?

According to the error, it failed when connecting to the database:

An error occurred using the connection to database '' on server 'mariadb'.

Apparently, it's not picking it up from the environment variable. Has it been changed in any way?

No, all you see is all I did: build image, adapt compose with what you see, deploy stack from Portainer. No ENV touched by me.

I'm asking about the project in general. Seeing as it has been updated to use a newer version of .NET without updating the Dockerfile, maybe the DBString was updated as well, causing the error.

According to the error, it failed when connecting to the database:

An error occurred using the connection to database '' on server 'mariadb'.

Apparently, it's not picking it up from the environment variable. Has it been changed in any way?

I don't think anything changed there.

I had the same issue, running the example docker-compose.yml

Same issue. Appeared after updating to the latest version. I tried toying with the env variables, different formatting and such but nothing solved it.

I checked the DB itself and it appears to be populated correctly. However, I cannot go any further in order to determine if the error message causes actual problems because of issue #20 .

mariadb -h 127.0.0.1 -u librum -pmariadb librum

MariaDB [librum]> show tables;
+------------------+
| Tables_in_librum |
+------------------+
| AspNetRoleClaims |
| AspNetRoles      |
| AspNetUserClaims |
| AspNetUserLogins |
| AspNetUserRoles  |
| AspNetUserTokens |
| AspNetUsers      |
| Bookmarks        |
| Books            |
| Highlights       |
| RectF            |
| Tags             |
+------------------+
12 rows in set (0.000 sec)

I sadly don't have a lot of experience with docker. @tralph3 @tbabej @3036662 might know more here since they have setup the docker stuff

I think this issue should be closed as the original one was resolved. The following database connection issue should be a separate issue anyway.

That being said, I don't think it's an actual issue. A fresh setup continues to give this error and I think it's a simple timing issue. The librum-server container initializes before the db container and shoots the error. Once the db container is up, librum-server continues as normal. I think a simple heartbeat on the db container should fix the problem.