Files
emdash-blog-template/Dockerfile
Kunthawat Greethong ddf47aff3a Dockerfile: reinstall after copying auth package to resolve its dependencies
The @emdash-cms/auth package needs its node_modules (ulidx, etc.) to be
linked. Running pnpm install after copying it restores the proper links.

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

55 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 only the core package directly (not via workspace filter)
RUN corepack enable && corepack prepare pnpm@9.0.0 --activate
RUN pnpm install
RUN cd packages/core && pnpm build
RUN cd packages/auth && pnpm build
# Return to app and copy source
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .
# Remove old emdash packages and replace with patched source
RUN rm -rf node_modules/emdash node_modules/@emdash-cms/auth
RUN cp -r /app/emdash-source/packages/core node_modules/emdash
RUN cp -r /app/emdash-source/packages/auth node_modules/@emdash-cms/auth
# Reinstall so auth's node_modules dependencies are linked
RUN pnpm install
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"]