From 49da5f6eb16bfe23f4b241c8594ede7efe3b3b84 Mon Sep 17 00:00:00 2001
From: rhpidfyre <brandon@rhpidfyre.io>
Date: Sat, 14 Dec 2024 00:07:59 -0500
Subject: [PATCH] web: use multi-stage building for the container file

---
 web/.dockerignore | 17 ++++++++++++++---
 web/Containerfile | 20 +++++++++-----------
 2 files changed, 23 insertions(+), 14 deletions(-)

diff --git a/web/.dockerignore b/web/.dockerignore
index c6651e7..9b49524 100644
--- a/web/.dockerignore
+++ b/web/.dockerignore
@@ -1,4 +1,15 @@
 node_modules
-build
-bun.lockb
-.gitignore
\ No newline at end of file
+Dockerfile*
+docker-compose*
+.dockerignore
+.git
+.gitignore
+README.md
+LICENSE
+.vscode
+Makefile
+helm-charts
+.env
+.editorconfig
+.idea
+coverage*
\ No newline at end of file
diff --git a/web/Containerfile b/web/Containerfile
index a048078..3114991 100644
--- a/web/Containerfile
+++ b/web/Containerfile
@@ -1,21 +1,19 @@
-FROM oven/bun:latest
+FROM oven/bun AS build
 
 WORKDIR /app
 
 COPY . .
 
-EXPOSE 3000
-
+ENV NODE_ENV=production
 ENV NEXT_TELEMETRY_DISABLED=1
+RUN bun install && bun run build
 
-RUN bun install
-RUN bun run build
+FROM build AS release
 
-RUN rm -rf src eslint.config.mjs tsconfig.json
+WORKDIR /app
 
-RUN bun remove "@emotion/react" "@emotion/styled" "@mui/icons-material" "@mui/material" "react" "react-dom" "sass"
-# bun prune --production
-# Uh-oh. bun prune is a subcommand reserved for future use by Bun.
-RUN bun remove "typescript" "@types/node" "@types/react" "@types/react-dom" "eslint" "eslint-config-next" "@eslint/eslintrc"
+COPY --from=build /app/build ./.next
+RUN bun add next
 
-ENTRYPOINT ["bun", "run", "start"]
\ No newline at end of file
+EXPOSE 3000
+ENTRYPOINT ["bun", "run", "env", "--", "next", "start", "-p", "3000"]
\ No newline at end of file