Trying to dockerize a Bun app, I faced those 3 following issues when running my container:
bun-app-1 | error: Cannot find module "@node-rs/argon2-wasm32-wasi" from "/app/node_modules/@node-rs/argon2/index.js"
bun-app-1 | error: Cannot find module "@node-rs/bcrypt-wasm32-wasi" from "/app/node_modules/@node-rs/bcrypt/binding.js"
bun-app-1 | error: Cannot find module "@node-rs/argon2-linux-arm64-gnu" from "/app/node_modules/@node-rs/argon2/index.js"
bun-app-1 exited with code 1
Locally, everything works fine (bun run src/index.tsx
in my terminal). The moment I try to run this with Docker, it crashes.
I’m newbie with Docker so I’m not sure if this error is related to my docker config. Don’t hesitate to correct me on this point or guide me in a better way to track issues (I know that bcrypt and argon2 are related to oslo, which is recommended to use with lucia).
Here below are my docker-compose and dockerfiles:
docker-compose.yml
version: '3'
services:
bun-app:
image: oven/bun:1.0.25-slim
build:
context: .
dockerfile: Dockerfile.dev
volumes:
- ./:/app
- /app/node_modules
ports:
- 3000:3000
env_file:
- ./.env
Dockerfile.dev
# syntax=docker/dockerfile:1
ARG BUN_VERSION=1.0.25-slim
FROM oven/bun:${BUN_VERSION} as base
LABEL fly_launch_runtime="Bun"
WORKDIR /app
# Set production environment
ENV NODE_ENV="development"
ENV PORT 3000
EXPOSE $PORT
COPY package.json bun.lockb ./
FROM base AS development
RUN bun install
COPY . .
CMD ["bun", "run", "src/index.tsx"]
Dockerfile.prod
# syntax=docker/dockerfile:1
# Adjust BUN_VERSION as desired
ARG BUN_VERSION=1.0.25-slim
FROM oven/bun:${BUN_VERSION} as base
LABEL fly_launch_runtime="Bun"
WORKDIR /app
COPY package.json bun.lockb ./
# Set production environment
ENV NODE_ENV="production"
FROM base AS build
RUN apt-get update -qq &&
apt-get install --no-install-recommends -y build-essential node-gyp pkg-config python-is-python3 ;
# Install node modules
COPY --link bun.lockb package.json ./
RUN bun install --ci
# Copy application code
COPY --link . .
# Final stage for app image
FROM base
# Copy built application
COPY --from=build /app /app
ENV PORT 3000
EXPOSE $PORT
CMD ["bun", "run", "src/index.tsx"]
yamakasi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.