sturlen
FREEOP
4 months ago
do you have public repo for the railpack configs? I can run bun flawlessly on railway with the auto detected railpack, but I'm having issues with building a docker image for my own servers. curious what you guys are doing differently
8 Replies
4 months ago
Can you show your Dockerimage?
4 months ago
Removing sensitive content if you need to
# Multi-stage Bun build optimized for CI
FROM oven/bun:1.3-debian AS deps
WORKDIR /app
COPY package.json bun.lock /app/
# install production dependencies only (used in final image)
RUN bun install --frozen-lockfile --production
FROM oven/bun:1.3-debian AS builder
WORKDIR /app
# install full deps for build
COPY package.json bun.lock /app/
RUN bun install --frozen-lockfile
# copy source and build
COPY . /app
# run tests and build in this stage (CI should run tests before building image)
RUN bun test || true
RUN bun run build
FROM oven/bun:1.3-debian AS release
WORKDIR /app
# copy only production node_modules and built assets
COPY --from=deps /app/node_modules ./node_modules
COPY --from=builder /app/dist ./dist
# copy source in case start script requires it (keeps runtime correct)
COPY --from=builder /app/src ./src
COPY --from=builder /app/package.json ./package.json
ENV NODE_ENV=production
EXPOSE 3000
USER bun
# start the app via the project start script (adjust if you prefer a static server)
CMD ["bun", "run", "start"]4 months ago
Any errors during building?
it built succesfully with github actions, but failed to start when I run it
4 months ago
I see your CMD, I recommend you set it to RUN ["bun", "run", "dist/YOUR_MAIN_FILE.js"] as using package.json scripts can be finicky