Librum-Reader / Librum-Server

The Librum server
https://librumreader.com
GNU Affero General Public License v3.0
301 stars 22 forks source link

Add a Docker image #9

Closed tralph3 closed 1 year ago

tralph3 commented 1 year ago

Hi. It's great to see you have implemented the possibility of self-hosting the server. However, most people use docker containers to self-host their services, since it allows them to run multiple services on the same host without needing to worry about version conflicts for the dependencies of each program, and it improves security by having each service isolated from one another.

The LibrumServer would need to be modified to allow to connect to a remote database (which is usually running on a container of its own).

A Docker container would also tremendously streamline the installation process, which is quite convoluted in its current state.

DavidLazarescu commented 1 year ago

Hey, thank you for your feedback. We are still planning to add a Docker image for Librum-Server, but due to my missing experience with docker and limited time, I was not able to do so yet.

We would happily accept any PRs from the community. Maybe the Docker image can build upon the recently released support for self-hosting Librum as described in the docs, since the MS dependencies do not need to be replaced anymore.

dennis1248 commented 1 year ago

I will give containerizing it a try tomorrow if time allows. It shouldn't be too difficult judging by the installation instructions.

tralph3 commented 1 year ago

I should also add that the HTTPS certificate doesn't need to be handled by Librum, since people usually use reverse proxies that take care of that.

tralph3 commented 1 year ago

Well, I've been trying to make a Dockerfile and I got something somewhat working. I can use the client to connect to the server with the admin account, but I can't create accounts, it errors out saying "An unknown error occurred". This is the server log of the error:

fail: Application.Common.Middleware.ExceptionHandlingMiddleware[0]

      Name or service not known

      System.Net.Sockets.SocketException (00000005, 0xFFFDFFFF): Name or service not known

         at System.Net.Dns.GetHostEntryOrAddressesCore(String hostName, Boolean justAddresses, AddressFamily addressFamily, Int64 startingTimestamp)

         at System.Net.Dns.<>c.<GetHostEntryOrAddressesCoreAsync>b__33_0(Object s, Int64 startingTimestamp)

         at System.Net.Dns.<>c__DisplayClass39_0`1.<RunAsync>b__0(Task <p0>, Object <p1>)

         at System.Threading.Tasks.ContinuationResultTaskFromTask`1.InnerInvoke()

         at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)

      --- End of stack trace from previous location ---

         at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)

         at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)

      --- End of stack trace from previous location ---

         at MailKit.Net.SocketUtils.ConnectAsync(String host, Int32 port, IPEndPoint localEndPoint, CancellationToken cancellationToken)

         at MailKit.Net.SocketUtils.ConnectAsync(String host, Int32 port, IPEndPoint localEndPoint, Int32 timeout, CancellationToken cancellationToken)

         at MailKit.MailService.ConnectNetworkAsync(String host, Int32 port, CancellationToken cancellationToken)

         at MailKit.Net.Smtp.SmtpClient.ConnectAsync(String host, Int32 port, SecureSocketOptions options, CancellationToken cancellationToken)

         at Application.Utility.EmailSender.SendEmail(MimeMessage message) in /app/src/Application/Utility/EmailSender.cs:line 115

         at Application.Utility.EmailSender.SendEmailConfirmationEmail(User user, String token) in /app/src/Application/Utility/EmailSender.cs:line 54

         at Application.Services.AuthenticationService.RegisterUserAsync(RegisterDto registerDto) in /app/src/Application/Services/AuthenticationService.cs:line 75

         at Presentation.Controllers.AuthenticationController.RegisterUser(RegisterDto registerDto) in /app/src/Presentation/Controllers/AuthenticationController.cs:line 30

         at lambda_method316(Closure, Object)

         at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.TaskOfActionResultExecutor.Execute(ActionContext actionContext, IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)

         at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeActionMethodAsync>g__Awaited|12_0(ControllerActionInvoker invoker, ValueTask`1 actionResultValueTask)

         at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeNextActionFilterAsync>g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)

         at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)

         at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)

         at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeInnerFilterAsync>g__Awaited|13_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)

         at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResourceFilter>g__Awaited|25_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)

         at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context)

         at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)

         at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeFilterPipelineAsync>g__Awaited|20_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)

         at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)

         at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)

         at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)

         at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)

         at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)

         at Application.Common.Middleware.ExceptionHandlingMiddleware.InvokeAsync(HttpContext context) in /app/src/Application/Common/Middleware/ExceptionHandlingMiddleware.cs:line 30

It also seems to expect me to have my own e-mail server to send confirmation mails to new users, which I don't have, and I don't intend to have. Is there a way to turn off this behavior? The client crashes when loading the free-books page, but I don't know if that has anything to do with the server.

Despite this, the user is created, and trying to login with it throws an error saying the account hasn't been confirmed yet. I have, of course, no way to do that.

tralph3 commented 1 year ago

We should probably continue the discussion in #10.