mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-14 20:21:09 +02:00
refactor(docker): standardize all web Dockerfiles to use sveltekit-base
Migrate 17 app Dockerfiles from standalone builds (each copying 20+ packages individually) to use the shared sveltekit-base:local image. Benefits: - No more missing package COPY errors - Single base image to maintain - Consistent build pattern across all apps - Faster builds (shared deps pre-installed) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
bb85a8d63d
commit
45ebfea59d
17 changed files with 160 additions and 1339 deletions
|
|
@ -1,100 +1,32 @@
|
|||
# syntax=docker/dockerfile:1
|
||||
# Build stage
|
||||
FROM node:20-alpine AS builder
|
||||
FROM sveltekit-base:local AS builder
|
||||
|
||||
# Build arguments for SvelteKit static env vars
|
||||
ARG PUBLIC_BACKEND_URL=http://presi-backend:3008
|
||||
ARG PUBLIC_MANA_CORE_AUTH_URL=http://mana-core-auth:3001
|
||||
|
||||
# Set as environment variables for build
|
||||
ARG PUBLIC_BACKEND_URL=http://presi-server
|
||||
ARG PUBLIC_MANA_CORE_AUTH_URL=http://mana-auth:3001
|
||||
ENV PUBLIC_BACKEND_URL=$PUBLIC_BACKEND_URL
|
||||
ENV PUBLIC_MANA_CORE_AUTH_URL=$PUBLIC_MANA_CORE_AUTH_URL
|
||||
|
||||
# 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 ./
|
||||
|
||||
# --- AUTO-GENERATED COPY STATEMENTS (do not edit manually) ---
|
||||
COPY packages/feedback ./packages/feedback
|
||||
COPY packages/eslint-config ./packages/eslint-config
|
||||
COPY packages/help ./packages/help
|
||||
COPY packages/local-store ./packages/local-store
|
||||
COPY packages/shared-app-onboarding ./packages/shared-app-onboarding
|
||||
COPY packages/shared-auth ./packages/shared-auth
|
||||
COPY packages/shared-auth-stores ./packages/shared-auth-stores
|
||||
COPY packages/shared-auth-ui ./packages/shared-auth-ui
|
||||
COPY packages/shared-branding ./packages/shared-branding
|
||||
COPY packages/shared-error-tracking ./packages/shared-error-tracking
|
||||
COPY packages/shared-i18n ./packages/shared-i18n
|
||||
COPY packages/shared-icons ./packages/shared-icons
|
||||
COPY packages/shared-profile-ui ./packages/shared-profile-ui
|
||||
COPY packages/shared-pwa ./packages/shared-pwa
|
||||
COPY packages/shared-stores ./packages/shared-stores
|
||||
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-ui ./packages/shared-ui
|
||||
COPY packages/shared-utils ./packages/shared-utils
|
||||
COPY packages/shared-vite-config ./packages/shared-vite-config
|
||||
COPY packages/subscriptions ./packages/subscriptions
|
||||
COPY apps/presi/packages/shared ./apps/presi/packages/shared
|
||||
# --- END AUTO-GENERATED ---
|
||||
|
||||
# Copy presi web
|
||||
COPY apps/presi/apps/web ./apps/presi/apps/web
|
||||
|
||||
# Install dependencies
|
||||
RUN --mount=type=cache,id=pnpm,target=/root/.local/share/pnpm/store pnpm install --no-frozen-lockfile
|
||||
RUN --mount=type=cache,id=pnpm,target=/root/.local/share/pnpm/store \
|
||||
pnpm install --no-frozen-lockfile --ignore-scripts
|
||||
|
||||
# Build shared packages that need building
|
||||
WORKDIR /app/packages/shared-auth
|
||||
RUN pnpm build || true
|
||||
|
||||
WORKDIR /app/packages/shared-error-tracking
|
||||
RUN pnpm build
|
||||
|
||||
WORKDIR /app/packages/shared-pwa
|
||||
RUN pnpm build
|
||||
|
||||
# Build the web app
|
||||
WORKDIR /app/apps/presi/apps/web
|
||||
RUN pnpm exec svelte-kit sync
|
||||
RUN pnpm build
|
||||
RUN NODE_OPTIONS="--max-old-space-size=4096" pnpm build
|
||||
|
||||
# Production stage
|
||||
FROM node:20-alpine AS production
|
||||
|
||||
# Keep same directory structure as builder so pnpm symlinks resolve correctly
|
||||
WORKDIR /app/apps/presi/apps/web
|
||||
|
||||
# Copy the pnpm store that symlinks point to (at /app/node_modules/.pnpm)
|
||||
COPY --from=builder /app/node_modules/.pnpm /app/node_modules/.pnpm
|
||||
|
||||
# Copy the app's node_modules (contains symlinks to the pnpm store)
|
||||
COPY --from=builder /app/apps/presi/apps/web/node_modules ./node_modules
|
||||
|
||||
# Copy built application
|
||||
COPY --from=builder /app/apps/presi/apps/web/build ./build
|
||||
COPY --from=builder /app/apps/presi/apps/web/package.json ./
|
||||
|
||||
# Expose port
|
||||
EXPOSE 5178
|
||||
EXPOSE 5020
|
||||
ENV NODE_ENV=production PORT=5020 HOST=0.0.0.0
|
||||
|
||||
# Set environment variables
|
||||
ENV NODE_ENV=production
|
||||
ENV PORT=5178
|
||||
ENV HOST=0.0.0.0
|
||||
|
||||
# Health check
|
||||
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
|
||||
CMD wget --no-verbose --tries=1 --spider http://localhost:5178/health || exit 1
|
||||
CMD wget --no-verbose --tries=1 --spider http://localhost:5020/health || exit 1
|
||||
|
||||
# Run the app
|
||||
CMD ["node", "build"]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue