forked from minzeyaphyo/burmddit
- Replace @vercel/postgres with standard pg library - Add Dockerfile for Next.js standalone build - Add tsconfig.json, postcss.config.js - Fix globals.css undefined tailwind utilities - Force dynamic rendering for DB-dependent pages - Add .dockerignore
48 lines
1.1 KiB
Docker
48 lines
1.1 KiB
Docker
FROM node:18-alpine AS base
|
|
|
|
# Install dependencies only when needed
|
|
FROM base AS deps
|
|
RUN apk add --no-cache libc6-compat
|
|
WORKDIR /app
|
|
COPY frontend/package.json frontend/package-lock.json* ./
|
|
RUN npm ci 2>/dev/null || npm install
|
|
|
|
# Build the application
|
|
FROM base AS builder
|
|
WORKDIR /app
|
|
COPY --from=deps /app/node_modules ./node_modules
|
|
COPY frontend/ .
|
|
|
|
# Need DATABASE_URL at build time for Next.js static generation (can be dummy)
|
|
ARG DATABASE_URL=postgresql://localhost/burmddit
|
|
ENV DATABASE_URL=${DATABASE_URL}
|
|
ENV NEXT_TELEMETRY_DISABLED=1
|
|
|
|
RUN npm run build
|
|
|
|
# Production image
|
|
FROM base AS runner
|
|
WORKDIR /app
|
|
|
|
ENV NODE_ENV=production
|
|
ENV NEXT_TELEMETRY_DISABLED=1
|
|
|
|
RUN addgroup --system --gid 1001 nodejs
|
|
RUN adduser --system --uid 1001 nextjs
|
|
|
|
# Copy public assets
|
|
COPY --from=builder /app/public ./public
|
|
|
|
# Copy standalone build
|
|
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
|
|
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
|
|
|
|
USER nextjs
|
|
|
|
EXPOSE 3000
|
|
|
|
ENV PORT=3000
|
|
ENV HOSTNAME="0.0.0.0"
|
|
|
|
CMD ["node", "server.js"]
|