isar icon indicating copy to clipboard operation
isar copied to clipboard

Running in Docker container struggles to find libisar.so

Open jackstefansky opened this issue 2 years ago • 7 comments

Hey, I'm using isar in my dart project and everything works as expected regarding to initializing isar core on windows. The only issue happens when I try building the app and dockerize it. It looks like the isar lib cannot be loaded or localized. I even tested if the lib file is being downloaded correctly and it is:

Code sample

Future<void> init(InternetAddress ip, int port) async {
  print(Platform.operatingSystemVersion);

  try {
    await Isar.initializeIsarCore(download: true);
  } catch (e) {
    print(e);
  }

  final isarlib = File('/app/bin/libisar.so');

  print('isar lib exists: ${isarlib.existsSync()}');
  
  ...

Output

Linux 5.10.16.3-microsoft-standard-WSL2 #1 SMP Fri Apr 2 22:23:49 UTC 2021
Invalid argument(s): Failed to load dynamic library '/app/bin/libisar.so': libgcc_s.so.1: cannot open shared object file: No such file or directory
isar lib exists: true
Unhandled exception:
Invalid argument(s): Failed to load dynamic library '/app/bin/libisar.so': libgcc_s.so.1: cannot open shared object file: No such file or directory
#0      _open (dart:ffi-patch/ffi_dynamic_library_patch.dart:11)
#1      new DynamicLibrary.open (dart:ffi-patch/ffi_dynamic_library_patch.dart:22)
#2      _initializePath (package:isar/src/native/isar_core.dart:92)
#3      initializeCoreBinary (package:isar/src/native/isar_core.dart:75)
#4      openIsar (package:isar/src/native/open.dart:81)
#5      Isar.open (package:isar/src/isar.dart:107)
#6      init (file:///app/main.dart:22)
<asynchronous suspension>
#7      main (file:///app/bin/server.dart:42)
<asynchronous suspension

cannot open shared object file: No such file or directory

How is that possible? I manually checked if the file is there. I even tried to copy it to the container in docker-compose but the outcome is the same: File is there, but No such file or directory :/

Details

  • Platform: Docker ( Linux 5.10.16.3-microsoft-standard-WSL2 )
  • Dart version: 3.0.2
  • Isar version: 3.1.0+1

  • [x] I searched for similar issues already
  • [x] I filled the details section with the exact device model and version
  • [x] I am able to provide a reproducible example

jackstefansky avatar Oct 15 '23 20:10 jackstefansky

I am having the same issue.

I am using dart_frog and it works fine when I use dart_frog dev.

When I build, create docker image and run it then I get the following error:

Details

2024-01-08 11:49:51 Unhandled exception: 2024-01-08 11:49:51 Invalid argument(s): Failed to load dynamic library '/app/bin/libisar.so': libgcc_s.so.1: cannot open shared object file: No such file or directory 2024-01-08 11:49:51 #0 _open (dart:ffi-patch/ffi_dynamic_library_patch.dart:11) 2024-01-08 11:49:51 #1 new DynamicLibrary.open (dart:ffi-patch/ffi_dynamic_library_patch.dart:22) 2024-01-08 11:49:51 #2 _initializePath (package:isar/src/native/isar_core.dart:92) 2024-01-08 11:49:51 #3 initializeCoreBinary. (package:isar/src/native/isar_core.dart:71) 2024-01-08 11:49:51 2024-01-08 11:49:51 #4 Isar.initializeIsarCore (package:isar/src/isar.dart:309) 2024-01-08 11:49:51 2024-01-08 11:49:01 directory: Directory: '//isar_storage_dont_edit' 2024-01-08 11:49:51 directory: Directory: '//isar_storage_dont_edit' 2024-01-08 11:49:51 #5 IsarDB.initDatabase (package:my_api/storage/isar_db.dart:29) 2024-01-08 11:49:51 2024-01-08 11:49:51 #6 init (file:///app/main.dart:9) 2024-01-08 11:49:51 2024-01-08 11:49:51 #7 main (file:///app/bin/server.dart:23) 2024-01-08 11:49:51

TristanGrobler avatar Jan 08 '24 19:01 TristanGrobler

Try : RUN apt-get update & apt-get install -y gcc-multilib libgcc1

rafagazani avatar Apr 17 '24 05:04 rafagazani

Try : RUN apt-get update & apt-get install -y gcc-multilib libgcc1

Would that be as part of the docker file or where would that be inserted?

TristanGrobler avatar Apr 18 '24 12:04 TristanGrobler

Dockerfile:

FROM dart:3.2.0-sdk AS build

RUN apt-get update && apt-get install -y
gcc-multilib
libgcc1

WORKDIR /app COPY pubspec.* ./ RUN dart pub get

COPY . . RUN dart compile exe bin/server.dart -o bin/server

FROM ubuntu COPY --from=build /app/bin/server /app/bin/ COPY --from=build /app/bin/libisar.so /app/bin/

EXPOSE 8080 CMD ["/app/bin/server"]

rafagazani avatar Apr 19 '24 13:04 rafagazani

The scratch image does not have the minimum requirements to run ISAR

rafagazani avatar Apr 19 '24 13:04 rafagazani

One bad point is that ISAR may not work in all scenarios. For example, it worked on my local wsl, but when I took it to azure, it didn't work. https://github.com/isar/isar/issues/1299 My best choice was to remove it from my project. I would love to use it, but I don't think now is the time.

rafagazani avatar Apr 19 '24 13:04 rafagazani

(Thank you @danilosouza-linxsetadigital for Dockerfile)

rafagazani avatar Apr 19 '24 13:04 rafagazani