eclipse-aaspe / server

C# based server for AASX packages
Other
72 stars 52 forks source link

[Bug]: Docker container fails to start when "--with-db" is set #343

Open de-ich opened 3 months ago

de-ich commented 3 months ago

Describe the bug

When using the "--with-db" option, the server fails to start and logs the following error message:

2024-08-19 09:26:13 aasx-server  | args:
2024-08-19 09:26:13 aasx-server  | --no-security
2024-08-19 09:26:13 aasx-server  | --with-db
2024-08-19 09:26:13 aasx-server  | --start-index
2024-08-19 09:26:13 aasx-server  | 0
2024-08-19 09:26:13 aasx-server  | --aasx-in-memory
2024-08-19 09:26:13 aasx-server  | 100
2024-08-19 09:26:13 aasx-server  | --data-path
2024-08-19 09:26:13 aasx-server  | /usr/share/aasxs
2024-08-19 09:26:13 aasx-server  | --external-blazor
2024-08-19 09:26:13 aasx-server  | http://localhost:5001
2024-08-19 09:26:13 aasx-server  | 
2024-08-19 09:26:13 aasx-server  | Serving the AASXs from: /usr/share/aasxs
2024-08-19 09:26:13 aasx-server  | Security 1 Startup - Server
2024-08-19 09:26:13 aasx-server  | Security 1.1 Load X509 Root Certificates into X509 Store Root
2024-08-19 09:26:13 aasx-server  | Use SQLITE
2024-08-19 09:26:14 aasx-server  | Unhandled exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
2024-08-19 09:26:14 aasx-server  |  ---> System.AggregateException: One or more errors occurred. (SQLite Error 1: 'no such table: __EFMigrationsHistory'.)
2024-08-19 09:26:14 aasx-server  |  ---> Microsoft.Data.Sqlite.SqliteException (0x80004005): SQLite Error 1: 'no such table: __EFMigrationsHistory'.
2024-08-19 09:26:14 aasx-server  |    at Microsoft.Data.Sqlite.SqliteException.ThrowExceptionForRC(Int32 rc, sqlite3 db)
2024-08-19 09:26:14 aasx-server  |    at Microsoft.Data.Sqlite.SqliteCommand.PrepareAndEnumerateStatements()+MoveNext()
2024-08-19 09:26:14 aasx-server  |    at Microsoft.Data.Sqlite.SqliteCommand.GetStatements()+MoveNext()
2024-08-19 09:26:14 aasx-server  |    at Microsoft.Data.Sqlite.SqliteDataReader.NextResult()
2024-08-19 09:26:14 aasx-server  |    at Microsoft.Data.Sqlite.SqliteCommand.ExecuteReader(CommandBehavior behavior)
2024-08-19 09:26:14 aasx-server  |    at Microsoft.Data.Sqlite.SqliteCommand.ExecuteReader()
2024-08-19 09:26:14 aasx-server  |    at Microsoft.Data.Sqlite.SqliteCommand.ExecuteNonQuery()
2024-08-19 09:26:14 aasx-server  |    at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteNonQuery(RelationalCommandParameterObject parameterObject)
2024-08-19 09:26:14 aasx-server  |    at Microsoft.EntityFrameworkCore.Migrations.MigrationCommand.ExecuteNonQuery(IRelationalConnection connection, IReadOnlyDictionary`2 parameterValues)
2024-08-19 09:26:14 aasx-server  |    at Microsoft.EntityFrameworkCore.Migrations.Internal.MigrationCommandExecutor.ExecuteNonQuery(IEnumerable`1 migrationCommands, IRelationalConnection connection)
2024-08-19 09:26:14 aasx-server  |    at Microsoft.EntityFrameworkCore.Migrations.Internal.Migrator.Migrate(String targetMigration)
2024-08-19 09:26:14 aasx-server  |    at Microsoft.EntityFrameworkCore.RelationalDatabaseFacadeExtensions.Migrate(DatabaseFacade databaseFacade)
2024-08-19 09:26:14 aasx-server  |    at AasxServer.Program.Run(CommandLineArguments a) in /repo/src/AasxServerStandardBib/Program.cs:line 749
2024-08-19 09:26:14 aasx-server  |    --- End of inner exception stack trace ---
2024-08-19 09:26:14 aasx-server  |    at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
2024-08-19 09:26:14 aasx-server  |    at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
2024-08-19 09:26:14 aasx-server  |    at System.Threading.Tasks.Task.Wait()
2024-08-19 09:26:14 aasx-server  |    at AasxServer.Program.<>c.<Main>b__65_0(CommandLineArguments a) in /repo/src/AasxServerStandardBib/Program.cs:line 1226
2024-08-19 09:26:14 aasx-server  |    at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
2024-08-19 09:26:14 aasx-server  |    at System.Reflection.MethodBaseInvoker.InvokeDirectByRefWithFewArgs(Object obj, Span`1 copyOfArgs, BindingFlags invokeAttr)
2024-08-19 09:26:14 aasx-server  |    --- End of inner exception stack trace ---
2024-08-19 09:26:14 aasx-server  |    at System.Reflection.MethodBaseInvoker.InvokeDirectByRefWithFewArgs(Object obj, Span`1 copyOfArgs, BindingFlags invokeAttr)
2024-08-19 09:26:14 aasx-server  |    at System.Reflection.MethodBaseInvoker.InvokeWithOneArg(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
2024-08-19 09:26:14 aasx-server  |    at System.Delegate.DynamicInvokeImpl(Object[] args)
2024-08-19 09:26:14 aasx-server  |    at System.CommandLine.Invocation.ModelBindingCommandHandler.InvokeAsync(InvocationContext context)
2024-08-19 09:26:14 aasx-server  |    at System.CommandLine.Invocation.InvocationPipeline.<>c__DisplayClass4_0.<<BuildInvocationChain>b__0>d.MoveNext()
2024-08-19 09:26:14 aasx-server  | --- End of stack trace from previous location ---
2024-08-19 09:26:14 aasx-server  |    at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c.<<UseParseErrorReporting>b__21_0>d.MoveNext()
2024-08-19 09:26:14 aasx-server  | --- End of stack trace from previous location ---
2024-08-19 09:26:14 aasx-server  |    at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass16_0.<<UseHelp>b__0>d.MoveNext()
2024-08-19 09:26:14 aasx-server  | --- End of stack trace from previous location ---
2024-08-19 09:26:14 aasx-server  |    at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass25_0.<<UseVersionOption>b__0>d.MoveNext()
2024-08-19 09:26:14 aasx-server  | --- End of stack trace from previous location ---
2024-08-19 09:26:14 aasx-server  |    at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass23_0.<<UseTypoCorrections>b__0>d.MoveNext()
2024-08-19 09:26:14 aasx-server  | --- End of stack trace from previous location ---
2024-08-19 09:26:14 aasx-server  |    at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c.<<UseSuggestDirective>b__22_0>d.MoveNext()
2024-08-19 09:26:14 aasx-server  | --- End of stack trace from previous location ---
2024-08-19 09:26:14 aasx-server  |    at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c.<<UseParseDirective>b__20_0>d.MoveNext()
2024-08-19 09:26:14 aasx-server  | --- End of stack trace from previous location ---
2024-08-19 09:26:14 aasx-server  |    at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c.<<UseDebugDirective>b__11_0>d.MoveNext()
2024-08-19 09:26:14 aasx-server  | --- End of stack trace from previous location ---
2024-08-19 09:26:14 aasx-server  |    at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c.<<RegisterWithDotnetSuggest>b__10_0>d.MoveNext()
2024-08-19 09:26:14 aasx-server  | --- End of stack trace from previous location ---
2024-08-19 09:26:14 aasx-server  |    at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass14_0.<<UseExceptionHandler>b__0>d.MoveNext()

To reproduce

I used the following docker-compose file:

services:
  aasx-server:
    container_name: aasx-server
    image: docker.io/adminshellio/aasx-server-blazor-for-demo:main
    restart: unless-stopped
    ports:
      - 5001:5001
    environment:
      - Kestrel__Endpoints__Http__Url=http://*:5001
    volumes:
      - ./sample-aasx:/usr/share/aasxs
    entrypoint: dotnet AasxServerBlazor.dll
    command: --no-security --with-db --start-index 0 --aasx-in-memory 100 --data-path /usr/share/aasxs --external-blazor http://localhost:5001 

Running docker-compose up -d will produce the above error message. The same error message is thrown with the current alpha version of the docker images (0.3.1.104-aasv3-alpha-latest).

Expected Behaviour

The server starts correctly - same as when the --with-db option is not set.

Version

0.3.1.104-aasv3-alpha-latest

MichaelHoffmeisterFesto commented 3 weeks ago

I can reproduce the bug.