build: drop the Flutter builder stage from the Docker image
The Flutter SDK image is ~2.8 GB and filled Docker Desktop's VM disk
("read-only file system" while extracting a layer). Build the web bundle
on the host instead and COPY client/app/build/web into the 2-stage
(NestJS build -> slim runtime) image. .dockerignore keeps the bundle,
drops the platform scaffolding. README documents the host `flutter build
web` prerequisite.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
+10
-3
@@ -1,10 +1,17 @@
|
|||||||
**/node_modules
|
**/node_modules
|
||||||
**/dist
|
|
||||||
**/build
|
|
||||||
**/.dart_tool
|
**/.dart_tool
|
||||||
**/coverage
|
**/coverage
|
||||||
.git
|
|
||||||
**/*.log
|
**/*.log
|
||||||
|
.git
|
||||||
|
.github
|
||||||
|
backend/dist
|
||||||
|
# Flutter platform scaffolding / caches — the build/web bundle IS needed.
|
||||||
|
client/app/android
|
||||||
|
client/app/ios
|
||||||
|
client/app/linux
|
||||||
|
client/app/macos
|
||||||
|
client/app/windows
|
||||||
|
client/app/.dart_tool
|
||||||
# Secrets: passed at runtime via env_file / bind mount, never baked in.
|
# Secrets: passed at runtime via env_file / bind mount, never baked in.
|
||||||
backend/.env
|
backend/.env
|
||||||
backend/serviceAccount.json
|
backend/serviceAccount.json
|
||||||
|
|||||||
+9
-12
@@ -1,14 +1,11 @@
|
|||||||
# syntax=docker/dockerfile:1
|
# syntax=docker/dockerfile:1
|
||||||
|
#
|
||||||
|
# The Flutter web bundle is built on the HOST (it needs a ~2.8 GB SDK image
|
||||||
|
# otherwise). Before `docker compose build`, run:
|
||||||
|
# (cd client/app && flutter build web --release)
|
||||||
|
# This Dockerfile just copies client/app/build/web into the runtime image.
|
||||||
|
|
||||||
# --- 1. Flutter web build -------------------------------------------------
|
# --- 1. Backend build ---------------------------------------------------------
|
||||||
FROM ghcr.io/cirruslabs/flutter:stable AS web
|
|
||||||
WORKDIR /src
|
|
||||||
COPY client/app/pubspec.yaml client/app/pubspec.lock ./
|
|
||||||
RUN flutter pub get
|
|
||||||
COPY client/app/ ./
|
|
||||||
RUN flutter build web --release
|
|
||||||
|
|
||||||
# --- 2. Backend build --------------------------------------------------------
|
|
||||||
FROM node:20-bookworm-slim AS api-build
|
FROM node:20-bookworm-slim AS api-build
|
||||||
WORKDIR /src
|
WORKDIR /src
|
||||||
COPY backend/package.json backend/package-lock.json ./
|
COPY backend/package.json backend/package-lock.json ./
|
||||||
@@ -16,7 +13,7 @@ RUN npm ci
|
|||||||
COPY backend/ ./
|
COPY backend/ ./
|
||||||
RUN npx prisma generate && npm run build
|
RUN npx prisma generate && npm run build
|
||||||
|
|
||||||
# --- 3. Runtime ------------------------------------------------------------
|
# --- 2. Runtime -------------------------------------------------------------
|
||||||
FROM node:20-bookworm-slim AS runtime
|
FROM node:20-bookworm-slim AS runtime
|
||||||
ENV NODE_ENV=production
|
ENV NODE_ENV=production
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
@@ -26,8 +23,8 @@ RUN apt-get update && apt-get install -y --no-install-recommends openssl \
|
|||||||
COPY --from=api-build /src/node_modules ./node_modules
|
COPY --from=api-build /src/node_modules ./node_modules
|
||||||
COPY --from=api-build /src/dist ./dist
|
COPY --from=api-build /src/dist ./dist
|
||||||
COPY --from=api-build /src/prisma ./prisma
|
COPY --from=api-build /src/prisma ./prisma
|
||||||
# The Flutter web build; app.module reads WEB_CLIENT_DIR.
|
# Pre-built Flutter web bundle from the host; app.module reads WEB_CLIENT_DIR.
|
||||||
COPY --from=web /src/build/web ./web
|
COPY client/app/build/web ./web
|
||||||
ENV WEB_CLIENT_DIR=/app/web
|
ENV WEB_CLIENT_DIR=/app/web
|
||||||
EXPOSE 3000
|
EXPOSE 3000
|
||||||
# Apply pending migrations, then boot.
|
# Apply pending migrations, then boot.
|
||||||
|
|||||||
Reference in New Issue
Block a user