chore: dockerfile update

This commit is contained in:
2026-06-17 22:48:09 +05:30
parent bc31b2508b
commit 224a33c553
5 changed files with 83 additions and 30 deletions
+19
View File
@@ -0,0 +1,19 @@
node_modules
.pnpm-store
dist
.output
.astro
.cache
.next
build
.env
.env.*
!.env.example
.DS_Store
*.log
npm-debug.log*
pnpm-debug.log*
.idea
.vscode
.history
apps/web/dist
+28 -10
View File
@@ -1,22 +1,40 @@
# syntax=docker/dockerfile:1.7
#
# PayloadCMS production image. Built and run by docker-compose.
# `corepack` reads the `packageManager` field from apps/cms/package.json
# so we don't pin a version here.
FROM node:20-alpine AS base
RUN corepack enable && corepack prepare [email protected] --activate
WORKDIR /app
RUN corepack enable
WORKDIR /repo
# ---- deps -----------------------------------------------------------------
# Install ALL workspace deps at the root so the `apps/cms` package can
# resolve its siblings (@payloadcms/*, next, react, etc.) and the root
# tooling (prettier) is also available.
FROM base AS deps
COPY package.json pnpm-lock.yaml* ./
COPY ../../package.json ../../pnpm-workspace.yaml* ../../ ./
RUN pnpm install --frozen-lockfile
COPY pnpm-workspace.yaml package.json ./
COPY apps/cms/package.json ./apps/cms/package.json
COPY apps/web/package.json ./apps/web/package.json
# pnpm-lock.yaml is generated locally; fall back gracefully on first build.
COPY pnpm-lock.yaml* ./
RUN if [ -f pnpm-lock.yaml ]; then \
pnpm install --frozen-lockfile; \
else \
echo "No pnpm-lock.yaml found; running pnpm install (generates one)"; \
pnpm install; \
fi
FROM base AS build
COPY --from=deps /app /app
COPY . .
# ---- build ----------------------------------------------------------------
FROM deps AS build
COPY apps/cms ./apps/cms
WORKDIR /repo/apps/cms
RUN pnpm run build
# ---- runtime --------------------------------------------------------------
FROM base AS runtime
ENV NODE_ENV=production
WORKDIR /app
COPY --from=build /app ./
WORKDIR /repo/apps/cms
COPY --from=build /repo ./
EXPOSE 3000
CMD ["pnpm", "start"]
+25 -16
View File
@@ -1,33 +1,42 @@
# syntax=docker/dockerfile:1.7
#
# Single-shot build image for the Astro site. The production deployment uses
# this Dockerfile to produce apps/web/dist, then `docker-compose.yml` mounts
# that folder into a plain nginx:alpine container (so re-builds from the
# webhook don't require a `docker build` / push step).
# nginx:1.27-alpine with a bind mount to apps/web/dist (see docker-compose.yml),
# so the webhook can rewrite the site without rebuilding any image.
#
# You only need this image if you want a self-contained static site image
# (e.g. for a registry). For the normal homeserver flow, just use
# `docker compose up -d --build web` — there is no `web` service to build.
# You only need this Dockerfile if you want a self-contained static site
# image (e.g. for a registry). For the normal homeserver flow, this image
# is never built.
#
# `corepack` reads the `packageManager` field from apps/web/package.json
# so we don't pin a version here.
FROM node:20-alpine AS base
RUN corepack enable && corepack prepare [email protected] --activate
WORKDIR /app
RUN corepack enable
WORKDIR /repo
FROM base AS deps
COPY package.json pnpm-lock.yaml* ./
COPY ../../package.json ../../pnpm-workspace.yaml* ../../ ./
RUN pnpm install --frozen-lockfile
COPY pnpm-workspace.yaml package.json ./
COPY apps/web/package.json ./apps/web/package.json
COPY apps/cms/package.json ./apps/cms/package.json
COPY pnpm-lock.yaml* ./
RUN if [ -f pnpm-lock.yaml ]; then \
pnpm install --frozen-lockfile; \
else \
echo "No pnpm-lock.yaml found; running pnpm install (generates one)"; \
pnpm install; \
fi
FROM base AS build
FROM deps AS build
ENV PUBLIC_PAYLOAD_API=https://cms.softvowels.example
ENV PUBLIC_SITE_URL=https://softvowels.example
ENV PAYLOAD_API_INTERNAL=http://cms:3000
COPY --from=deps /app /app
COPY . .
COPY apps/web ./apps/web
WORKDIR /repo/apps/web
RUN pnpm run build
FROM nginx:1.27-alpine AS runtime
COPY --from=build /app/dist /usr/share/nginx/html
COPY nginx-default.conf /etc/nginx/conf.d/default.conf
COPY --from=build /repo/apps/web/dist /usr/share/nginx/html
COPY apps/web/nginx-default.conf /etc/nginx/conf.d/default.conf
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
+4
View File
@@ -3,6 +3,10 @@
"version": "0.1.0",
"private": true,
"type": "module",
"packageManager": "[email protected]",
"engines": {
"node": ">=20.11.0"
},
"scripts": {
"dev": "astro dev",
"start": "astro dev",
+7 -4
View File
@@ -16,7 +16,7 @@ services:
timeout: 5s
retries: 10
networks:
- app
- nginx_proxy_manager
cms:
build:
@@ -39,7 +39,7 @@ services:
volumes:
- cms-uploads:/app/apps/cms/media
networks:
- app
- nginx_proxy_manager
# The public site. We deliberately do NOT bake dist/ into the image:
# scripts/rebuild.sh (run by the host-side webhook) writes fresh HTML to
@@ -55,12 +55,15 @@ services:
- ./apps/web/dist:/usr/share/nginx/html:ro
- ./apps/web/nginx-default.conf:/etc/nginx/conf.d/default.conf:ro
networks:
- app
- nginx_proxy_manager
volumes:
pgdata:
cms-uploads:
networks:
app:
nginx_proxy_manager:
name: nginx_proxy_manager
driver: bridge
external: true