You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to integrate sharp with bun and Alpine linux, but I am constantly running into runtime errors, when trying to actually run the container. My first goal is to get it running at all. The endgame should be to get it building for x64 as well as arm
The development environment is Ubuntu 22.04 running inside WSL2. Here's the redacted dockerfile, without the authentication biuts and bobs on our private registry:
FROM oven/bun:alpine AS build-stage
WORKDIR /app
COPY package.json ./
COPY bun.lockb ./
RUN bun install
# manually installing this makes no difference# RUN bun install @img/sharp-linuxmusl-x64 @img/sharp-libvips-linuxmusl-x64
COPY ..
RUN bun build.ts
FROM oven/bun:alpine AS runtime-stage
RUN apk update && apk upgrade
RUN mkdir -p /usr/src/app
# Create a group named appusers and add a user called app to it.
RUN addgroup -S appusers && adduser -S app -G appusers
RUN chown -R app:appusers /usr/src/app
RUN mkdir -p /home/app
RUN chown -R app:appusers /home/app
COPY --from=build-stage /app/dist /usr/src/app
# not copying this yields in # ERR_DLOPEN_FAILED: Error loading shared library libvips-cpp.so.42: No such file or directory (needed by /home/app/.bun/install/cache/@img/[email protected]@@@1/lib/sharp-linuxmusl-x64.node)
COPY --from=build-stage /app/node_modules/sharp /usr/src/app/node_modules/sharp
COPY --from=build-stage /app/node_modules/semver /usr/src/app/node_modules/semver
USER app
WORKDIR /usr/src/app
COPY --chown=app:appusers package.json ./
EXPOSE 4000
CMD [ "bun" ,"run", "main.js" ]
Any combination I try, it always resolves in an error not being able to find libvips-cpp.so.42 or not being able to load sharp using teh linuxmusl-x64 runtime.
What am I doing wrong here?
The text was updated successfully, but these errors were encountered:
It looks like you're selectively copying only a couple of dependencies from the node_modules created during build-stage to the runtime-stage. You'll probably want to copy all the dependencies, something like:
Copying the whole node_modules folder is a bit of overkill, isn't ? The whole application is 116 MB (inlcuding sharp + deps) in size, while the node_modules folder sits at 294 MB. This is all the copying that's required to make it work:
The following will remove devDependencies and peerDependencies that are presumably not required at runtime. This should be lower maintenance than selectively copying dependencies.
UPDATE
Repo to reproduce: https://github.com/marcoheinrich-sii/sharp-bun-error-demo
I am trying to integrate sharp with bun and Alpine linux, but I am constantly running into runtime errors, when trying to actually run the container. My first goal is to get it running at all. The endgame should be to get it building for x64 as well as arm
The development environment is Ubuntu 22.04 running inside WSL2. Here's the redacted dockerfile, without the authentication biuts and bobs on our private registry:
build.ts
Any combination I try, it always resolves in an error not being able to find libvips-cpp.so.42 or not being able to load sharp using teh linuxmusl-x64 runtime.
What am I doing wrong here?
The text was updated successfully, but these errors were encountered: