Refactor .dockerignore and Dockerfile for optimized build context and caching
- Updated .dockerignore to ignore everything by default while allowing necessary files and directories for the Docker build. - Enhanced Dockerfile to utilize caching for pnpm installation and Turbo build process, improving build performance and efficiency.
This commit is contained in:
parent
3b3c88ed64
commit
63e619eab6
@ -1,7 +1,17 @@
|
||||
node_modules
|
||||
.next
|
||||
.turbo
|
||||
.git
|
||||
*.log
|
||||
# Ignore everything by default
|
||||
*
|
||||
|
||||
docker/backups
|
||||
# Allow only what the Dockerfile needs
|
||||
!package.json
|
||||
!pnpm-lock.yaml
|
||||
!pnpm-workspace.yaml
|
||||
!turbo.json
|
||||
!.npmrc
|
||||
!apps/web/
|
||||
!packages/
|
||||
|
||||
# Re-exclude build artifacts that snuck in
|
||||
apps/web/.next
|
||||
apps/web/node_modules
|
||||
packages/*/node_modules
|
||||
packages/*/dist
|
||||
|
||||
@ -15,12 +15,14 @@ RUN turbo prune @advdoors/web --docker
|
||||
FROM base AS builder
|
||||
COPY --from=pruner /app/out/json/ .
|
||||
COPY --from=pruner /app/out/pnpm-lock.yaml ./pnpm-lock.yaml
|
||||
RUN pnpm install --frozen-lockfile
|
||||
RUN --mount=type=cache,id=pnpm,target=/pnpm/store \
|
||||
pnpm install --frozen-lockfile
|
||||
|
||||
# Copy pruned source and build via Turbo
|
||||
COPY --from=pruner /app/out/full/ .
|
||||
ENV NEXT_TELEMETRY_DISABLED=1
|
||||
RUN pnpm turbo build --filter=@advdoors/web
|
||||
RUN --mount=type=cache,target=/app/apps/web/.next/cache \
|
||||
pnpm turbo build --filter=@advdoors/web
|
||||
|
||||
# Production
|
||||
FROM base AS runner
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user