mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-14 21:41:09 +02:00
Fourth stale package COPY in three days. The pattern is unfortunately predictable: package gets removed in a parallel cleanup commit, the Dockerfile.sveltekit-base entry stays behind, nobody notices because nobody runs the base build manually anymore. Then is_base_image_stale fires the next time something in packages/ changes and the build falls over. Long-term: add a pre-flight check to build-app.sh that validates every COPY-referenced path actually exists before kicking off Docker. Failing fast is much friendlier than failing 30 seconds into a Docker layer. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
97 lines
4.2 KiB
Text
97 lines
4.2 KiB
Text
# syntax=docker/dockerfile:1
|
|
# Shared builder base for all SvelteKit web apps
|
|
# Contains pre-installed shared packages and pre-built dependencies
|
|
#
|
|
# Usage in web Dockerfiles:
|
|
# FROM sveltekit-base:local AS builder
|
|
# COPY apps/myapp/packages/shared ./apps/myapp/packages/shared
|
|
# COPY apps/myapp/apps/web ./apps/myapp/apps/web
|
|
# RUN --mount=type=cache,id=pnpm,target=/root/.local/share/pnpm/store pnpm install --no-frozen-lockfile
|
|
# WORKDIR /app/apps/myapp/apps/web
|
|
# RUN pnpm exec svelte-kit sync
|
|
# RUN NODE_OPTIONS="--max-old-space-size=4096" pnpm build
|
|
|
|
FROM node:20-alpine
|
|
|
|
# Install system deps (git needed by some npm packages)
|
|
RUN apk add --no-cache git
|
|
|
|
# Install pnpm
|
|
RUN corepack enable && corepack prepare pnpm@9.15.0 --activate
|
|
|
|
WORKDIR /app
|
|
|
|
# Copy root workspace files
|
|
COPY pnpm-workspace.yaml ./
|
|
COPY package.json ./
|
|
COPY pnpm-lock.yaml ./
|
|
COPY patches/ ./patches/
|
|
|
|
# Copy ALL shared packages used by SvelteKit web apps
|
|
# packages/credit-operations and packages/shared-api-client were deleted
|
|
# during the NestJS-to-Hono migration; their COPY lines are removed.
|
|
COPY packages/qr-export ./packages/qr-export
|
|
COPY packages/shared-auth ./packages/shared-auth
|
|
COPY packages/shared-auth-ui ./packages/shared-auth-ui
|
|
COPY packages/shared-branding ./packages/shared-branding
|
|
# packages/shared-config was removed; its COPY line is gone too.
|
|
COPY packages/shared-error-tracking ./packages/shared-error-tracking
|
|
COPY packages/feedback ./packages/feedback
|
|
COPY packages/help ./packages/help
|
|
COPY packages/local-store ./packages/local-store
|
|
COPY packages/shared-i18n ./packages/shared-i18n
|
|
COPY packages/shared-icons ./packages/shared-icons
|
|
COPY packages/shared-pwa ./packages/shared-pwa
|
|
# packages/shared-splitscreen was removed; its COPY line is gone too.
|
|
COPY packages/shared-stores ./packages/shared-stores
|
|
# packages/shared-subscription-types and shared-subscription-ui were
|
|
# consolidated into packages/subscriptions (copied below). Their stale
|
|
# COPY lines broke `build-app.sh --base` on 2026-04-08, which blocked
|
|
# updating the base image when shared-utils was changed.
|
|
COPY packages/shared-tags ./packages/shared-tags
|
|
COPY packages/shared-tailwind ./packages/shared-tailwind
|
|
COPY packages/shared-theme ./packages/shared-theme
|
|
COPY packages/shared-theme-ui ./packages/shared-theme-ui
|
|
COPY packages/shared-links ./packages/shared-links
|
|
COPY packages/shared-types ./packages/shared-types
|
|
COPY packages/shared-ui ./packages/shared-ui
|
|
COPY packages/shared-utils ./packages/shared-utils
|
|
COPY packages/shared-vite-config ./packages/shared-vite-config
|
|
COPY packages/eslint-config ./packages/eslint-config
|
|
COPY packages/shared-hono ./packages/shared-hono
|
|
COPY packages/shared-logger ./packages/shared-logger
|
|
COPY packages/shared-storage ./packages/shared-storage
|
|
COPY packages/shared-landing-ui ./packages/shared-landing-ui
|
|
COPY packages/subscriptions ./packages/subscriptions
|
|
COPY packages/credits ./packages/credits
|
|
COPY packages/spiral-db ./packages/spiral-db
|
|
COPY packages/wallpaper-generator ./packages/wallpaper-generator
|
|
COPY packages/local-llm ./packages/local-llm
|
|
COPY packages/shared-llm ./packages/shared-llm
|
|
|
|
# Install dependencies (shared packages only - app deps added later)
|
|
RUN --mount=type=cache,id=pnpm,target=/root/.local/share/pnpm/store \
|
|
pnpm install --no-frozen-lockfile --ignore-scripts
|
|
|
|
# Ensure all @mana workspace packages are linked in node_modules
|
|
# (pnpm may skip linking when app/*/ dirs from pnpm-workspace.yaml don't exist)
|
|
RUN mkdir -p node_modules/@mana && \
|
|
for pkg in packages/*/; do \
|
|
name=$(node -p "require('./${pkg}package.json').name" 2>/dev/null) || continue; \
|
|
scope=$(echo "$name" | sed -n 's|@\(.*\)/.*|\1|p'); \
|
|
base=$(echo "$name" | sed 's|.*/||'); \
|
|
if [ -n "$scope" ]; then \
|
|
mkdir -p "node_modules/@${scope}"; \
|
|
ln -sfn "../../${pkg}" "node_modules/@${scope}/${base}"; \
|
|
fi; \
|
|
done
|
|
|
|
# Build shared packages in dependency order
|
|
RUN cd packages/shared-vite-config && pnpm build \
|
|
&& cd /app/packages/shared-auth && pnpm build || true \
|
|
&& cd /app/packages/shared-error-tracking && pnpm build \
|
|
&& cd /app/packages/shared-pwa && pnpm build \
|
|
&& cd /app/packages/shared-tags && pnpm build \
|
|
&& cd /app/packages/spiral-db && pnpm build 2>/dev/null || true
|
|
|
|
WORKDIR /app
|