web: use multi-stage building for the container file

This commit is contained in:
rhpidfyre 2024-12-14 00:07:59 -05:00
parent f0c39f5837
commit 49da5f6eb1
2 changed files with 23 additions and 14 deletions

View File

@ -1,4 +1,15 @@
node_modules node_modules
build Dockerfile*
bun.lockb docker-compose*
.dockerignore
.git
.gitignore .gitignore
README.md
LICENSE
.vscode
Makefile
helm-charts
.env
.editorconfig
.idea
coverage*

View File

@ -1,21 +1,19 @@
FROM oven/bun:latest FROM oven/bun AS build
WORKDIR /app WORKDIR /app
COPY . . COPY . .
EXPOSE 3000 ENV NODE_ENV=production
ENV NEXT_TELEMETRY_DISABLED=1 ENV NEXT_TELEMETRY_DISABLED=1
RUN bun install && bun run build
RUN bun install FROM build AS release
RUN bun run build
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" COPY --from=build /app/build ./.next
# bun prune --production RUN bun add next
# 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"
ENTRYPOINT ["bun", "run", "start"] EXPOSE 3000
ENTRYPOINT ["bun", "run", "env", "--", "next", "start", "-p", "3000"]