Files
softvowels-webpage/apps/web/Dockerfile
T
2026-06-17 23:58:51 +05:30

45 lines
1.5 KiB
Docker

# syntax=docker/dockerfile:1.7
#
# Astro static site production image. Built and run by docker-compose.
#
# Multi-stage:
# deps - installs the workspace (only apps/web and apps/cms are
# needed for the web build, but we keep apps/cms/package.json
# so the workspace resolves cleanly).
# build - runs `astro build` to produce apps/web/dist.
# runtime - small nginx:1.27-alpine serving the baked-in dist/ and
# the custom nginx-default.conf.
#
# We install pnpm via `npm install -g pnpm@9` instead of corepack so
# the version negotiation is unambiguous across Node 20 minor releases.
FROM node:20-alpine AS base
RUN npm install -g pnpm@9
WORKDIR /repo
FROM base AS deps
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 deps AS build
ENV PUBLIC_PAYLOAD_API=https://cms.softvowels.example
ENV PUBLIC_SITE_URL=https://softvowels.example
ENV PAYLOAD_API_INTERNAL=http://softvowels-cms:3000
COPY apps/web ./apps/web
WORKDIR /repo/apps/web
RUN pnpm run build
FROM nginx:1.27-alpine AS runtime
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;"]