Skip to content

Commit d8e902a

Browse files
committed
Fix Docker build process and YAML syntax
- Fix YAML syntax error in buildspec.yml (multi-line string causing build failure) - Remove complex runtime Dockerfile generation from buildspec - Use proper multi-stage Docker build with Prisma generation - Update Dockerfile to copy Prisma client from custom location (src/generated/client) - Follow Docker best practices: generate Prisma client during Docker build, not in buildspec This ensures: - Clean YAML without syntax errors - Proper separation of concerns (buildspec handles build, Docker handles packaging) - Prisma client generated consistently in Docker environment - No manual file copying between build phases
1 parent 4182641 commit d8e902a

File tree

2 files changed

+4
-41
lines changed

2 files changed

+4
-41
lines changed

apps/web/Dockerfile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,8 @@ COPY --from=builder /app/public ./public
6666
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
6767
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
6868

69-
# Copy the generated Prisma client (including WASM files)
70-
COPY --from=builder --chown=nextjs:nodejs /app/node_modules/.prisma ./node_modules/.prisma
71-
COPY --from=builder --chown=nextjs:nodejs /app/node_modules/@prisma/client ./node_modules/@prisma/client
69+
# Copy the generated Prisma client from custom output location
70+
COPY --from=builder --chown=nextjs:nodejs /app/src/generated/client ./src/generated/client
7271

7372
# Switch to non-root user
7473
USER nextjs

apps/web/buildspec.yml

Lines changed: 2 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -50,45 +50,9 @@ phases:
5050
- ls -la .next/standalone/public/ || echo "❌ .next/standalone/public/ not found"
5151
- ls -la .next/standalone/server.js || echo "❌ server.js not found"
5252

53-
- echo "=== COPYING PRISMA CLIENT FOR RUNTIME ==="
54-
- echo "Copying generated Prisma client to standalone build..."
55-
- mkdir -p .next/standalone/src/generated
56-
- cp -r src/generated/client .next/standalone/src/generated/ || echo "Warning: Custom Prisma client not found"
57-
- echo "✅ Prisma client copied to standalone build"
58-
5953
- echo "=== BUILDING DOCKER IMAGE WITH BUILD ARTIFACTS ==="
60-
# Note: We're using a simplified runtime Dockerfile here because the build artifacts
61-
# are already created. For local development or standard CI/CD, use the main Dockerfile
62-
# which includes the full multi-stage build process.
63-
- |
64-
cat > Dockerfile.runtime << 'EOF'
65-
# Use Node.js Alpine for smaller image size
66-
FROM node:18-alpine AS runtime
67-
68-
WORKDIR /app
69-
70-
ENV NODE_ENV=production
71-
ENV NEXT_TELEMETRY_DISABLED=1
72-
ENV PORT=3000
73-
ENV HOSTNAME="0.0.0.0"
74-
75-
# Copy the complete standalone build (includes Prisma client)
76-
COPY .next/standalone ./
77-
78-
# Create non-root user for security
79-
RUN addgroup -g 1001 -S nodejs && \
80-
adduser -S nextjs -u 1001 && \
81-
chown -R nextjs:nodejs /app
82-
83-
USER nextjs
84-
85-
EXPOSE 3000
86-
87-
# Use node to run the standalone server.js
88-
CMD ["node", "server.js"]
89-
EOF
90-
91-
- docker build -f Dockerfile.runtime -t $IMAGE_REPO_NAME:$IMAGE_TAG .
54+
- echo "Using proper Docker build process with Prisma generation..."
55+
- docker build -t $IMAGE_REPO_NAME:$IMAGE_TAG .
9256
- docker tag $IMAGE_REPO_NAME:$IMAGE_TAG $REPOSITORY_URI:$IMAGE_TAG
9357
- docker tag $IMAGE_REPO_NAME:$IMAGE_TAG $REPOSITORY_URI:latest
9458

0 commit comments

Comments
 (0)