Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to run on oven/bun:distroless docker image #1558

Open
jamiehaywood opened this issue Jul 15, 2024 · 4 comments
Open

Unable to run on oven/bun:distroless docker image #1558

jamiehaywood opened this issue Jul 15, 2024 · 4 comments

Comments

@jamiehaywood
Copy link

When I try and run a libsql on a Bun distroless image I get an error: TypeError: libgcc_s.so.1: cannot open shared object file: No such file or directory

I assume that the distroless is missing some native binaries that libsql relies on?

Minimal repro:

index.ts

import { drizzle } from "drizzle-orm/libsql";
import { createClient } from "@libsql/client";
import * as schema from "./schema";

const client = createClient({
  url: `file:${__dirname}/sqlite.db`,
});

const db = drizzle<typeof schema>(client, { schema });

const res = await db.select().from(schema.books);

console.log(res);

drizzle.config.ts

import { defineConfig } from "drizzle-kit";

export default defineConfig({
  dialect: "sqlite",

  schema: "./schema.ts",
  out: "./drizzle",

  dbCredentials: {
    url: "sqlite.db",
  },
});

schema.ts

import { sqliteTable, text } from "drizzle-orm/sqlite-core";

const books = sqliteTable("books", {
  id: text("id").notNull().primaryKey(),
  title: text("title").notNull(),
  description: text("description"),
});

export { books };

Dockerfile

FROM oven/bun:distroless
COPY dist .
ENTRYPOINT ["bun", "./index.js"]
  1. Run bun build index.ts --outdir dist --target bun
  2. Run docker build . -t repro
  3. Run docker run -p 8080:8080 test
@jamiehaywood
Copy link
Author

Update: works using the oven/bun:latest image.

Would be ideal if we could run distroless as it halves the final docker image size.

@flexchar
Copy link

I would say it's not libsql issue but rather that the base image is missing the module. It is therefore your responsibility to provide the modules, especially when using the skinniest docker image variations, for what you would like to run - in this case sqld.

So this could be closed. :)

@jamiehaywood
Copy link
Author

thanks for your reply @flexchar - how do you know that sqld is the missing module?

@flexchar
Copy link

flexchar commented Aug 5, 2024

The error you shared in the first paragraph tells us exactly that - that libgcc_s.so.1 is missing.

I have been tinkering with docker for several years and I stumbled upon issues like that more than I would wish anyone :D.

Upon googling, I find this https://pkgs.alpinelinux.org/package/edge/main/x86_64/libgcc

So I would suggest to install this package and try again. You can do so by adding RUN apk install -y libgcc to your Dockerfile. Let me know if that helps!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants