a year ago
Hey there,
I've deployed a few apps using the T3 stack running on Bun (so Bun + Prisma + NextJS) and after setting it up they've run on Railway without a problem. So I was a little surprised that I ran into a missing libssl problem when without the NextJS. I looked around and tried most of the solutions I found, short for setting up a custom Dockerfile as I think it shouldn't be needed.
My most recent failing attempt looks like this:-
Prisma
5.18.0(I changed it to the same as the one that works with my NextJS app. The latest at time of writing is5.19.1)
No
nixpacks.tomlas it gave me the same result as settingNIXPACKS_LIBS=openssl
Environment variables
NIXPACKS_LIBS=openssl...
prisma/schema.prismagenerator client { provider = "prisma-client-js" binaryTargets = ["native", "debian-openssl-1.1.x", "debian-openssl-3.0.x"] } datasource db { provider = "postgresql" url = env("DATABASE_URL") } // ...railway.json(comments aren't in the actual file; also copied over from a working NextJS deploy and modified){ "$schema": "https://railway.app/railway.schema.json", "build": { "builder": "NIXPACKS", "nixpacksVersion": "1.26.0", // tried to use the nixpacksVersion that works with // my NextJS deploys "buildCommand": "bun install && bun run prisma migrate deploy" // I see I double-run bun install after the nixpacks // install step but don't think it's the problem }, "deploy": { "startCommand": "bun run start" } }
Relevant parts of build logs:
context: 67fdae95f64c32489a3547b3b05691cd
╔═════════════════════ Nixpacks v1.26.0 ════════════════════╗
║ setup │ nodejs_18, bun, openssl ║
║───────────────────────────────────────────────────────────║
║ install │ bun i --no-save ║
║───────────────────────────────────────────────────────────║
║ build │ bun install && bun run prisma migrate deploy ║
║───────────────────────────────────────────────────────────║
║ start │ bun run start ║
╚═══════════════════════════════════════════════════════════╝
[...]
#5 [stage-0 1/10] FROM ghcr.io/railwayapp/nixpacks:ubuntu-1722297819@sha256:91bbbdf4bf734a471738c36a57b5ba191e5c81ad1d0e9d60d70da2d318639eb8
#5 resolve ghcr.io/railwayapp/nixpacks:ubuntu-1722297819@sha256:91bbbdf4bf734a471738c36a57b5ba191e5c81ad1d0e9d60d70da2d318639eb8 done
[...]
#8 24.23 /nix/store/gp504m4dvw5k2pdx6pccf1km79fkcwgf-openssl-3.0.13
#8 24.23 /nix/store/qannz09m66qpcy3ny1f4nkl4ql0g71ks-openssl-3.0.13-bin
#8 24.23 /nix/store/191vca5vdxdlr32k2hpzd66mic98930f-openssl-3.0.13-dev
#8 24.23 /nix/store/sss9pw9l1prvc0a1b01ycrn0xwxxvh3x-openssl-3.0.13-man
#8 24.24 copying path '/nix/store/sss9pw9l1prvc0a1b01ycrn0xwxxvh3x-openssl-3.0.13-man' from 'https://cache.nixos.org';...
#8 24.96 copying path '/nix/store/gp504m4dvw5k2pdx6pccf1km79fkcwgf-openssl-3.0.13' from 'https://cache.nixos.org';...
#8 25.15 copying path '/nix/store/qannz09m66qpcy3ny1f4nkl4ql0g71ks-openssl-3.0.13-bin' from 'https://cache.nixos.org';...
#8 25.19 copying path '/nix/store/191vca5vdxdlr32k2hpzd66mic98930f-openssl-3.0.13-dev' from 'https://cache.nixos.org';...
[...]
#12 [stage-0 8/10] RUN --mount=type=cache,id=s/63ed19a2-75ed-4ae1-8529-6dcec8a0bc5b-node_modules/cache,target=/app/node_modules/.cache bun install && bun run prisma migrate deploy
#12 0.307 bun install v1.1.9 (bb13798d)
#12 0.311
#12 0.311 Checked 36 installs across 37 packages (no changes) [7.00ms]
#12 0.925 Prisma schema loaded from prisma/schema.prisma
#12 0.928 Datasource "db": PostgreSQL database "railway", schema "public" at "autorack.proxy.rlwy.net:53198"
#12 0.943
#12 0.943 Error: Schema engine error:
#12 0.943
#12 0.953 error: "prisma" exited with code 1
#12 ERROR: process "/bin/bash -ol pipefail -c bun install && bun run prisma migrate deploy" did not complete successfully: exit code: 1I got the empty error issue.
If I remove NIXPACKS_LIB=openssl, then the build succeeds, but the runtime throws this error pretty immediately, causing a reboot loop and eventually a crash.
$ bun run // some .ts file that calls `new PrismaClient()` //
// minified prisma code removed
PrismaClientInitializationError: Unable to require(`/app/node_modules/.prisma/client/libquery_engine-debian-openssl-3.0.x.so.node`).
Prisma cannot find the required `libssl` system library in your system. Please install openssl-3.0.x and try again.
Details: libssl.so.3: cannot open shared object file: No such file or directory
at new e (/app/node_modules/@prisma/client/runtime/library.js:21:1872)
at /app/node_modules/@prisma/client/runtime/library.js:110:10219
Bun v1.1.9 (Linux x64)
error: script "start" exited with code 1I would love to use all my suitable apps on Railway so hope there can be a clean solution to this. Thank you!
3 Replies
a year ago
I don't have an immediate solution for you, but I'd like to ask why didn't you want to use a Dockerfile?
I feel like you could have wrote a working Dockerfile in the time it took you to write out this very nicely put together forum post.
a year ago
Ah... Docker (and especially docker-compose) hasn't really been my strong suit so I didn't want to dabble in it (and saw the other solutions mostly didn't have to), and have liked Railway for handling it on its own but you have a point. It seems that there are open issues on prisma's GitHub with prisma running on bun's default oven/bun docker image. But it allegedly works on some images with bun and node included.
I used this Dockerfile (credits to kabir-asani in this post), slightly modified, and it worked like a charm. 

FROM ubuntu:22.04
ARG DATABASE_URL
# probably not needed here but needed if running prisma commands in this build phase
RUN apt-get update && apt-get install -y curl gnupg zip unzip openssl
RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - && \
apt-get install -y nodejs
ENV BUN_INSTALL=$HOME/bun
RUN curl -fsSL https://bun.sh/install | bash
ENV PATH=$PATH:$HOME/bun/bin
WORKDIR /app
COPY package.json .
COPY bun.lockb .
COPY tsconfig.json .
COPY prisma prisma
RUN bun install
# I chose to prisma generate & deploy during start phase
COPY src src
# copy anything else over that's necessary
CMD ["bun", "db-deploy-and-start"]
# this doesn't include PORTs, so you'll have to support them if you have a webserverpackage.json > scripts
"db-deploy-and-start": "prisma migrate deploy && prisma generate && bun run src/main.ts"railway.json > deploy
"startCommand": "bun run db-deploy-and-start"Thanks for what you said!
Status changed to Solved brody • about 1 year ago

