From 8141685a940a33873ae6684a3aa07809c515dfc8 Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Thu, 11 Apr 2024 17:14:00 +0200 Subject: docker: use bun compiler to generate single file executable --- Dockerfile | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 915a6a9..3724bf3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -30,6 +30,9 @@ COPY --link static static ENV NODE_ENV=production RUN bun run bin/build.ts +RUN rm -fr node_modules +COPY --from=install /temp/prod/node_modules node_modules +RUN bun build src/index.ts --compile --minify --sourcemap --outfile server FROM alpine:20240329 as postprocess @@ -47,11 +50,12 @@ RUN make format RUN make -j4 compress # Final stage for app image -FROM base +FROM gcr.io/distroless/base-nossl + +WORKDIR /app # Copy built application COPY config.toml /app/ -COPY --from=install /temp/prod/node_modules node_modules COPY --from=build /app /app COPY --from=postprocess /app/public /app/public @@ -60,4 +64,4 @@ EXPOSE 3000 EXPOSE 9091 ENV NODE_ENV=production -CMD [ "bun", "run", "src/index.ts" ] +CMD [ "/app/server" ] -- cgit 1.4.1