Files
emdash-blog-template/Dockerfile
Kunthawat Greethong f981f1fe4c fix: run emdash seed only on first launch via entrypoint.sh
- Remove emdash seed from Dockerfile build stage (no longer overwrites DB)
- Add entrypoint.sh that checks if data.db exists before seeding
- First launch: seed runs to populate DB
- Subsequent redeploys: DB exists, seed skipped, data preserved
- Also remove COPY data.db from runner stage (volume mount handles persistence)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-30 15:00:29 +07:00

37 lines
682 B
Docker

FROM node:22-alpine AS deps
RUN apk add --no-cache python3 make g++ sqlite
WORKDIR /app
COPY package.json pnpm-lock.yaml* ./
RUN corepack enable && corepack prepare pnpm@9.0.0 --activate
RUN pnpm install
FROM deps AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .
RUN pnpm build && pnpm exec emdash init && mkdir -p uploads
FROM deps AS runner
WORKDIR /app
ENV NODE_ENV=production
ENV HOST=0.0.0.0
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/uploads ./uploads
EXPOSE 4321
COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]