set-auth #1

Merged
phaichayon merged 2 commits from set-auth into main 2026-07-16 09:25:33 +00:00
6 changed files with 16 additions and 131 deletions

View File

@@ -1 +0,0 @@
npx lint-staged

View File

@@ -1 +0,0 @@
bun run build

View File

@@ -1,73 +1,28 @@
# ============================================
# Stage 1: Install dependencies
# ============================================
ARG NODE_VERSION=22-slim
FROM node:${NODE_VERSION} AS dependencies
FROM node:20-bookworm-slim AS base
WORKDIR /app
# Install bun to use bun.lock for dependency resolution
RUN npm install -g bun
# Copy package-related files to leverage Docker cache
COPY package.json bun.lock* ./
# Install dependencies with frozen lockfile for reproducible builds
RUN --mount=type=cache,target=/root/.bun/install/cache \
bun install --no-save --frozen-lockfile
# ============================================
# Stage 2: Build the Next.js application
# ============================================
FROM node:${NODE_VERSION} AS builder
WORKDIR /app
COPY --from=dependencies /app/node_modules ./node_modules
COPY . .
ENV NODE_ENV=production
ENV NEXT_TELEMETRY_DISABLED=1
# Build-time env vars — override these with --build-arg or in compose.yml
ARG NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY
ARG NEXT_PUBLIC_CLERK_SIGN_IN_URL=/auth/sign-in
ARG NEXT_PUBLIC_CLERK_SIGN_UP_URL=/auth/sign-up
ARG NEXT_PUBLIC_SENTRY_DISABLED=true
FROM base AS deps
COPY package.json package-lock.json ./
RUN npm install --no-audit --no-fund
FROM base AS builder
ENV NODE_ENV=production
ENV BUILD_STANDALONE=true
ARG NEXT_PUBLIC_SENTRY_DISABLED=true
ENV NEXT_PUBLIC_SENTRY_DISABLED=${NEXT_PUBLIC_SENTRY_DISABLED}
COPY --from=deps /app/node_modules ./node_modules
COPY . .
RUN npm run build
# ============================================
# Stage 3: Production runner
# ============================================
FROM node:${NODE_VERSION} AS runner
FROM node:20-bookworm-slim AS runner
WORKDIR /app
ENV NODE_ENV=production
ENV PORT=3000
ENV HOSTNAME="0.0.0.0"
ENV NEXT_TELEMETRY_DISABLED=1
# Copy public assets
COPY --from=builder --chown=node:node /app/public ./public
# Create .next dir with correct permissions for prerender cache
RUN mkdir .next && chown node:node .next
# Copy standalone output and static files
COPY --from=builder --chown=node:node /app/.next/standalone ./
COPY --from=builder --chown=node:node /app/.next/static ./.next/static
# Run as non-root user
USER node
ENV PORT=3000
ENV HOSTNAME=0.0.0.0
COPY --from=builder /app/public ./public
COPY --from=builder /app/.next/standalone ./
COPY --from=builder /app/.next/static ./.next/static
EXPOSE 3000
CMD ["node", "server.js"]

View File

@@ -1,68 +0,0 @@
# ============================================
# Stage 1: Install dependencies
# ============================================
FROM oven/bun:1 AS dependencies
WORKDIR /app
# Copy package-related files to leverage Docker cache
COPY package.json bun.lock* ./
# Install dependencies with frozen lockfile for reproducible builds
RUN --mount=type=cache,target=/root/.bun/install/cache \
bun install --no-save --frozen-lockfile
# ============================================
# Stage 2: Build the Next.js application
# ============================================
FROM oven/bun:1 AS builder
WORKDIR /app
COPY --from=dependencies /app/node_modules ./node_modules
COPY . .
ENV NODE_ENV=production
ENV NEXT_TELEMETRY_DISABLED=1
# Build-time env vars — override these with --build-arg or in compose.yml
ARG NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY
ARG NEXT_PUBLIC_CLERK_SIGN_IN_URL=/auth/sign-in
ARG NEXT_PUBLIC_CLERK_SIGN_UP_URL=/auth/sign-up
ARG NEXT_PUBLIC_SENTRY_DISABLED=true
ENV BUILD_STANDALONE=true
RUN bun run build
# ============================================
# Stage 3: Production runner
# ============================================
FROM oven/bun:1 AS runner
WORKDIR /app
ENV NODE_ENV=production
ENV PORT=3000
ENV HOSTNAME="0.0.0.0"
ENV NEXT_TELEMETRY_DISABLED=1
# Copy public assets
COPY --from=builder --chown=bun:bun /app/public ./public
# Create .next dir with correct permissions for prerender cache
RUN mkdir .next && chown bun:bun .next
# Copy standalone output and static files
COPY --from=builder --chown=bun:bun /app/.next/standalone ./
COPY --from=builder --chown=bun:bun /app/.next/static ./.next/static
# Run as non-root user
USER bun
EXPOSE 3000
CMD ["bun", "server.js"]

BIN
docker-bun-build.log Normal file

Binary file not shown.

BIN
docker-node-build.log Normal file

Binary file not shown.