Add Forgejo CD workflow + Docker image build
Some checks failed
Deploy eCourt Note Web to Server / Validate Database Schema (Drizzle) (push) Successful in 3s
Deploy eCourt Note Web to Server / Build Web Docker Image (push) Successful in 53s
Deploy eCourt Note Web to Server / Deploy eCourt Note Web to Server (push) Failing after 1s
Deploy eCourt Note Web to Server / Notify Deployment Status (push) Failing after 1s
Some checks failed
Deploy eCourt Note Web to Server / Validate Database Schema (Drizzle) (push) Successful in 3s
Deploy eCourt Note Web to Server / Build Web Docker Image (push) Successful in 53s
Deploy eCourt Note Web to Server / Deploy eCourt Note Web to Server (push) Failing after 1s
Deploy eCourt Note Web to Server / Notify Deployment Status (push) Failing after 1s
- .forgejo/workflows/build.yml: ดัดแปลงจาก e-Ticket — validate db/schema.ts (Drizzle) แทน Prisma migrations, image chamomind/ecourt-note, deploy ผ่าน SSH (ECOURT_NOTE_TAG), แก้ env ที่ใช้แต่ไม่ได้นิยาม (NEXT_PUBLIC_APP_URL) และ vars/secrets.SSH_DEPLOY_USER ไม่สอดคล้อง - docker/web.Dockerfile: Next.js standalone 3 stages (deps/build/runner) พร้อม build-time DATABASE_URL placeholder (db/index.ts throw ถ้าไม่มี env ตอนเก็บ page data) + COPY .next/static ที่ standalone ไม่รวม - .dockerignore กัน .git/node_modules/.next/.env เข้า build context - next.config.mjs: เปิด output: "standalone" หมายเหตุ: ยังตรวจ docker build ท้องถิ่นไม่ครบ — ค้างที่ดิสก์ C: เต็ม (Docker Desktop buildkit read-only) รอเคลียร์พื้นที่ก่อน rerun Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
parent
eddcec28c7
commit
83108dd16c
4 changed files with 301 additions and 1 deletions
37
docker/web.Dockerfile
Normal file
37
docker/web.Dockerfile
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
# ─── Stage 1: ติดตั้ง dependencies (npm ci รวม postinstall คัดลอก pdf.worker) ───
|
||||
FROM node:24-alpine AS deps
|
||||
WORKDIR /app
|
||||
COPY package.json package-lock.json ./
|
||||
# postinstall เขียน public/pdf.worker.min.mjs — ต้องมีโฟลเดอร์ public/ ก่อน ไม่งั้น npm ci ล้ม
|
||||
RUN mkdir -p public && npm ci
|
||||
|
||||
# ─── Stage 2: build Next.js (output: standalone) ───
|
||||
FROM node:24-alpine AS builder
|
||||
WORKDIR /app
|
||||
COPY --from=deps /app/node_modules ./node_modules
|
||||
COPY . .
|
||||
# ประกันว่า pdf.worker.min.mjs ตรงกับเวอร์ชัน pdfjs-dist ใน node_modules เสมอ
|
||||
# (postinstall รันใน stage deps ซึ่งยังไม่มี public/ ของ repo)
|
||||
RUN node -e "require('fs').copyFileSync('node_modules/pdfjs-dist/build/pdf.worker.min.mjs','public/pdf.worker.min.mjs')"
|
||||
ENV NEXT_TELEMETRY_DISABLED=1
|
||||
# db/index.ts throw ถ้าไม่มี DATABASE_URL ตอน next build เก็บ page data —
|
||||
# ใส่ค่า dummy (postgres.js เชื่อมแบบ lazy ไม่มี query ตอน build) ตัวจริงฉีดตอน docker run
|
||||
ENV DATABASE_URL=postgresql://placeholder:placeholder@127.0.0.1:5432/placeholder
|
||||
RUN npm run build
|
||||
|
||||
# ─── Stage 3: runtime ตัวเบา (แค่ standalone + public/) ───
|
||||
FROM node:24-alpine AS runner
|
||||
WORKDIR /app
|
||||
ENV NODE_ENV=production \
|
||||
NEXT_TELEMETRY_DISABLED=1 \
|
||||
PORT=3000 \
|
||||
HOSTNAME=0.0.0.0
|
||||
RUN addgroup -S nodejs && adduser -S nextjs -G nodejs
|
||||
# Next 14.2 รวม public/ (pdf.worker, ฟอนต์ Sarabun, samples PDF) ไว้ใน standalone แล้ว
|
||||
# แต่ไม่รวม .next/static (JS chunks) — ต้องคัดลอกเพิ่ม ไม่งั้นหน้าเว็บไม่มี JS
|
||||
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
|
||||
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
|
||||
USER nextjs
|
||||
EXPOSE 3000
|
||||
# DATABASE_URL ฉีดตอนรันผ่าน env ของ container (อย่าฝังใน image)
|
||||
CMD ["node", "server.js"]
|
||||
Loading…
Add table
Add a link
Reference in a new issue