Files
bracket/frontend/Dockerfile
Erik Vroon 583eb4e963 Migrate Next.js to Vite (#1397)
Vite is much simpler to use than Next.js and we don't need any of the
features Next has that Vite doesn't have.

Benefits of moving to Vite are:
- Much better performance in dev and prod environments
- Much better build times
- Actual support for static exports, no vendor lock-in of having to use
Vercel
- Support for runtime environment variables/loading config from `.env`
files
- No annoying backwards-incompatible changes on major releases of Next
- Better i18n support without having to define getServerSideProps on
every page
- Better bundle optimization
- No opt-out Vercel telemetry 

Also replaces yarn by pnpm and upgrades mantine to 8.3
2025-11-12 11:18:06 +01:00

48 lines
1.0 KiB
Docker

# Install dependencies only when needed
FROM node:22-alpine AS deps
WORKDIR /app
COPY pnpm-lock.yaml package.json ./
RUN corepack enable && pnpm i
# Rebuild the source code only when needed
FROM node:22-alpine AS builder
WORKDIR /app
COPY . .
COPY --from=deps /app/node_modules ./node_modules
RUN corepack enable
RUN VITE_API_BASE_URL=http://VITE_API_BASE_URL_PLACEHOLDER \
VITE_HCAPTCHA_SITE_KEY=VITE_HCAPTCHA_SITE_KEY_PLACEHOLDER \
pnpm build
# Production image, copy all the files and run next
FROM node:22-alpine AS runner
WORKDIR /app
ENV NODE_ENV=production
RUN addgroup -g 1001 --system nodejs && \
adduser --system vite -u 1001 -G nodejs
COPY --from=builder --chown=vite:nodejs /app/public ./public
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/package.json ./package.json
RUN apk add bash
USER vite
EXPOSE 3000
HEALTHCHECK --interval=10s --timeout=5s --retries=5 \
CMD ["wget", "--spider", "http://0.0.0.0:3000", "||", "exit", "1"]
CMD ["pnpm", "start"]