# This is making minimal changes from the guide at # https://bun.sh/guides/ecosystem/docker (as of 2024-02-04) # use the official Bun image # see all versions at https://hub.docker.com/r/oven/bun/tags FROM oven/bun:1-alpine as base WORKDIR /app # install dependencies into temp directory # this will cache them and speed up future builds FROM base as install RUN mkdir -p /tmp/dev COPY package.json bun.lockb /temp/dev/ RUN cd /temp/dev && bun install --frozen-lockfile # install with --production (exclude devDependencies) RUN mkdir -p /temp/prod COPY package.json bun.lockb /temp/prod/ RUN cd /temp/prod && bun install --frozen-lockfile --production # ^ Is this necessary? Don't we either need prod or not prod? # copy node_modules from temp directory # then copy all (non-ignored) project files into the image FROM base AS prerelease COPY --from=install /temp/dev/node_modules node_modules COPY . . FROM nginx:stable-alpine as release COPY --from=build-stage /app/docker/nginx.conf /etc/nginx/nginx.conf COPY --from=build-stage /app/dist /usr/share/nginx/html