Adapt for self-hosted deployment on Coolify

- 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
This commit is contained in:
Min Zeya Phyo
2026-02-19 16:51:31 +08:00
parent dddb86ea94
commit 98af1c7cec
11 changed files with 112 additions and 10 deletions

47
Dockerfile Normal file
View File

@@ -0,0 +1,47 @@
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"]