I encounter a problem since Bun 1.3.
When running on the container, I get the error 'Cannot find package 'date-fns' from '/usr/src/app/test.ts''
Considering test.ts being:
import { formatDuration, milliseconds } from "date-fns";
const pingDuration = { seconds: 1 };
console.log(`ping every ${formatDuration(pingDuration)}`);
while (true) {
await Bun.sleep(milliseconds(pingDuration));
console.log('pong');
}
and my docker file being:
# use the official Bun image
# see all versions at https://hub.docker.com/r/oven/bun/tags
FROM oven/bun:1.3 AS base
WORKDIR /usr/src/app
# install dependencies into temp directory
# install with --production (exclude devDependencies)
FROM base AS install
RUN mkdir -p /temp/prod
COPY package.json bun.lock /temp/prod/
COPY /packages/package-1/package.json /temp/prod/packages/package-1/
COPY /packages/package-2/package.json /temp/prod/packages/package-2/
RUN cd /temp/prod && bun ci --production
# copy production dependencies and source code into final image
FROM base AS release
COPY --from=install /temp/prod/node_modules node_modules
# COPY packages/package-1/index.ts .
# COPY packages/package-1/src src
COPY packages/package-1/test.ts .
# run the app
USER bun
EXPOSE 3000/tcp
ENTRYPOINT [ "bun", "run", "test.ts" ]
My project is a workspace with two packages.
The exact same definition works on 1.2