From c71111c646baade80839e977ca9a8042a6cb0fb7 Mon Sep 17 00:00:00 2001 From: Alie Date: Sat, 20 Apr 2024 14:08:03 +0200 Subject: [PATCH] imporve dockerfie form layer caching --- Dockerfile | 15 +++++++++++---- bunfig.toml | 7 ++++++- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index 3e930ea..8090bd8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,14 @@ -FROM oven/bun:1 as install +FROM oven/bun:1 as base + +FROM base as install RUN mkdir -p /temp/prod -COPY . /temp/prod -RUN cd /temp/prod && bun install --production --frozen-lockfile && bun run build +COPY package.json bun.lockb /temp/prod/ +RUN cd /temp/prod && bun install --production --frozen-lockfile + +FROM base as build +RUN mkdir -p /temp/prod +COPY . /temp/prod/ +RUN cd /temp/prod && bun run build FROM nginx AS release -COPY --from=install /temp/prod/dist /usr/share/nginx/html \ No newline at end of file +COPY --from=build /temp/prod/dist /usr/share/nginx/html \ No newline at end of file diff --git a/bunfig.toml b/bunfig.toml index 54b7a49..5301d49 100644 --- a/bunfig.toml +++ b/bunfig.toml @@ -1,2 +1,7 @@ [test] -preload = './happydom.ts' \ No newline at end of file +preload = './happydom.ts' + +[install.lockfile] +# whether to save a non-Bun lockfile alongside bun.lockb +# only "yarn" is supported +print = "yarn"