diff --git a/Dockerfile b/Dockerfile index 7df79c03..17e4c109 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,24 +1,34 @@ -FROM node:20-alpine AS builder - +# Base stage for both Bun and Node.js +FROM alpine:3.14 as base WORKDIR /app +COPY package.json . -COPY package.json ./ - -RUN npm install - +# Bun stage +FROM oven/bun:1 as bun-builder +WORKDIR /app +COPY --from=base /app/package.json . COPY . . +RUN bun install +RUN bun run build -RUN ADAPTER=bun npm run build - -FROM oven/bun:alpine - +# Node.js stage +FROM node:18-alpine as node-builder WORKDIR /app +COPY --from=base /app/package.json . +COPY . . +RUN npm install +RUN npm run build -COPY --from=builder /app/node_modules /app/node_modules -COPY --from=builder /app/build /app/build - +# Final Bun image +FROM oven/bun:1-alpine AS bun +WORKDIR /app +COPY --from=bun-builder /app . EXPOSE 3000 - -USER bun - CMD ["bun", "/app/build/index.js"] + +# Final Node.js image +FROM node:20-alpine AS node +WORKDIR /app +COPY --from=node-builder /app . +EXPOSE 3000 +CMD ["node", "/app/build/index.js"] \ No newline at end of file