microsoft / fhir-server

A service that implements the FHIR standard
MIT License
1.15k stars 491 forks source link

docker compose installation. #3160

Open alessiocamillohome opened 1 year ago

alessiocamillohome commented 1 year ago

Hello everyone, i am trying to install the fhir-api server and database using the docker-compose command and following the instructions report in the documentation (https://github.com/microsoft/fhir-server/tree/main/samples/docker):

Using docker-compose this image can be started with the following steps:
Open a terminal window.
Set the enviornment variable SAPASSWORD to what you want the SQL access password to be. Be sure to follow the [SQL server password complexity requirements](https://docs.microsoft.com/en-us/sql/relational-databases/security/password-policy?view=sql-server-ver15#password-complexity).
Copy & save a local version of the docker-compose file from the release directory of the fhir-server project.
Run the command:
docker-compose up -d .
After giving the container a minute to start up it should be accessable at http://localhost:8080/metadata.

Unfortunately in the Log I have the following error which I think does not start the fhir-api server correctly.

Unhandled exception. System.NullReferenceException: Object reference not set to an instance of an object.
fhir-server-fhir-api-1  |    at System.Lazy`1.CreateValue()
fhir-server-fhir-api-1  |    at Hl7.FhirPath.FhirPathCompiler.get_DefaultSymbolTable()
fhir-server-fhir-api-1  |    at Microsoft.Health.Fhir.Api.Modules.FhirModule.Load(IServiceCollection services) in /repo/src/Microsoft.Health.Fhir.Shared.Api/Modules/FhirModule.cs:line 58
fhir-server-fhir-api-1  |    at Microsoft.Health.Extensions.DependencyInjection.ServiceCollectionExtensions.RegisterModule(IServiceCollection collection, Type moduleType, Object[] constructorParams)
fhir-server-fhir-api-1  |    at Microsoft.Health.Extensions.DependencyInjection.ServiceCollectionExtensions.RegisterAssemblyModules(IServiceCollection collection, Assembly assembly, Object[] constructorParams)
fhir-server-fhir-api-1  |    at Microsoft.Extensions.DependencyInjection.FhirServerServiceCollectionExtensions.AddFhirServer(IServiceCollection services, IConfiguration configurationRoot, Action`1 configureAction) in /repo/src/Microsoft.Health.Fhir.Shared.Api/Registration/FhirServerServiceCollectionExtensions.cs:line 88
fhir-server-fhir-api-1  |    at Microsoft.Health.Fhir.Web.Startup.ConfigureServices(IServiceCollection services) in /repo/src/Microsoft.Health.Fhir.Shared.Web/Startup.cs:line 45
fhir-server-fhir-api-1  |    at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
fhir-server-fhir-api-1  |    at System.Reflection.MethodInvoker.Invoke(Object obj, IntPtr* args, BindingFlags invokeAttr)
fhir-server-fhir-api-1  |    at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
fhir-server-fhir-api-1  |    at Microsoft.AspNetCore.Hosting.ConfigureServicesBuilder.InvokeCore(Object instance, IServiceCollection services)
fhir-server-fhir-api-1  |    at Microsoft.AspNetCore.Hosting.StartupLoader.ConfigureServicesDelegateBuilder`1.<>c__DisplayClass14_0.<ConfigureServices>g__ConfigureServicesWithContainerConfiguration|0(IServiceCollection services)
fhir-server-fhir-api-1  |    at Microsoft.AspNetCore.Hosting.ConventionBasedStartup.ConfigureServices(IServiceCollection services)
fhir-server-fhir-api-1  |    at Microsoft.AspNetCore.Hosting.WebHost.EnsureApplicationServices()
fhir-server-fhir-api-1  |    at Microsoft.AspNetCore.Hosting.WebHost.Initialize()
fhir-server-fhir-api-1  |    at Microsoft.AspNetCore.Hosting.WebHostBuilder.Build()
fhir-server-fhir-api-1  |    at Microsoft.Health.Fhir.Web.Program.Main(String[] args) in /repo/src/Microsoft.Health.Fhir.Shared.Web/Program.cs:line 20

The full docker-compose file:

version: "3"
services:
  fhir-api:
    image: "mcr.microsoft.com/healthcareapis/r4-fhir-server"
    restart: on-failure
    environment:
      FHIRServer__Security__Enabled: "false"
      SqlServer__ConnectionString: "Server=tcp:sql,1433;Initial Catalog=FHIR;Persist Security Info=False;User ID=sa;Password=<SAPASSWORD>;MultipleActiveResultSets=False;Connection Timeout=30;TrustServerCertificate=true;"
      SqlServer__AllowDatabaseCreation: "true"
      SqlServer__Initialize: "true"
      SqlServer__SchemaOptions__AutomaticUpdatesEnabled: "true"
      DataStore: "SqlServer"
    ports:     
      - "8080:8080"
    depends_on:
      - sql
  sql:
    image: "mcr.microsoft.com/mssql/server"
    environment:
      SA_PASSWORD: <SAPASSWORD>
      ACCEPT_EULA: "Y"
    healthcheck:
        test: ["CMD", "/opt/mssql-tools/bin/sqlcmd","-U sa -P <SAPASSWORD> -Q 'SELECT * FROM INFORMATION_SCHEMA.TABLES'"]
        interval: 10s
        timeout: 10s
        retries: 6

My working environment is a Macbook M1 Pro with macOS Ventura 13.2.1. The version of Docker is 20.10.23 (with Use Virtualization framework and Use Rosetta for x86/amd64 emulation on Apple Silicon checked) Is this environment supported for this version of the fhir server?

Thanks for your support.

EXPEkesheth commented 1 year ago

@alessiocamillohome , thanks for reporting the issue. We will investigate the issue.

EXPEkesheth commented 1 year ago

AB#101532

abiisnn commented 1 year ago

Would you mind sharing the command you used to see the logs?

shabanlushaj commented 1 year ago

It's not related at all but docker sample needs to be updated: Connection string misses TrustServerCertificate=true property which causes System.Security.Authentication.AuthenticationException: The remote certificate was rejected by the provided RemoteCertificateValidationCallback. (docker-compose file has it).

https://github.com/microsoft/fhir-server/tree/main/samples/docker#:~:text=%22%20%2De-,SqlServer__ConnectionString,-%3D%22Server

ayoubbensakhria commented 1 year ago

Works fine for me Ubuntu 20.04: SAPASSWORD has to meet the SQL Server password policy requirements.