···11+FROM oven/bun:1 AS base
22+WORKDIR /usr/src/app
33+44+# install dependencies into temp directory
55+# this will cache them and speed up future builds
66+FROM base AS install
77+RUN mkdir -p /temp/dev
88+COPY package.json bun.lock /temp/dev/
99+RUN cd /temp/dev && bun install --frozen-lockfile
1010+1111+# install with --production (exclude devDependencies)
1212+RUN mkdir -p /temp/prod
1313+COPY package.json bun.lock /temp/prod/
1414+RUN cd /temp/prod && bun install --frozen-lockfile --production
1515+1616+# copy node_modules from temp directory
1717+# then copy all (non-ignored) project files into the image
1818+FROM base AS prerelease
1919+COPY --from=install /temp/dev/node_modules node_modules
2020+COPY . .
2121+2222+# copy production dependencies and source code into final image
2323+FROM base AS release
2424+COPY --from=install /temp/prod/node_modules node_modules
2525+COPY --from=prerelease /usr/src/app/package.json .
2626+COPY --from=prerelease /usr/src/app .
2727+2828+# run the app
2929+USER bun
3030+EXPOSE 4300/tcp
3131+ENTRYPOINT [ "bun", "run", "prod" ]