build: Docker setup (compose: postgres + all-in-one api image)
- Dockerfile: 3-stage — Flutter web build, NestJS build, slim node runtime. Runtime copies dist + node_modules + prisma + the web bundle (WEB_CLIENT_DIR=/app/web), runs `prisma migrate deploy` then `node dist/main.js`. One container serves client + API on :3000. - docker-compose.yml: postgres:16-alpine with a healthcheck + the api service; config from backend/.env (Compose v2 strips quotes), DATABASE_URL + GOOGLE_APPLICATION_CREDENTIALS overridden for the container, serviceAccount.json bind-mounted read-only. - .dockerignore keeps node_modules/build/secrets out of the context. Not run here (no Docker on this box); the stack also runs natively against the local Postgres. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
+34
@@ -0,0 +1,34 @@
|
||||
# syntax=docker/dockerfile:1
|
||||
|
||||
# --- 1. Flutter web 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
|
||||
WORKDIR /src
|
||||
COPY backend/package.json backend/package-lock.json ./
|
||||
RUN npm ci
|
||||
COPY backend/ ./
|
||||
RUN npx prisma generate && npm run build
|
||||
|
||||
# --- 3. Runtime ------------------------------------------------------------
|
||||
FROM node:20-bookworm-slim AS runtime
|
||||
ENV NODE_ENV=production
|
||||
WORKDIR /app
|
||||
# Prisma needs OpenSSL at runtime.
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends openssl \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
COPY --from=api-build /src/node_modules ./node_modules
|
||||
COPY --from=api-build /src/dist ./dist
|
||||
COPY --from=api-build /src/prisma ./prisma
|
||||
# The Flutter web build; app.module reads WEB_CLIENT_DIR.
|
||||
COPY --from=web /src/build/web ./web
|
||||
ENV WEB_CLIENT_DIR=/app/web
|
||||
EXPOSE 3000
|
||||
# Apply pending migrations, then boot.
|
||||
CMD ["sh", "-c", "npx prisma migrate deploy && node dist/main.js"]
|
||||
Reference in New Issue
Block a user