oven-sh / bun

Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one
https://bun.sh
Other
73.48k stars 2.71k forks source link

Fastify app running on Bun Killed after deploying to Docker #6729

Open jsoneaday opened 11 months ago

jsoneaday commented 11 months ago

What version of Bun is running?

1.0.7

What platform is your computer?

Darwin 23.0.0 arm64 arm

What steps can reproduce the bug?

I have a full repo here, https://github.com/jsoneaday/build-servers-with-bun-fastify

  1. Build a Fastify server that uses Prisma
  2. Setup Dockerfile like this: FROM ubuntu:20.04 RUN apt-get update && apt-get install -y \ curl \ && rm -rf /var/lib/apt/lists/* RUN curl -sL https://deb.nodesource.com/setup_20.x | bash - RUN apt-get install -y nodejs RUN apt-get install unzip RUN npm install -g bun COPY package.json ./ COPY bun.lockb ./ COPY prisma ./prisma COPY src ./ RUN bun install --force RUN bun install -g prisma@5.5.2 CMD bun prisma generate;bun ./index.ts
  3. Also needs docker-compose.yml: version: "3.4"

services: db: image: postgres:14.0 volumes:

What is the expected behavior?

Server should come up and not be Killed

What do you see instead?

In Docker console of routes-webserver-1 I see this

2023-10-26 08:02:18 Prisma schema loaded from prisma/schema.prisma 2023-10-26 08:02:19 2023-10-26 08:02:19 ✔ Generated Prisma Client (v5.5.2) to ./node_modules/@prisma/client in 243ms 2023-10-26 08:02:19 2023-10-26 08:02:19 Start using Prisma Client in Node.js (See: https://pris.ly/d/client) 2023-10-26 08:02:19 2023-10-26 08:02:19 import { PrismaClient } from '@prisma/client' 2023-10-26 08:02:19 const prisma = new PrismaClient() 2023-10-26 08:02:19 2023-10-26 08:02:19 or start using Prisma Client at the edge (See: https://pris.ly/d/accelerate) 2023-10-26 08:02:19 2023-10-26 08:02:19 import { PrismaClient } from '@prisma/client/edge' 2023-10-26 08:02:19 const prisma = new PrismaClient() 2023-10-26 08:02:19 2023-10-26 08:02:19 2023-10-26 08:02:19 See other ways of importing Prisma Client: http://pris.ly/d/importing-client 2023-10-26 08:02:19 2023-10-26 08:02:20 {"level":30,"time":1698321740562,"pid":52,"hostname":"7b1140954c5b","msg":"Server listening at http://0.0.0.0:4000"} 2023-10-26 08:02:20 {"level":30,"time":1698321740564,"pid":52,"hostname":"7b1140954c5b","msg":"Let's go!"} 2023-10-26 08:02:35 Killed

Additional information

The entire repo can be found here https://github.com/jsoneaday/build-servers-with-bun-fastify

jsoneaday commented 11 months ago

This issue seems to be related to Prisma running. I tried to remove the impact of Prisma by pre-generating the client files and then deploying docker but app is still killed. However if I remove Prisma entirely app will live. Here's my latest dockerfile.

FROM oven/bun:1.0.7

COPY package.json ./ COPY bun.lockb ./ COPY prisma ./prisma COPY src ./src

RUN bun install CMD bun ./src/index.ts

Also my docker settings:

Screenshot 2023-10-27 at 8 14 37 AM