mirror of
https://github.com/andwati/andwati.com.git
synced 2026-11-14 21:05:12 +00:00
Add Docker setup for running Strapi locally
apps/cms/Dockerfile.dev + root docker-compose.yml give a one-command way to run the CMS in a container for testing (docker compose up cms), with the shared content/ directory mounted so it matches the host dev setup. apps/cms/Dockerfile is a production multi-stage build for later Dokploy deployment. Uses node:24-bookworm-slim to match the local Node version and get glibc prebuilt binaries for better-sqlite3 without needing a native build toolchain in the final image. Verified: both images build, the dev container boots Strapi successfully, admin panel and API routes are reachable, and the mounted content/ volume resolves at the same relative path the future sync provider will expect.
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
# Production image for the Strapi CMS. Multi-stage: install deps, build the
|
||||
# admin panel, then copy only the built output + prod node_modules into the
|
||||
# runtime layer.
|
||||
#
|
||||
# Build context must be the repo root (pnpm workspace root), e.g.:
|
||||
# docker build -f apps/cms/Dockerfile -t andwati-cms .
|
||||
|
||||
FROM node:24-bookworm-slim AS base
|
||||
RUN corepack enable
|
||||
WORKDIR /app
|
||||
|
||||
FROM base AS deps
|
||||
# better-sqlite3 needs to compile if no prebuilt binary matches the platform.
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
python3 make g++ \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
COPY pnpm-workspace.yaml pnpm-lock.yaml package.json ./
|
||||
COPY apps/site/package.json apps/site/package.json
|
||||
COPY apps/cms/package.json apps/cms/package.json
|
||||
RUN pnpm install --frozen-lockfile --filter cms
|
||||
|
||||
FROM deps AS build
|
||||
ENV NODE_ENV=production
|
||||
COPY apps/cms apps/cms
|
||||
RUN pnpm --filter cms build
|
||||
|
||||
FROM base AS runtime
|
||||
ENV NODE_ENV=production
|
||||
COPY --from=build /app/node_modules /app/node_modules
|
||||
COPY --from=build /app/apps/cms /app/apps/cms
|
||||
WORKDIR /app/apps/cms
|
||||
EXPOSE 1337
|
||||
CMD ["pnpm", "start"]
|
||||
Reference in New Issue
Block a user