fix: docker builds (#10)
--------- Co-authored-by: Rem Helper <remhelper@abunchofknowitalls.com> Reviewed-on: https://git.abunchofknowitalls.com/joshuafhiggins/otunes/pulls/10
This commit was merged in pull request #10.
This commit is contained in:
1 parent
680e19a305
commit
0da4909b75
2 files changed
+27
-8
No files matched your search
+8
-3
@@ -3,8 +3,12 @@
|
||||
# Keeps Docker builds fast, lean, and free of development files.
|
||||
############################################################
|
||||
|
||||
# Dependencies (installed inside Docker, never copied)
|
||||
node_modules/
|
||||
# Dependencies (installed inside Docker, never copied).
|
||||
# Use **/ so nested workspace installs (apps/web/node_modules, etc.) are
|
||||
# excluded — a bare "node_modules/" only matches the repo root and would
|
||||
# let host symlinks overwrite the image install during COPY.
|
||||
**/node_modules
|
||||
**/node_modules/**
|
||||
.pnpm-store/
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
@@ -13,7 +17,8 @@ pnpm-debug.log*
|
||||
lerna-debug.log*
|
||||
|
||||
# Next.js build outputs (always generated during `next build`)
|
||||
.next/
|
||||
**/.next
|
||||
**/.next/**
|
||||
out/
|
||||
dist/
|
||||
build/
|
||||
|
||||
+19
-5
@@ -18,10 +18,19 @@ FROM node:${NODE_VERSION} AS dependencies
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml .npmrc ./
|
||||
# Only manifests needed for @otunes/web and its workspace dependency (@otunes/convex).
|
||||
# Mobile is intentionally omitted so its deps are never installed.
|
||||
COPY package.json pnpm-lock.yaml .npmrc ./
|
||||
COPY apps/web/package.json ./apps/web/
|
||||
COPY packages/convex/package.json ./packages/convex/
|
||||
|
||||
# Explicit workspace — do not use apps/* so mobile cannot be discovered.
|
||||
RUN printf '%s\n' \
|
||||
'packages:' \
|
||||
' - "apps/web"' \
|
||||
' - "packages/convex"' \
|
||||
> pnpm-workspace.yaml
|
||||
|
||||
RUN --mount=type=cache,target=/root/.local/share/pnpm/store \
|
||||
corepack enable pnpm && \
|
||||
pnpm install --frozen-lockfile --filter @otunes/web...
|
||||
@@ -30,15 +39,20 @@ RUN --mount=type=cache,target=/root/.local/share/pnpm/store \
|
||||
# Stage 2: Build Next.js application in standalone mode
|
||||
# ============================================
|
||||
|
||||
FROM node:${NODE_VERSION} AS builder
|
||||
# Reuse the installed workspace — no need to re-copy node_modules from a blank image.
|
||||
FROM dependencies AS builder
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY --from=dependencies /app/node_modules ./node_modules
|
||||
COPY --from=dependencies /app/apps/web/node_modules ./apps/web/node_modules
|
||||
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml .npmrc ./
|
||||
# Overlay sources; nested node_modules must be dockerignored so they do not
|
||||
# replace the install from the dependencies stage with host pnpm symlinks.
|
||||
COPY apps/web ./apps/web
|
||||
COPY packages/convex ./packages/convex
|
||||
|
||||
# Re-apply the install tree after source COPY so module resolution cannot be
|
||||
# clobbered even if a nested node_modules slips into the build context.
|
||||
COPY --from=dependencies /app/node_modules ./node_modules
|
||||
COPY --from=dependencies /app/apps/web/node_modules ./apps/web/node_modules
|
||||
COPY --from=dependencies /app/packages/convex/node_modules ./packages/convex/node_modules
|
||||
|
||||
ENV NODE_ENV=production
|
||||
|
||||
Reference in new issue
Block a user