From 5576f0872fe6e53260e7ffe253109f850ba0ce11 Mon Sep 17 00:00:00 2001 From: Woodson Gates <43043100+faultoverload@users.noreply.github.com> Date: Tue, 27 Jan 2026 16:48:57 -0500 Subject: [PATCH 1/7] Add Dockerfile for multi-stage build with Nginx --- Dockerfile | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..e81fea2 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,37 @@ +# Build stage +FROM oven/bun:1 AS builder + +WORKDIR /app + +# Copy package files +COPY package.json bun.lockb* ./ + +# Install dependencies +RUN bun install --frozen-lockfile + +# Copy source code +COPY . . + +# Build the application +RUN bun run build + +# Production stage +FROM nginx:alpine + +# Copy built static files +COPY --from=builder /app/dist /usr/share/nginx/html + +# Add custom nginx config for SPA routing +RUN echo 'server { \ + listen 80; \ + server_name localhost; \ + root /usr/share/nginx/html; \ + index index.html; \ + location / { \ + try_files $uri $uri/ /index.html; \ + } \ +}' > /etc/nginx/conf.d/default.conf + +EXPOSE 80 + +CMD ["nginx", "-g", "daemon off;"] From f04572949834b6fc08599d7122e6b1f1e9d417e6 Mon Sep 17 00:00:00 2001 From: Woodson Gates <43043100+faultoverload@users.noreply.github.com> Date: Tue, 3 Feb 2026 13:36:04 -0500 Subject: [PATCH 2/7] Refactor Dockerfile for final serving stage Update Dockerfile to use bun:1-alpine for serving. --- Dockerfile | 35 ++++++----------------------------- 1 file changed, 6 insertions(+), 29 deletions(-) diff --git a/Dockerfile b/Dockerfile index e81fea2..038d7b2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,37 +1,14 @@ # Build stage FROM oven/bun:1 AS builder - WORKDIR /app - -# Copy package files COPY package.json bun.lockb* ./ - -# Install dependencies RUN bun install --frozen-lockfile - -# Copy source code COPY . . - -# Build the application RUN bun run build -# Production stage -FROM nginx:alpine - -# Copy built static files -COPY --from=builder /app/dist /usr/share/nginx/html - -# Add custom nginx config for SPA routing -RUN echo 'server { \ - listen 80; \ - server_name localhost; \ - root /usr/share/nginx/html; \ - index index.html; \ - location / { \ - try_files $uri $uri/ /index.html; \ - } \ -}' > /etc/nginx/conf.d/default.conf - -EXPOSE 80 - -CMD ["nginx", "-g", "daemon off;"] +# Final stage +FROM oven/bun:1-alpine +WORKDIR /app +COPY --from=builder /app/dist . +EXPOSE 3000 +ENTRYPOINT ["bun", "serve"] From 08e504da59b5c17b46e160713336b4b332ce6662 Mon Sep 17 00:00:00 2001 From: Woodson Gates <43043100+faultoverload@users.noreply.github.com> Date: Tue, 3 Feb 2026 13:43:45 -0500 Subject: [PATCH 3/7] Change ENTRYPOINT to run index.html --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 038d7b2..4b1a294 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,4 +11,4 @@ FROM oven/bun:1-alpine WORKDIR /app COPY --from=builder /app/dist . EXPOSE 3000 -ENTRYPOINT ["bun", "serve"] +ENTRYPOINT ["bun", "run", "index.html"] From 0d5738e6b834ec6e5c2f768fcbbecc1b1b4ece3a Mon Sep 17 00:00:00 2001 From: Woodson Gates <43043100+faultoverload@users.noreply.github.com> Date: Tue, 3 Feb 2026 14:05:42 -0500 Subject: [PATCH 4/7] Refactor Dockerfile for multi-stage builds --- Dockerfile | 46 +++++++++++++++++++++++++++++++++++----------- 1 file changed, 35 insertions(+), 11 deletions(-) diff --git a/Dockerfile b/Dockerfile index 4b1a294..defc1e9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,14 +1,38 @@ -# Build stage -FROM oven/bun:1 AS builder -WORKDIR /app -COPY package.json bun.lockb* ./ -RUN bun install --frozen-lockfile +# use the official Bun image +# see all versions at https://hub.docker.com/r/oven/bun/tags +FROM oven/bun:1 AS base +WORKDIR /usr/src/app + +# install dependencies into temp directory +# this will cache them and speed up future builds +FROM base AS install +RUN mkdir -p /temp/dev +COPY package.json bun.lock /temp/dev/ +RUN cd /temp/dev && bun install --frozen-lockfile + +# install with --production (exclude devDependencies) +RUN mkdir -p /temp/prod +COPY package.json bun.lock /temp/prod/ +RUN cd /temp/prod && bun install --frozen-lockfile --production + +# 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 . . + +# [optional] tests & build +ENV NODE_ENV=production +RUN bun test RUN bun run build -# Final stage -FROM oven/bun:1-alpine -WORKDIR /app -COPY --from=builder /app/dist . -EXPOSE 3000 -ENTRYPOINT ["bun", "run", "index.html"] +# copy production dependencies and source code into final image +FROM base AS release +COPY --from=install /temp/prod/node_modules node_modules +COPY --from=prerelease /usr/src/app/index.ts . +COPY --from=prerelease /usr/src/app/package.json . + +# run the app +USER bun +EXPOSE 3000/tcp +ENTRYPOINT [ "bun", "run", "index.html" ] From 9af500548833f6c1736e161b939fc60ebf172fdc Mon Sep 17 00:00:00 2001 From: Woodson Gates <43043100+faultoverload@users.noreply.github.com> Date: Tue, 3 Feb 2026 14:10:51 -0500 Subject: [PATCH 5/7] Refactor Dockerfile for multi-stage builds --- Dockerfile | 48 ++++++++++++++---------------------------------- 1 file changed, 14 insertions(+), 34 deletions(-) diff --git a/Dockerfile b/Dockerfile index defc1e9..4b96642 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,38 +1,18 @@ -# use the official Bun image -# see all versions at https://hub.docker.com/r/oven/bun/tags -FROM oven/bun:1 AS base -WORKDIR /usr/src/app - -# install dependencies into temp directory -# this will cache them and speed up future builds -FROM base AS install -RUN mkdir -p /temp/dev -COPY package.json bun.lock /temp/dev/ -RUN cd /temp/dev && bun install --frozen-lockfile - -# install with --production (exclude devDependencies) -RUN mkdir -p /temp/prod -COPY package.json bun.lock /temp/prod/ -RUN cd /temp/prod && bun install --frozen-lockfile --production - -# 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 +# Build stage +FROM oven/bun:1 AS builder +WORKDIR /app +COPY package.json bun.lockb* ./ +RUN bun install --frozen-lockfile COPY . . - -# [optional] tests & build -ENV NODE_ENV=production -RUN bun test RUN bun run build -# copy production dependencies and source code into final image -FROM base AS release -COPY --from=install /temp/prod/node_modules node_modules -COPY --from=prerelease /usr/src/app/index.ts . -COPY --from=prerelease /usr/src/app/package.json . +# Production stage +FROM oven/bun:1-alpine +WORKDIR /app +COPY --from=builder /app/dist ./dist +COPY --from=builder /app/package.json ./ +COPY --from=builder /app/bun.lockb ./ +RUN bun install --frozen-lockfile --production -# run the app -USER bun -EXPOSE 3000/tcp -ENTRYPOINT [ "bun", "run", "index.html" ] +EXPOSE 3000 +CMD ["bun", "run", "start"] From 97455ace636bfd189cf5147d0727ebe4dd44df27 Mon Sep 17 00:00:00 2001 From: Woodson Gates <43043100+faultoverload@users.noreply.github.com> Date: Tue, 3 Feb 2026 14:12:22 -0500 Subject: [PATCH 6/7] Fix CMD syntax in Dockerfile From 508fc49ed70b0e7246a06b9c6e181fbf8d0d687f Mon Sep 17 00:00:00 2001 From: Woodson Gates <43043100+faultoverload@users.noreply.github.com> Date: Tue, 3 Feb 2026 14:18:41 -0500 Subject: [PATCH 7/7] Refactor Dockerfile for final production stage --- Dockerfile | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index 4b96642..4b1a294 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,13 +6,9 @@ RUN bun install --frozen-lockfile COPY . . RUN bun run build -# Production stage +# Final stage FROM oven/bun:1-alpine WORKDIR /app -COPY --from=builder /app/dist ./dist -COPY --from=builder /app/package.json ./ -COPY --from=builder /app/bun.lockb ./ -RUN bun install --frozen-lockfile --production - +COPY --from=builder /app/dist . EXPOSE 3000 -CMD ["bun", "run", "start"] +ENTRYPOINT ["bun", "run", "index.html"]