From 87314a0e96d0aa4edbd092fc58121d51a123d3cc Mon Sep 17 00:00:00 2001 From: Zoe Roux Date: Sat, 18 Jan 2025 16:37:57 +0100 Subject: [PATCH] Use bun build in the dockerfile --- api/Dockerfile | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/api/Dockerfile b/api/Dockerfile index aa6cf9e8f..f3e7e1773 100644 --- a/api/Dockerfile +++ b/api/Dockerfile @@ -1,15 +1,28 @@ -FROM oven/bun +FROM oven/bun AS builder WORKDIR /app -COPY package.json . -COPY bun.lock . +COPY package.json bun.lock . RUN bun install --production COPY src src -COPY tsconfig.json . -COPY drizzle drizzle COPY drizzle drizzle +COPY tsconfig.json . + +ENV NODE_ENV=production +RUN bun build \ + --compile \ + --minify-whitespace \ + --minify-syntax \ + --target bun \ + --outfile server \ + ./src/index.ts -ENV NODE_ENV production +FROM gcr.io/distroless/base +WORKDIR /app + +COPY --from=builder /app/server server + +ENV NODE_ENV=production EXPOSE 3000 -CMD ["bun", "src/index.ts"] +CMD ["./server"] +