Files
emdash-blog-template/Dockerfile
Kunthawat Greethong a06c72b9d1 Dockerfile: only copy dist/src/package.json from core (avoid circular symlinks)
The -L flag on cp still follows symlinks deeply in this monorepo.
Instead copy only dist/ and src/ and package.json directly without -L.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-05-03 16:12:06 +07:00

53 lines
1.4 KiB
Docker

FROM node:22-alpine AS deps
RUN apk add --no-cache python3 make g++ sqlite git
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
# Clone patched emdash source
RUN git clone --depth=1 https://git.moreminimore.com/kunthawat/emdash-patch-imageupload.git emdash-source
WORKDIR /app/emdash-source
# Build core package (contains visual editing toolbar with fix)
RUN corepack enable && corepack prepare pnpm@9.0.0 --activate
RUN pnpm install
RUN cd packages/core && pnpm build
# Return to app
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .
# Replace emdash core with patched version (don't copy whole package - it has circular symlinks)
RUN rm -rf node_modules/emdash/dist node_modules/emdash/src node_modules/emdash/package.json
RUN cp -r emdash-source/packages/core/dist node_modules/emdash/
RUN cp -r emdash-source/packages/core/src node_modules/emdash/
RUN cp emdash-source/packages/core/package.json node_modules/emdash/
RUN pnpm build && mkdir -p storage/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
EXPOSE 4321
COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]